[PATCH AArch64] Add a builtin for rbit(q?)_p8; add intrinsics and tests.
[official-gcc.git] / gcc / tree-pretty-print.c
blobce0c655bd3d8781c4246bede1245710f9a4c07d9
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "stor-layout.h"
27 #include "expr.h"
28 #include "tree-pretty-print.h"
29 #include "hashtab.h"
30 #include "hash-set.h"
31 #include "gimple-expr.h"
32 #include "cgraph.h"
33 #include "langhooks.h"
34 #include "tree-iterator.h"
35 #include "tree-chrec.h"
36 #include "dumpfile.h"
37 #include "value-prof.h"
38 #include "predict.h"
39 #include "wide-int-print.h"
40 #include "internal-fn.h"
42 #include <new> // For placement-new.
44 /* Local functions, macros and variables. */
45 static const char *op_symbol (const_tree);
46 static void pretty_print_string (pretty_printer *, const char*);
47 static void newline_and_indent (pretty_printer *, int);
48 static void maybe_init_pretty_print (FILE *);
49 static void print_struct_decl (pretty_printer *, const_tree, int, int);
50 static void do_niy (pretty_printer *, const_tree);
52 #define INDENT(SPACE) do { \
53 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
55 #define NIY do_niy (buffer, node)
57 static pretty_printer buffer;
58 static int initialized = 0;
60 /* Try to print something for an unknown tree code. */
62 static void
63 do_niy (pretty_printer *buffer, const_tree node)
65 int i, len;
67 pp_string (buffer, "<<< Unknown tree: ");
68 pp_string (buffer, get_tree_code_name (TREE_CODE (node)));
70 if (EXPR_P (node))
72 len = TREE_OPERAND_LENGTH (node);
73 for (i = 0; i < len; ++i)
75 newline_and_indent (buffer, 2);
76 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
80 pp_string (buffer, " >>>");
83 /* Debugging function to print out a generic expression. */
85 DEBUG_FUNCTION void
86 debug_generic_expr (tree t)
88 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
89 fprintf (stderr, "\n");
92 /* Debugging function to print out a generic statement. */
94 DEBUG_FUNCTION void
95 debug_generic_stmt (tree t)
97 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
98 fprintf (stderr, "\n");
101 /* Debugging function to print out a chain of trees . */
103 DEBUG_FUNCTION void
104 debug_tree_chain (tree t)
106 hash_set<tree> seen;
108 while (t)
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
111 fprintf (stderr, " ");
112 t = TREE_CHAIN (t);
113 if (seen.add (t))
115 fprintf (stderr, "... [cycled back to ");
116 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
117 fprintf (stderr, "]");
118 break;
121 fprintf (stderr, "\n");
124 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
125 void
126 print_generic_decl (FILE *file, tree decl, int flags)
128 maybe_init_pretty_print (file);
129 print_declaration (&buffer, decl, 2, flags);
130 pp_write_text_to_stream (&buffer);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in dumpfile.h. */
136 void
137 print_generic_stmt (FILE *file, tree t, int flags)
139 maybe_init_pretty_print (file);
140 dump_generic_node (&buffer, t, 0, flags, true);
141 pp_newline_and_flush (&buffer);
144 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
145 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
146 INDENT spaces. */
148 void
149 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
151 int i;
153 maybe_init_pretty_print (file);
155 for (i = 0; i < indent; i++)
156 pp_space (&buffer);
157 dump_generic_node (&buffer, t, indent, flags, true);
158 pp_newline_and_flush (&buffer);
161 /* Print a single expression T on file FILE. FLAGS specifies details to show
162 in the dump. See TDF_* in dumpfile.h. */
164 void
165 print_generic_expr (FILE *file, tree t, int flags)
167 maybe_init_pretty_print (file);
168 dump_generic_node (&buffer, t, 0, flags, false);
169 pp_flush (&buffer);
172 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
173 in FLAGS. */
175 static void
176 dump_decl_name (pretty_printer *buffer, tree node, int flags)
178 if (DECL_NAME (node))
180 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
181 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
182 else
183 pp_tree_identifier (buffer, DECL_NAME (node));
185 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
187 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
188 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
189 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
191 if (flags & TDF_NOUID)
192 pp_string (buffer, "D#xxxx");
193 else
194 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
196 else
198 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
199 if (flags & TDF_NOUID)
200 pp_printf (buffer, "%c.xxxx", c);
201 else
202 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
205 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
207 if (flags & TDF_NOUID)
208 pp_printf (buffer, "ptD.xxxx");
209 else
210 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
214 /* Like the above, but used for pretty printing function calls. */
216 static void
217 dump_function_name (pretty_printer *buffer, tree node, int flags)
219 if (TREE_CODE (node) == NOP_EXPR)
220 node = TREE_OPERAND (node, 0);
221 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
222 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
223 else
224 dump_decl_name (buffer, node, flags);
227 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
228 FLAGS are as in dump_generic_node. */
230 static void
231 dump_function_declaration (pretty_printer *buffer, tree node,
232 int spc, int flags)
234 bool wrote_arg = false;
235 tree arg;
237 pp_space (buffer);
238 pp_left_paren (buffer);
240 /* Print the argument types. */
241 arg = TYPE_ARG_TYPES (node);
242 while (arg && arg != void_list_node && arg != error_mark_node)
244 if (wrote_arg)
246 pp_comma (buffer);
247 pp_space (buffer);
249 wrote_arg = true;
250 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
251 arg = TREE_CHAIN (arg);
254 /* Drop the trailing void_type_node if we had any previous argument. */
255 if (arg == void_list_node && !wrote_arg)
256 pp_string (buffer, "void");
257 /* Properly dump vararg function types. */
258 else if (!arg && wrote_arg)
259 pp_string (buffer, ", ...");
260 /* Avoid printing any arg for unprototyped functions. */
262 pp_right_paren (buffer);
265 /* Dump the domain associated with an array. */
267 static void
268 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
270 pp_left_bracket (buffer);
271 if (domain)
273 tree min = TYPE_MIN_VALUE (domain);
274 tree max = TYPE_MAX_VALUE (domain);
276 if (min && max
277 && integer_zerop (min)
278 && tree_fits_shwi_p (max))
279 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
280 else
282 if (min)
283 dump_generic_node (buffer, min, spc, flags, false);
284 pp_colon (buffer);
285 if (max)
286 dump_generic_node (buffer, max, spc, flags, false);
289 else
290 pp_string (buffer, "<unknown>");
291 pp_right_bracket (buffer);
295 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
296 dump_generic_node. */
298 static void
299 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
301 const char *name;
303 switch (OMP_CLAUSE_CODE (clause))
305 case OMP_CLAUSE_PRIVATE:
306 name = "private";
307 goto print_remap;
308 case OMP_CLAUSE_SHARED:
309 name = "shared";
310 goto print_remap;
311 case OMP_CLAUSE_FIRSTPRIVATE:
312 name = "firstprivate";
313 goto print_remap;
314 case OMP_CLAUSE_LASTPRIVATE:
315 name = "lastprivate";
316 goto print_remap;
317 case OMP_CLAUSE_COPYIN:
318 name = "copyin";
319 goto print_remap;
320 case OMP_CLAUSE_COPYPRIVATE:
321 name = "copyprivate";
322 goto print_remap;
323 case OMP_CLAUSE_UNIFORM:
324 name = "uniform";
325 goto print_remap;
326 case OMP_CLAUSE__LOOPTEMP_:
327 name = "_looptemp_";
328 goto print_remap;
329 print_remap:
330 pp_string (buffer, name);
331 pp_left_paren (buffer);
332 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
333 spc, flags, false);
334 pp_right_paren (buffer);
335 break;
337 case OMP_CLAUSE_REDUCTION:
338 pp_string (buffer, "reduction(");
339 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
341 pp_string (buffer,
342 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
343 pp_colon (buffer);
345 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
346 spc, flags, false);
347 pp_right_paren (buffer);
348 break;
350 case OMP_CLAUSE_IF:
351 pp_string (buffer, "if(");
352 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
353 spc, flags, false);
354 pp_right_paren (buffer);
355 break;
357 case OMP_CLAUSE_NUM_THREADS:
358 pp_string (buffer, "num_threads(");
359 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
360 spc, flags, false);
361 pp_right_paren (buffer);
362 break;
364 case OMP_CLAUSE__CILK_FOR_COUNT_:
365 pp_string (buffer, "_Cilk_for_count_(");
366 dump_generic_node (buffer, OMP_CLAUSE_OPERAND (clause, 0),
367 spc, flags, false);
368 pp_right_paren (buffer);
369 break;
371 case OMP_CLAUSE_NOWAIT:
372 pp_string (buffer, "nowait");
373 break;
374 case OMP_CLAUSE_ORDERED:
375 pp_string (buffer, "ordered");
376 break;
378 case OMP_CLAUSE_DEFAULT:
379 pp_string (buffer, "default(");
380 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
382 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
383 break;
384 case OMP_CLAUSE_DEFAULT_SHARED:
385 pp_string (buffer, "shared");
386 break;
387 case OMP_CLAUSE_DEFAULT_NONE:
388 pp_string (buffer, "none");
389 break;
390 case OMP_CLAUSE_DEFAULT_PRIVATE:
391 pp_string (buffer, "private");
392 break;
393 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
394 pp_string (buffer, "firstprivate");
395 break;
396 default:
397 gcc_unreachable ();
399 pp_right_paren (buffer);
400 break;
402 case OMP_CLAUSE_SCHEDULE:
403 pp_string (buffer, "schedule(");
404 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
406 case OMP_CLAUSE_SCHEDULE_STATIC:
407 pp_string (buffer, "static");
408 break;
409 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
410 pp_string (buffer, "dynamic");
411 break;
412 case OMP_CLAUSE_SCHEDULE_GUIDED:
413 pp_string (buffer, "guided");
414 break;
415 case OMP_CLAUSE_SCHEDULE_RUNTIME:
416 pp_string (buffer, "runtime");
417 break;
418 case OMP_CLAUSE_SCHEDULE_AUTO:
419 pp_string (buffer, "auto");
420 break;
421 case OMP_CLAUSE_SCHEDULE_CILKFOR:
422 pp_string (buffer, "cilk-for grain");
423 break;
424 default:
425 gcc_unreachable ();
427 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
429 pp_comma (buffer);
430 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
431 spc, flags, false);
433 pp_right_paren (buffer);
434 break;
436 case OMP_CLAUSE_UNTIED:
437 pp_string (buffer, "untied");
438 break;
440 case OMP_CLAUSE_COLLAPSE:
441 pp_string (buffer, "collapse(");
442 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
443 spc, flags, false);
444 pp_right_paren (buffer);
445 break;
447 case OMP_CLAUSE_FINAL:
448 pp_string (buffer, "final(");
449 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
450 spc, flags, false);
451 pp_right_paren (buffer);
452 break;
454 case OMP_CLAUSE_MERGEABLE:
455 pp_string (buffer, "mergeable");
456 break;
458 case OMP_CLAUSE_LINEAR:
459 pp_string (buffer, "linear(");
460 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
461 spc, flags, false);
462 pp_colon (buffer);
463 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
464 spc, flags, false);
465 pp_right_paren (buffer);
466 break;
468 case OMP_CLAUSE_ALIGNED:
469 pp_string (buffer, "aligned(");
470 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
471 spc, flags, false);
472 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
474 pp_colon (buffer);
475 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
476 spc, flags, false);
478 pp_right_paren (buffer);
479 break;
481 case OMP_CLAUSE_DEPEND:
482 pp_string (buffer, "depend(");
483 switch (OMP_CLAUSE_DEPEND_KIND (clause))
485 case OMP_CLAUSE_DEPEND_IN:
486 pp_string (buffer, "in");
487 break;
488 case OMP_CLAUSE_DEPEND_OUT:
489 pp_string (buffer, "out");
490 break;
491 case OMP_CLAUSE_DEPEND_INOUT:
492 pp_string (buffer, "inout");
493 break;
494 default:
495 gcc_unreachable ();
497 pp_colon (buffer);
498 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
499 spc, flags, false);
500 pp_right_paren (buffer);
501 break;
503 case OMP_CLAUSE_MAP:
504 pp_string (buffer, "map(");
505 switch (OMP_CLAUSE_MAP_KIND (clause))
507 case OMP_CLAUSE_MAP_ALLOC:
508 case OMP_CLAUSE_MAP_POINTER:
509 pp_string (buffer, "alloc");
510 break;
511 case OMP_CLAUSE_MAP_TO:
512 case OMP_CLAUSE_MAP_TO_PSET:
513 pp_string (buffer, "to");
514 break;
515 case OMP_CLAUSE_MAP_FROM:
516 pp_string (buffer, "from");
517 break;
518 case OMP_CLAUSE_MAP_TOFROM:
519 pp_string (buffer, "tofrom");
520 break;
521 default:
522 gcc_unreachable ();
524 pp_colon (buffer);
525 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
526 spc, flags, false);
527 print_clause_size:
528 if (OMP_CLAUSE_SIZE (clause))
530 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
531 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
532 pp_string (buffer, " [pointer assign, bias: ");
533 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
534 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_TO_PSET)
535 pp_string (buffer, " [pointer set, len: ");
536 else
537 pp_string (buffer, " [len: ");
538 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
539 spc, flags, false);
540 pp_right_bracket (buffer);
542 pp_right_paren (buffer);
543 break;
545 case OMP_CLAUSE_FROM:
546 pp_string (buffer, "from(");
547 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
548 spc, flags, false);
549 goto print_clause_size;
551 case OMP_CLAUSE_TO:
552 pp_string (buffer, "to(");
553 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
554 spc, flags, false);
555 goto print_clause_size;
557 case OMP_CLAUSE_NUM_TEAMS:
558 pp_string (buffer, "num_teams(");
559 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
560 spc, flags, false);
561 pp_right_paren (buffer);
562 break;
564 case OMP_CLAUSE_THREAD_LIMIT:
565 pp_string (buffer, "thread_limit(");
566 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
567 spc, flags, false);
568 pp_right_paren (buffer);
569 break;
571 case OMP_CLAUSE_DEVICE:
572 pp_string (buffer, "device(");
573 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
574 spc, flags, false);
575 pp_right_paren (buffer);
576 break;
578 case OMP_CLAUSE_DIST_SCHEDULE:
579 pp_string (buffer, "dist_schedule(static");
580 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
582 pp_comma (buffer);
583 dump_generic_node (buffer,
584 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
585 spc, flags, false);
587 pp_right_paren (buffer);
588 break;
590 case OMP_CLAUSE_PROC_BIND:
591 pp_string (buffer, "proc_bind(");
592 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
594 case OMP_CLAUSE_PROC_BIND_MASTER:
595 pp_string (buffer, "master");
596 break;
597 case OMP_CLAUSE_PROC_BIND_CLOSE:
598 pp_string (buffer, "close");
599 break;
600 case OMP_CLAUSE_PROC_BIND_SPREAD:
601 pp_string (buffer, "spread");
602 break;
603 default:
604 gcc_unreachable ();
606 pp_right_paren (buffer);
607 break;
609 case OMP_CLAUSE_SAFELEN:
610 pp_string (buffer, "safelen(");
611 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
612 spc, flags, false);
613 pp_right_paren (buffer);
614 break;
616 case OMP_CLAUSE_SIMDLEN:
617 pp_string (buffer, "simdlen(");
618 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
619 spc, flags, false);
620 pp_right_paren (buffer);
621 break;
623 case OMP_CLAUSE__SIMDUID_:
624 pp_string (buffer, "_simduid_(");
625 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
626 spc, flags, false);
627 pp_right_paren (buffer);
628 break;
630 case OMP_CLAUSE_INBRANCH:
631 pp_string (buffer, "inbranch");
632 break;
633 case OMP_CLAUSE_NOTINBRANCH:
634 pp_string (buffer, "notinbranch");
635 break;
636 case OMP_CLAUSE_FOR:
637 pp_string (buffer, "for");
638 break;
639 case OMP_CLAUSE_PARALLEL:
640 pp_string (buffer, "parallel");
641 break;
642 case OMP_CLAUSE_SECTIONS:
643 pp_string (buffer, "sections");
644 break;
645 case OMP_CLAUSE_TASKGROUP:
646 pp_string (buffer, "taskgroup");
647 break;
649 default:
650 /* Should never happen. */
651 dump_generic_node (buffer, clause, spc, flags, false);
652 break;
657 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
658 dump_generic_node. */
660 void
661 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
663 if (clause == NULL)
664 return;
666 pp_space (buffer);
667 while (1)
669 dump_omp_clause (buffer, clause, spc, flags);
670 clause = OMP_CLAUSE_CHAIN (clause);
671 if (clause == NULL)
672 return;
673 pp_space (buffer);
678 /* Dump location LOC to BUFFER. */
680 static void
681 dump_location (pretty_printer *buffer, location_t loc)
683 expanded_location xloc = expand_location (loc);
685 pp_left_bracket (buffer);
686 if (xloc.file)
688 pp_string (buffer, xloc.file);
689 pp_string (buffer, " : ");
691 pp_decimal_int (buffer, xloc.line);
692 pp_string (buffer, "] ");
696 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
697 dump_generic_node. */
699 static void
700 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
702 tree t;
704 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
706 if (flags & TDF_ADDRESS)
707 pp_printf (buffer, "[%p] ", (void *) block);
709 if (BLOCK_ABSTRACT (block))
710 pp_string (buffer, "[abstract] ");
712 if (TREE_ASM_WRITTEN (block))
713 pp_string (buffer, "[written] ");
715 if (flags & TDF_SLIM)
716 return;
718 if (BLOCK_SOURCE_LOCATION (block))
719 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
721 newline_and_indent (buffer, spc + 2);
723 if (BLOCK_SUPERCONTEXT (block))
725 pp_string (buffer, "SUPERCONTEXT: ");
726 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
727 flags | TDF_SLIM, false);
728 newline_and_indent (buffer, spc + 2);
731 if (BLOCK_SUBBLOCKS (block))
733 pp_string (buffer, "SUBBLOCKS: ");
734 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
736 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
737 pp_space (buffer);
739 newline_and_indent (buffer, spc + 2);
742 if (BLOCK_CHAIN (block))
744 pp_string (buffer, "SIBLINGS: ");
745 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
747 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
748 pp_space (buffer);
750 newline_and_indent (buffer, spc + 2);
753 if (BLOCK_VARS (block))
755 pp_string (buffer, "VARS: ");
756 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
758 dump_generic_node (buffer, t, 0, flags, false);
759 pp_space (buffer);
761 newline_and_indent (buffer, spc + 2);
764 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
766 unsigned i;
767 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
769 pp_string (buffer, "NONLOCALIZED_VARS: ");
770 FOR_EACH_VEC_ELT (*nlv, i, t)
772 dump_generic_node (buffer, t, 0, flags, false);
773 pp_space (buffer);
775 newline_and_indent (buffer, spc + 2);
778 if (BLOCK_ABSTRACT_ORIGIN (block))
780 pp_string (buffer, "ABSTRACT_ORIGIN: ");
781 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
782 flags | TDF_SLIM, false);
783 newline_and_indent (buffer, spc + 2);
786 if (BLOCK_FRAGMENT_ORIGIN (block))
788 pp_string (buffer, "FRAGMENT_ORIGIN: ");
789 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
790 flags | TDF_SLIM, false);
791 newline_and_indent (buffer, spc + 2);
794 if (BLOCK_FRAGMENT_CHAIN (block))
796 pp_string (buffer, "FRAGMENT_CHAIN: ");
797 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
799 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
800 pp_space (buffer);
802 newline_and_indent (buffer, spc + 2);
807 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
808 indent. FLAGS specifies details to show in the dump (see TDF_* in
809 dumpfile.h). If IS_STMT is true, the object printed is considered
810 to be a statement and it is terminated by ';' if appropriate. */
813 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
814 bool is_stmt)
816 tree type;
817 tree op0, op1;
818 const char *str;
819 bool is_expr;
820 enum tree_code code;
822 if (node == NULL_TREE)
823 return spc;
825 is_expr = EXPR_P (node);
827 if (is_stmt && (flags & TDF_STMTADDR))
828 pp_printf (buffer, "<&%p> ", (void *)node);
830 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
831 dump_location (buffer, EXPR_LOCATION (node));
833 code = TREE_CODE (node);
834 switch (code)
836 case ERROR_MARK:
837 pp_string (buffer, "<<< error >>>");
838 break;
840 case IDENTIFIER_NODE:
841 pp_tree_identifier (buffer, node);
842 break;
844 case TREE_LIST:
845 while (node && node != error_mark_node)
847 if (TREE_PURPOSE (node))
849 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
850 pp_space (buffer);
852 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
853 node = TREE_CHAIN (node);
854 if (node && TREE_CODE (node) == TREE_LIST)
856 pp_comma (buffer);
857 pp_space (buffer);
860 break;
862 case TREE_BINFO:
863 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
864 break;
866 case TREE_VEC:
868 size_t i;
869 if (TREE_VEC_LENGTH (node) > 0)
871 size_t len = TREE_VEC_LENGTH (node);
872 for (i = 0; i < len - 1; i++)
874 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
875 false);
876 pp_comma (buffer);
877 pp_space (buffer);
879 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
880 flags, false);
883 break;
885 case VOID_TYPE:
886 case INTEGER_TYPE:
887 case REAL_TYPE:
888 case FIXED_POINT_TYPE:
889 case COMPLEX_TYPE:
890 case VECTOR_TYPE:
891 case ENUMERAL_TYPE:
892 case BOOLEAN_TYPE:
894 unsigned int quals = TYPE_QUALS (node);
895 enum tree_code_class tclass;
897 if (quals & TYPE_QUAL_ATOMIC)
898 pp_string (buffer, "atomic ");
899 if (quals & TYPE_QUAL_CONST)
900 pp_string (buffer, "const ");
901 else if (quals & TYPE_QUAL_VOLATILE)
902 pp_string (buffer, "volatile ");
903 else if (quals & TYPE_QUAL_RESTRICT)
904 pp_string (buffer, "restrict ");
906 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
908 pp_string (buffer, "<address-space-");
909 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
910 pp_string (buffer, "> ");
913 tclass = TREE_CODE_CLASS (TREE_CODE (node));
915 if (tclass == tcc_declaration)
917 if (DECL_NAME (node))
918 dump_decl_name (buffer, node, flags);
919 else
920 pp_string (buffer, "<unnamed type decl>");
922 else if (tclass == tcc_type)
924 if (TYPE_NAME (node))
926 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
927 pp_tree_identifier (buffer, TYPE_NAME (node));
928 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
929 && DECL_NAME (TYPE_NAME (node)))
930 dump_decl_name (buffer, TYPE_NAME (node), flags);
931 else
932 pp_string (buffer, "<unnamed type>");
934 else if (TREE_CODE (node) == VECTOR_TYPE)
936 pp_string (buffer, "vector");
937 pp_left_paren (buffer);
938 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
939 pp_string (buffer, ") ");
940 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
942 else if (TREE_CODE (node) == INTEGER_TYPE)
944 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
945 pp_string (buffer, (TYPE_UNSIGNED (node)
946 ? "unsigned char"
947 : "signed char"));
948 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
949 pp_string (buffer, (TYPE_UNSIGNED (node)
950 ? "unsigned short"
951 : "signed short"));
952 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
953 pp_string (buffer, (TYPE_UNSIGNED (node)
954 ? "unsigned int"
955 : "signed int"));
956 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
957 pp_string (buffer, (TYPE_UNSIGNED (node)
958 ? "unsigned long"
959 : "signed long"));
960 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
961 pp_string (buffer, (TYPE_UNSIGNED (node)
962 ? "unsigned long long"
963 : "signed long long"));
964 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
965 && exact_log2 (TYPE_PRECISION (node)) != -1)
967 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
968 pp_decimal_int (buffer, TYPE_PRECISION (node));
969 pp_string (buffer, "_t");
971 else
973 pp_string (buffer, (TYPE_UNSIGNED (node)
974 ? "<unnamed-unsigned:"
975 : "<unnamed-signed:"));
976 pp_decimal_int (buffer, TYPE_PRECISION (node));
977 pp_greater (buffer);
980 else if (TREE_CODE (node) == COMPLEX_TYPE)
982 pp_string (buffer, "__complex__ ");
983 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
985 else if (TREE_CODE (node) == REAL_TYPE)
987 pp_string (buffer, "<float:");
988 pp_decimal_int (buffer, TYPE_PRECISION (node));
989 pp_greater (buffer);
991 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
993 pp_string (buffer, "<fixed-point-");
994 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
995 pp_decimal_int (buffer, TYPE_PRECISION (node));
996 pp_greater (buffer);
998 else if (TREE_CODE (node) == VOID_TYPE)
999 pp_string (buffer, "void");
1000 else
1001 pp_string (buffer, "<unnamed type>");
1003 break;
1006 case POINTER_TYPE:
1007 case REFERENCE_TYPE:
1008 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1010 if (TREE_TYPE (node) == NULL)
1012 pp_string (buffer, str);
1013 pp_string (buffer, "<null type>");
1015 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1017 tree fnode = TREE_TYPE (node);
1019 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1020 pp_space (buffer);
1021 pp_left_paren (buffer);
1022 pp_string (buffer, str);
1023 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1024 dump_decl_name (buffer, TYPE_NAME (node), flags);
1025 else if (flags & TDF_NOUID)
1026 pp_printf (buffer, "<Txxxx>");
1027 else
1028 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1030 pp_right_paren (buffer);
1031 dump_function_declaration (buffer, fnode, spc, flags);
1033 else
1035 unsigned int quals = TYPE_QUALS (node);
1037 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1038 pp_space (buffer);
1039 pp_string (buffer, str);
1041 if (quals & TYPE_QUAL_CONST)
1042 pp_string (buffer, " const");
1043 if (quals & TYPE_QUAL_VOLATILE)
1044 pp_string (buffer, " volatile");
1045 if (quals & TYPE_QUAL_RESTRICT)
1046 pp_string (buffer, " restrict");
1048 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1050 pp_string (buffer, " <address-space-");
1051 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1052 pp_greater (buffer);
1055 if (TYPE_REF_CAN_ALIAS_ALL (node))
1056 pp_string (buffer, " {ref-all}");
1058 break;
1060 case OFFSET_TYPE:
1061 NIY;
1062 break;
1064 case MEM_REF:
1066 if (integer_zerop (TREE_OPERAND (node, 1))
1067 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1068 infer them and MEM_ATTR caching will share MEM_REFs
1069 with differently-typed op0s. */
1070 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1071 /* Released SSA_NAMES have no TREE_TYPE. */
1072 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1073 /* Same pointer types, but ignoring POINTER_TYPE vs.
1074 REFERENCE_TYPE. */
1075 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1076 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1077 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1078 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1079 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1080 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1081 /* Same value types ignoring qualifiers. */
1082 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1083 == TYPE_MAIN_VARIANT
1084 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1086 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1088 pp_star (buffer);
1089 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1090 spc, flags, false);
1092 else
1093 dump_generic_node (buffer,
1094 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1095 spc, flags, false);
1097 else
1099 tree ptype;
1101 pp_string (buffer, "MEM[");
1102 pp_left_paren (buffer);
1103 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1104 dump_generic_node (buffer, ptype,
1105 spc, flags | TDF_SLIM, false);
1106 pp_right_paren (buffer);
1107 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1108 spc, flags, false);
1109 if (!integer_zerop (TREE_OPERAND (node, 1)))
1111 pp_string (buffer, " + ");
1112 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1113 spc, flags, false);
1115 pp_right_bracket (buffer);
1117 break;
1120 case TARGET_MEM_REF:
1122 const char *sep = "";
1123 tree tmp;
1125 pp_string (buffer, "MEM[");
1127 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1129 pp_string (buffer, sep);
1130 sep = ", ";
1131 pp_string (buffer, "symbol: ");
1132 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1133 spc, flags, false);
1135 else
1137 pp_string (buffer, sep);
1138 sep = ", ";
1139 pp_string (buffer, "base: ");
1140 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1142 tmp = TMR_INDEX2 (node);
1143 if (tmp)
1145 pp_string (buffer, sep);
1146 sep = ", ";
1147 pp_string (buffer, "base: ");
1148 dump_generic_node (buffer, tmp, spc, flags, false);
1150 tmp = TMR_INDEX (node);
1151 if (tmp)
1153 pp_string (buffer, sep);
1154 sep = ", ";
1155 pp_string (buffer, "index: ");
1156 dump_generic_node (buffer, tmp, spc, flags, false);
1158 tmp = TMR_STEP (node);
1159 if (tmp)
1161 pp_string (buffer, sep);
1162 sep = ", ";
1163 pp_string (buffer, "step: ");
1164 dump_generic_node (buffer, tmp, spc, flags, false);
1166 tmp = TMR_OFFSET (node);
1167 if (tmp)
1169 pp_string (buffer, sep);
1170 sep = ", ";
1171 pp_string (buffer, "offset: ");
1172 dump_generic_node (buffer, tmp, spc, flags, false);
1174 pp_right_bracket (buffer);
1176 break;
1178 case ARRAY_TYPE:
1180 tree tmp;
1182 /* Print the innermost component type. */
1183 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1184 tmp = TREE_TYPE (tmp))
1186 dump_generic_node (buffer, tmp, spc, flags, false);
1188 /* Print the dimensions. */
1189 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1190 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1191 break;
1194 case RECORD_TYPE:
1195 case UNION_TYPE:
1196 case QUAL_UNION_TYPE:
1198 unsigned int quals = TYPE_QUALS (node);
1200 if (quals & TYPE_QUAL_ATOMIC)
1201 pp_string (buffer, "atomic ");
1202 if (quals & TYPE_QUAL_CONST)
1203 pp_string (buffer, "const ");
1204 if (quals & TYPE_QUAL_VOLATILE)
1205 pp_string (buffer, "volatile ");
1207 /* Print the name of the structure. */
1208 if (TREE_CODE (node) == RECORD_TYPE)
1209 pp_string (buffer, "struct ");
1210 else if (TREE_CODE (node) == UNION_TYPE)
1211 pp_string (buffer, "union ");
1213 if (TYPE_NAME (node))
1214 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1215 else if (!(flags & TDF_SLIM))
1216 /* FIXME: If we eliminate the 'else' above and attempt
1217 to show the fields for named types, we may get stuck
1218 following a cycle of pointers to structs. The alleged
1219 self-reference check in print_struct_decl will not detect
1220 cycles involving more than one pointer or struct type. */
1221 print_struct_decl (buffer, node, spc, flags);
1222 break;
1225 case LANG_TYPE:
1226 NIY;
1227 break;
1229 case INTEGER_CST:
1230 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1232 /* In the case of a pointer, one may want to divide by the
1233 size of the pointed-to type. Unfortunately, this not
1234 straightforward. The C front-end maps expressions
1236 (int *) 5
1237 int *p; (p + 5)
1239 in such a way that the two INTEGER_CST nodes for "5" have
1240 different values but identical types. In the latter
1241 case, the 5 is multiplied by sizeof (int) in c-common.c
1242 (pointer_int_sum) to convert it to a byte address, and
1243 yet the type of the node is left unchanged. Argh. What
1244 is consistent though is that the number value corresponds
1245 to bytes (UNITS) offset.
1247 NB: Neither of the following divisors can be trivially
1248 used to recover the original literal:
1250 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1251 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1252 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1253 pp_string (buffer, "B"); /* pseudo-unit */
1255 else if (tree_fits_shwi_p (node))
1256 pp_wide_integer (buffer, tree_to_shwi (node));
1257 else if (tree_fits_uhwi_p (node))
1258 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1259 else
1261 wide_int val = node;
1263 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1265 pp_minus (buffer);
1266 val = -val;
1268 print_hex (val, pp_buffer (buffer)->digit_buffer);
1269 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1271 if (TREE_OVERFLOW (node))
1272 pp_string (buffer, "(OVF)");
1273 break;
1275 case REAL_CST:
1276 /* Code copied from print_node. */
1278 REAL_VALUE_TYPE d;
1279 if (TREE_OVERFLOW (node))
1280 pp_string (buffer, " overflow");
1282 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1283 d = TREE_REAL_CST (node);
1284 if (REAL_VALUE_ISINF (d))
1285 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1286 else if (REAL_VALUE_ISNAN (d))
1287 pp_string (buffer, " Nan");
1288 else
1290 char string[100];
1291 real_to_decimal (string, &d, sizeof (string), 0, 1);
1292 pp_string (buffer, string);
1294 #else
1296 HOST_WIDE_INT i;
1297 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1298 pp_string (buffer, "0x");
1299 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1300 output_formatted_integer (buffer, "%02x", *p++);
1302 #endif
1303 break;
1306 case FIXED_CST:
1308 char string[100];
1309 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1310 pp_string (buffer, string);
1311 break;
1314 case COMPLEX_CST:
1315 pp_string (buffer, "__complex__ (");
1316 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1317 pp_string (buffer, ", ");
1318 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1319 pp_right_paren (buffer);
1320 break;
1322 case STRING_CST:
1323 pp_string (buffer, "\"");
1324 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1325 pp_string (buffer, "\"");
1326 break;
1328 case VECTOR_CST:
1330 unsigned i;
1331 pp_string (buffer, "{ ");
1332 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1334 if (i != 0)
1335 pp_string (buffer, ", ");
1336 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1337 spc, flags, false);
1339 pp_string (buffer, " }");
1341 break;
1343 case FUNCTION_TYPE:
1344 case METHOD_TYPE:
1345 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1346 pp_space (buffer);
1347 if (TREE_CODE (node) == METHOD_TYPE)
1349 if (TYPE_METHOD_BASETYPE (node))
1350 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1351 flags);
1352 else
1353 pp_string (buffer, "<null method basetype>");
1354 pp_colon_colon (buffer);
1356 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1357 dump_decl_name (buffer, TYPE_NAME (node), flags);
1358 else if (flags & TDF_NOUID)
1359 pp_printf (buffer, "<Txxxx>");
1360 else
1361 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1362 dump_function_declaration (buffer, node, spc, flags);
1363 break;
1365 case FUNCTION_DECL:
1366 case CONST_DECL:
1367 dump_decl_name (buffer, node, flags);
1368 break;
1370 case LABEL_DECL:
1371 if (DECL_NAME (node))
1372 dump_decl_name (buffer, node, flags);
1373 else if (LABEL_DECL_UID (node) != -1)
1374 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1375 else
1377 if (flags & TDF_NOUID)
1378 pp_string (buffer, "<D.xxxx>");
1379 else
1380 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1382 break;
1384 case TYPE_DECL:
1385 if (DECL_IS_BUILTIN (node))
1387 /* Don't print the declaration of built-in types. */
1388 break;
1390 if (DECL_NAME (node))
1391 dump_decl_name (buffer, node, flags);
1392 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1394 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1395 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1396 && TYPE_METHODS (TREE_TYPE (node)))
1398 /* The type is a c++ class: all structures have at least
1399 4 methods. */
1400 pp_string (buffer, "class ");
1401 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1403 else
1405 pp_string (buffer,
1406 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1407 ? "union" : "struct "));
1408 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1411 else
1412 pp_string (buffer, "<anon>");
1413 break;
1415 case VAR_DECL:
1416 case PARM_DECL:
1417 case FIELD_DECL:
1418 case DEBUG_EXPR_DECL:
1419 case NAMESPACE_DECL:
1420 case NAMELIST_DECL:
1421 dump_decl_name (buffer, node, flags);
1422 break;
1424 case RESULT_DECL:
1425 pp_string (buffer, "<retval>");
1426 break;
1428 case COMPONENT_REF:
1429 op0 = TREE_OPERAND (node, 0);
1430 str = ".";
1431 if (op0
1432 && (TREE_CODE (op0) == INDIRECT_REF
1433 || (TREE_CODE (op0) == MEM_REF
1434 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1435 && integer_zerop (TREE_OPERAND (op0, 1))
1436 /* Dump the types of INTEGER_CSTs explicitly, for we
1437 can't infer them and MEM_ATTR caching will share
1438 MEM_REFs with differently-typed op0s. */
1439 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1440 /* Released SSA_NAMES have no TREE_TYPE. */
1441 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1442 /* Same pointer types, but ignoring POINTER_TYPE vs.
1443 REFERENCE_TYPE. */
1444 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1445 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1446 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1447 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1448 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1449 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1450 /* Same value types ignoring qualifiers. */
1451 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1452 == TYPE_MAIN_VARIANT
1453 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1455 op0 = TREE_OPERAND (op0, 0);
1456 str = "->";
1458 if (op_prio (op0) < op_prio (node))
1459 pp_left_paren (buffer);
1460 dump_generic_node (buffer, op0, spc, flags, false);
1461 if (op_prio (op0) < op_prio (node))
1462 pp_right_paren (buffer);
1463 pp_string (buffer, str);
1464 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1465 op0 = component_ref_field_offset (node);
1466 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1468 pp_string (buffer, "{off: ");
1469 dump_generic_node (buffer, op0, spc, flags, false);
1470 pp_right_brace (buffer);
1472 break;
1474 case BIT_FIELD_REF:
1475 pp_string (buffer, "BIT_FIELD_REF <");
1476 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1477 pp_string (buffer, ", ");
1478 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1479 pp_string (buffer, ", ");
1480 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1481 pp_greater (buffer);
1482 break;
1484 case ARRAY_REF:
1485 case ARRAY_RANGE_REF:
1486 op0 = TREE_OPERAND (node, 0);
1487 if (op_prio (op0) < op_prio (node))
1488 pp_left_paren (buffer);
1489 dump_generic_node (buffer, op0, spc, flags, false);
1490 if (op_prio (op0) < op_prio (node))
1491 pp_right_paren (buffer);
1492 pp_left_bracket (buffer);
1493 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1494 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1495 pp_string (buffer, " ...");
1496 pp_right_bracket (buffer);
1498 op0 = array_ref_low_bound (node);
1499 op1 = array_ref_element_size (node);
1501 if (!integer_zerop (op0)
1502 || TREE_OPERAND (node, 2)
1503 || TREE_OPERAND (node, 3))
1505 pp_string (buffer, "{lb: ");
1506 dump_generic_node (buffer, op0, spc, flags, false);
1507 pp_string (buffer, " sz: ");
1508 dump_generic_node (buffer, op1, spc, flags, false);
1509 pp_right_brace (buffer);
1511 break;
1513 case CONSTRUCTOR:
1515 unsigned HOST_WIDE_INT ix;
1516 tree field, val;
1517 bool is_struct_init = false;
1518 bool is_array_init = false;
1519 widest_int curidx;
1520 pp_left_brace (buffer);
1521 if (TREE_CLOBBER_P (node))
1522 pp_string (buffer, "CLOBBER");
1523 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1524 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1525 is_struct_init = true;
1526 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1527 && TYPE_DOMAIN (TREE_TYPE (node))
1528 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1529 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1530 == INTEGER_CST)
1532 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1533 is_array_init = true;
1534 curidx = wi::to_widest (minv);
1536 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1538 if (field)
1540 if (is_struct_init)
1542 pp_dot (buffer);
1543 dump_generic_node (buffer, field, spc, flags, false);
1544 pp_equal (buffer);
1546 else if (is_array_init
1547 && (TREE_CODE (field) != INTEGER_CST
1548 || curidx != wi::to_widest (field)))
1550 pp_left_bracket (buffer);
1551 if (TREE_CODE (field) == RANGE_EXPR)
1553 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1554 flags, false);
1555 pp_string (buffer, " ... ");
1556 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1557 flags, false);
1558 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1559 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1561 else
1562 dump_generic_node (buffer, field, spc, flags, false);
1563 if (TREE_CODE (field) == INTEGER_CST)
1564 curidx = wi::to_widest (field);
1565 pp_string (buffer, "]=");
1568 if (is_array_init)
1569 curidx += 1;
1570 if (val && TREE_CODE (val) == ADDR_EXPR)
1571 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1572 val = TREE_OPERAND (val, 0);
1573 if (val && TREE_CODE (val) == FUNCTION_DECL)
1574 dump_decl_name (buffer, val, flags);
1575 else
1576 dump_generic_node (buffer, val, spc, flags, false);
1577 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1579 pp_comma (buffer);
1580 pp_space (buffer);
1583 pp_right_brace (buffer);
1585 break;
1587 case COMPOUND_EXPR:
1589 tree *tp;
1590 if (flags & TDF_SLIM)
1592 pp_string (buffer, "<COMPOUND_EXPR>");
1593 break;
1596 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1597 spc, flags, !(flags & TDF_SLIM));
1598 if (flags & TDF_SLIM)
1599 newline_and_indent (buffer, spc);
1600 else
1602 pp_comma (buffer);
1603 pp_space (buffer);
1606 for (tp = &TREE_OPERAND (node, 1);
1607 TREE_CODE (*tp) == COMPOUND_EXPR;
1608 tp = &TREE_OPERAND (*tp, 1))
1610 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1611 spc, flags, !(flags & TDF_SLIM));
1612 if (flags & TDF_SLIM)
1613 newline_and_indent (buffer, spc);
1614 else
1616 pp_comma (buffer);
1617 pp_space (buffer);
1621 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1623 break;
1625 case STATEMENT_LIST:
1627 tree_stmt_iterator si;
1628 bool first = true;
1630 if (flags & TDF_SLIM)
1632 pp_string (buffer, "<STATEMENT_LIST>");
1633 break;
1636 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1638 if (!first)
1639 newline_and_indent (buffer, spc);
1640 else
1641 first = false;
1642 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1645 break;
1647 case MODIFY_EXPR:
1648 case INIT_EXPR:
1649 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1650 false);
1651 pp_space (buffer);
1652 pp_equal (buffer);
1653 pp_space (buffer);
1654 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1655 false);
1656 break;
1658 case TARGET_EXPR:
1659 pp_string (buffer, "TARGET_EXPR <");
1660 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1661 pp_comma (buffer);
1662 pp_space (buffer);
1663 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1664 pp_greater (buffer);
1665 break;
1667 case DECL_EXPR:
1668 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1669 is_stmt = false;
1670 break;
1672 case COND_EXPR:
1673 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1675 pp_string (buffer, "if (");
1676 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1677 pp_right_paren (buffer);
1678 /* The lowered cond_exprs should always be printed in full. */
1679 if (COND_EXPR_THEN (node)
1680 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1681 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1682 && COND_EXPR_ELSE (node)
1683 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1684 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1686 pp_space (buffer);
1687 dump_generic_node (buffer, COND_EXPR_THEN (node),
1688 0, flags, true);
1689 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1691 pp_string (buffer, " else ");
1692 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1693 0, flags, true);
1696 else if (!(flags & TDF_SLIM))
1698 /* Output COND_EXPR_THEN. */
1699 if (COND_EXPR_THEN (node))
1701 newline_and_indent (buffer, spc+2);
1702 pp_left_brace (buffer);
1703 newline_and_indent (buffer, spc+4);
1704 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1705 flags, true);
1706 newline_and_indent (buffer, spc+2);
1707 pp_right_brace (buffer);
1710 /* Output COND_EXPR_ELSE. */
1711 if (COND_EXPR_ELSE (node)
1712 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1714 newline_and_indent (buffer, spc);
1715 pp_string (buffer, "else");
1716 newline_and_indent (buffer, spc+2);
1717 pp_left_brace (buffer);
1718 newline_and_indent (buffer, spc+4);
1719 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1720 flags, true);
1721 newline_and_indent (buffer, spc+2);
1722 pp_right_brace (buffer);
1725 is_expr = false;
1727 else
1729 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1730 pp_space (buffer);
1731 pp_question (buffer);
1732 pp_space (buffer);
1733 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1734 pp_space (buffer);
1735 pp_colon (buffer);
1736 pp_space (buffer);
1737 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1739 break;
1741 case BIND_EXPR:
1742 pp_left_brace (buffer);
1743 if (!(flags & TDF_SLIM))
1745 if (BIND_EXPR_VARS (node))
1747 pp_newline (buffer);
1749 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1751 print_declaration (buffer, op0, spc+2, flags);
1752 pp_newline (buffer);
1756 newline_and_indent (buffer, spc+2);
1757 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1758 newline_and_indent (buffer, spc);
1759 pp_right_brace (buffer);
1761 is_expr = false;
1762 break;
1764 case CALL_EXPR:
1765 if (CALL_EXPR_FN (node) != NULL_TREE)
1766 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1767 else
1768 pp_string (buffer, internal_fn_name (CALL_EXPR_IFN (node)));
1770 /* Print parameters. */
1771 pp_space (buffer);
1772 pp_left_paren (buffer);
1774 tree arg;
1775 call_expr_arg_iterator iter;
1776 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1778 dump_generic_node (buffer, arg, spc, flags, false);
1779 if (more_call_expr_args_p (&iter))
1781 pp_comma (buffer);
1782 pp_space (buffer);
1786 if (CALL_EXPR_VA_ARG_PACK (node))
1788 if (call_expr_nargs (node) > 0)
1790 pp_comma (buffer);
1791 pp_space (buffer);
1793 pp_string (buffer, "__builtin_va_arg_pack ()");
1795 pp_right_paren (buffer);
1797 op1 = CALL_EXPR_STATIC_CHAIN (node);
1798 if (op1)
1800 pp_string (buffer, " [static-chain: ");
1801 dump_generic_node (buffer, op1, spc, flags, false);
1802 pp_right_bracket (buffer);
1805 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1806 pp_string (buffer, " [return slot optimization]");
1807 if (CALL_EXPR_TAILCALL (node))
1808 pp_string (buffer, " [tail call]");
1809 break;
1811 case WITH_CLEANUP_EXPR:
1812 NIY;
1813 break;
1815 case CLEANUP_POINT_EXPR:
1816 pp_string (buffer, "<<cleanup_point ");
1817 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1818 pp_string (buffer, ">>");
1819 break;
1821 case PLACEHOLDER_EXPR:
1822 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1823 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1824 pp_greater (buffer);
1825 break;
1827 /* Binary arithmetic and logic expressions. */
1828 case WIDEN_SUM_EXPR:
1829 case WIDEN_MULT_EXPR:
1830 case MULT_EXPR:
1831 case MULT_HIGHPART_EXPR:
1832 case PLUS_EXPR:
1833 case POINTER_PLUS_EXPR:
1834 case MINUS_EXPR:
1835 case TRUNC_DIV_EXPR:
1836 case CEIL_DIV_EXPR:
1837 case FLOOR_DIV_EXPR:
1838 case ROUND_DIV_EXPR:
1839 case TRUNC_MOD_EXPR:
1840 case CEIL_MOD_EXPR:
1841 case FLOOR_MOD_EXPR:
1842 case ROUND_MOD_EXPR:
1843 case RDIV_EXPR:
1844 case EXACT_DIV_EXPR:
1845 case LSHIFT_EXPR:
1846 case RSHIFT_EXPR:
1847 case LROTATE_EXPR:
1848 case RROTATE_EXPR:
1849 case VEC_LSHIFT_EXPR:
1850 case VEC_RSHIFT_EXPR:
1851 case WIDEN_LSHIFT_EXPR:
1852 case BIT_IOR_EXPR:
1853 case BIT_XOR_EXPR:
1854 case BIT_AND_EXPR:
1855 case TRUTH_ANDIF_EXPR:
1856 case TRUTH_ORIF_EXPR:
1857 case TRUTH_AND_EXPR:
1858 case TRUTH_OR_EXPR:
1859 case TRUTH_XOR_EXPR:
1860 case LT_EXPR:
1861 case LE_EXPR:
1862 case GT_EXPR:
1863 case GE_EXPR:
1864 case EQ_EXPR:
1865 case NE_EXPR:
1866 case UNLT_EXPR:
1867 case UNLE_EXPR:
1868 case UNGT_EXPR:
1869 case UNGE_EXPR:
1870 case UNEQ_EXPR:
1871 case LTGT_EXPR:
1872 case ORDERED_EXPR:
1873 case UNORDERED_EXPR:
1875 const char *op = op_symbol (node);
1876 op0 = TREE_OPERAND (node, 0);
1877 op1 = TREE_OPERAND (node, 1);
1879 /* When the operands are expressions with less priority,
1880 keep semantics of the tree representation. */
1881 if (op_prio (op0) <= op_prio (node))
1883 pp_left_paren (buffer);
1884 dump_generic_node (buffer, op0, spc, flags, false);
1885 pp_right_paren (buffer);
1887 else
1888 dump_generic_node (buffer, op0, spc, flags, false);
1890 pp_space (buffer);
1891 pp_string (buffer, op);
1892 pp_space (buffer);
1894 /* When the operands are expressions with less priority,
1895 keep semantics of the tree representation. */
1896 if (op_prio (op1) <= op_prio (node))
1898 pp_left_paren (buffer);
1899 dump_generic_node (buffer, op1, spc, flags, false);
1900 pp_right_paren (buffer);
1902 else
1903 dump_generic_node (buffer, op1, spc, flags, false);
1905 break;
1907 /* Unary arithmetic and logic expressions. */
1908 case NEGATE_EXPR:
1909 case BIT_NOT_EXPR:
1910 case TRUTH_NOT_EXPR:
1911 case ADDR_EXPR:
1912 case PREDECREMENT_EXPR:
1913 case PREINCREMENT_EXPR:
1914 case INDIRECT_REF:
1915 if (TREE_CODE (node) == ADDR_EXPR
1916 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1917 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1918 ; /* Do not output '&' for strings and function pointers. */
1919 else
1920 pp_string (buffer, op_symbol (node));
1922 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1924 pp_left_paren (buffer);
1925 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1926 pp_right_paren (buffer);
1928 else
1929 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1930 break;
1932 case POSTDECREMENT_EXPR:
1933 case POSTINCREMENT_EXPR:
1934 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1936 pp_left_paren (buffer);
1937 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1938 pp_right_paren (buffer);
1940 else
1941 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1942 pp_string (buffer, op_symbol (node));
1943 break;
1945 case MIN_EXPR:
1946 pp_string (buffer, "MIN_EXPR <");
1947 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1948 pp_string (buffer, ", ");
1949 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1950 pp_greater (buffer);
1951 break;
1953 case MAX_EXPR:
1954 pp_string (buffer, "MAX_EXPR <");
1955 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1956 pp_string (buffer, ", ");
1957 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1958 pp_greater (buffer);
1959 break;
1961 case ABS_EXPR:
1962 pp_string (buffer, "ABS_EXPR <");
1963 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1964 pp_greater (buffer);
1965 break;
1967 case RANGE_EXPR:
1968 NIY;
1969 break;
1971 case ADDR_SPACE_CONVERT_EXPR:
1972 case FIXED_CONVERT_EXPR:
1973 case FIX_TRUNC_EXPR:
1974 case FLOAT_EXPR:
1975 CASE_CONVERT:
1976 type = TREE_TYPE (node);
1977 op0 = TREE_OPERAND (node, 0);
1978 if (type != TREE_TYPE (op0))
1980 pp_left_paren (buffer);
1981 dump_generic_node (buffer, type, spc, flags, false);
1982 pp_string (buffer, ") ");
1984 if (op_prio (op0) < op_prio (node))
1985 pp_left_paren (buffer);
1986 dump_generic_node (buffer, op0, spc, flags, false);
1987 if (op_prio (op0) < op_prio (node))
1988 pp_right_paren (buffer);
1989 break;
1991 case VIEW_CONVERT_EXPR:
1992 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1993 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1994 pp_string (buffer, ">(");
1995 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1996 pp_right_paren (buffer);
1997 break;
1999 case PAREN_EXPR:
2000 pp_string (buffer, "((");
2001 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2002 pp_string (buffer, "))");
2003 break;
2005 case NON_LVALUE_EXPR:
2006 pp_string (buffer, "NON_LVALUE_EXPR <");
2007 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2008 pp_greater (buffer);
2009 break;
2011 case SAVE_EXPR:
2012 pp_string (buffer, "SAVE_EXPR <");
2013 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2014 pp_greater (buffer);
2015 break;
2017 case COMPLEX_EXPR:
2018 pp_string (buffer, "COMPLEX_EXPR <");
2019 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2020 pp_string (buffer, ", ");
2021 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2022 pp_greater (buffer);
2023 break;
2025 case CONJ_EXPR:
2026 pp_string (buffer, "CONJ_EXPR <");
2027 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2028 pp_greater (buffer);
2029 break;
2031 case REALPART_EXPR:
2032 pp_string (buffer, "REALPART_EXPR <");
2033 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2034 pp_greater (buffer);
2035 break;
2037 case IMAGPART_EXPR:
2038 pp_string (buffer, "IMAGPART_EXPR <");
2039 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2040 pp_greater (buffer);
2041 break;
2043 case VA_ARG_EXPR:
2044 pp_string (buffer, "VA_ARG_EXPR <");
2045 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2046 pp_greater (buffer);
2047 break;
2049 case TRY_FINALLY_EXPR:
2050 case TRY_CATCH_EXPR:
2051 pp_string (buffer, "try");
2052 newline_and_indent (buffer, spc+2);
2053 pp_left_brace (buffer);
2054 newline_and_indent (buffer, spc+4);
2055 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2056 newline_and_indent (buffer, spc+2);
2057 pp_right_brace (buffer);
2058 newline_and_indent (buffer, spc);
2059 pp_string (buffer,
2060 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2061 newline_and_indent (buffer, spc+2);
2062 pp_left_brace (buffer);
2063 newline_and_indent (buffer, spc+4);
2064 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2065 newline_and_indent (buffer, spc+2);
2066 pp_right_brace (buffer);
2067 is_expr = false;
2068 break;
2070 case CATCH_EXPR:
2071 pp_string (buffer, "catch (");
2072 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2073 pp_right_paren (buffer);
2074 newline_and_indent (buffer, spc+2);
2075 pp_left_brace (buffer);
2076 newline_and_indent (buffer, spc+4);
2077 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2078 newline_and_indent (buffer, spc+2);
2079 pp_right_brace (buffer);
2080 is_expr = false;
2081 break;
2083 case EH_FILTER_EXPR:
2084 pp_string (buffer, "<<<eh_filter (");
2085 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2086 pp_string (buffer, ")>>>");
2087 newline_and_indent (buffer, spc+2);
2088 pp_left_brace (buffer);
2089 newline_and_indent (buffer, spc+4);
2090 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2091 newline_and_indent (buffer, spc+2);
2092 pp_right_brace (buffer);
2093 is_expr = false;
2094 break;
2096 case LABEL_EXPR:
2097 op0 = TREE_OPERAND (node, 0);
2098 /* If this is for break or continue, don't bother printing it. */
2099 if (DECL_NAME (op0))
2101 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2102 if (strcmp (name, "break") == 0
2103 || strcmp (name, "continue") == 0)
2104 break;
2106 dump_generic_node (buffer, op0, spc, flags, false);
2107 pp_colon (buffer);
2108 if (DECL_NONLOCAL (op0))
2109 pp_string (buffer, " [non-local]");
2110 break;
2112 case LOOP_EXPR:
2113 pp_string (buffer, "while (1)");
2114 if (!(flags & TDF_SLIM))
2116 newline_and_indent (buffer, spc+2);
2117 pp_left_brace (buffer);
2118 newline_and_indent (buffer, spc+4);
2119 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2120 newline_and_indent (buffer, spc+2);
2121 pp_right_brace (buffer);
2123 is_expr = false;
2124 break;
2126 case PREDICT_EXPR:
2127 pp_string (buffer, "// predicted ");
2128 if (PREDICT_EXPR_OUTCOME (node))
2129 pp_string (buffer, "likely by ");
2130 else
2131 pp_string (buffer, "unlikely by ");
2132 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2133 pp_string (buffer, " predictor.");
2134 break;
2136 case ANNOTATE_EXPR:
2137 pp_string (buffer, "ANNOTATE_EXPR <");
2138 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2139 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2141 case annot_expr_ivdep_kind:
2142 pp_string (buffer, ", ivdep");
2143 break;
2144 case annot_expr_no_vector_kind:
2145 pp_string (buffer, ", no-vector");
2146 break;
2147 case annot_expr_vector_kind:
2148 pp_string (buffer, ", vector");
2149 break;
2150 default:
2151 gcc_unreachable ();
2153 pp_greater (buffer);
2154 break;
2156 case RETURN_EXPR:
2157 pp_string (buffer, "return");
2158 op0 = TREE_OPERAND (node, 0);
2159 if (op0)
2161 pp_space (buffer);
2162 if (TREE_CODE (op0) == MODIFY_EXPR)
2163 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2164 spc, flags, false);
2165 else
2166 dump_generic_node (buffer, op0, spc, flags, false);
2168 break;
2170 case EXIT_EXPR:
2171 pp_string (buffer, "if (");
2172 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2173 pp_string (buffer, ") break");
2174 break;
2176 case SWITCH_EXPR:
2177 pp_string (buffer, "switch (");
2178 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2179 pp_right_paren (buffer);
2180 if (!(flags & TDF_SLIM))
2182 newline_and_indent (buffer, spc+2);
2183 pp_left_brace (buffer);
2184 if (SWITCH_BODY (node))
2186 newline_and_indent (buffer, spc+4);
2187 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2188 true);
2190 else
2192 tree vec = SWITCH_LABELS (node);
2193 size_t i, n = TREE_VEC_LENGTH (vec);
2194 for (i = 0; i < n; ++i)
2196 tree elt = TREE_VEC_ELT (vec, i);
2197 newline_and_indent (buffer, spc+4);
2198 if (elt)
2200 dump_generic_node (buffer, elt, spc+4, flags, false);
2201 pp_string (buffer, " goto ");
2202 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2203 flags, true);
2204 pp_semicolon (buffer);
2206 else
2207 pp_string (buffer, "case ???: goto ???;");
2210 newline_and_indent (buffer, spc+2);
2211 pp_right_brace (buffer);
2213 is_expr = false;
2214 break;
2216 case GOTO_EXPR:
2217 op0 = GOTO_DESTINATION (node);
2218 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2220 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2221 if (strcmp (name, "break") == 0
2222 || strcmp (name, "continue") == 0)
2224 pp_string (buffer, name);
2225 break;
2228 pp_string (buffer, "goto ");
2229 dump_generic_node (buffer, op0, spc, flags, false);
2230 break;
2232 case ASM_EXPR:
2233 pp_string (buffer, "__asm__");
2234 if (ASM_VOLATILE_P (node))
2235 pp_string (buffer, " __volatile__");
2236 pp_left_paren (buffer);
2237 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2238 pp_colon (buffer);
2239 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2240 pp_colon (buffer);
2241 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2242 if (ASM_CLOBBERS (node))
2244 pp_colon (buffer);
2245 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2247 pp_right_paren (buffer);
2248 break;
2250 case CASE_LABEL_EXPR:
2251 if (CASE_LOW (node) && CASE_HIGH (node))
2253 pp_string (buffer, "case ");
2254 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2255 pp_string (buffer, " ... ");
2256 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2258 else if (CASE_LOW (node))
2260 pp_string (buffer, "case ");
2261 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2263 else
2264 pp_string (buffer, "default");
2265 pp_colon (buffer);
2266 break;
2268 case OBJ_TYPE_REF:
2269 pp_string (buffer, "OBJ_TYPE_REF(");
2270 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2271 pp_semicolon (buffer);
2272 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2274 pp_string (buffer, "(");
2275 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2276 pp_string (buffer, ")");
2278 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2279 pp_arrow (buffer);
2280 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2281 pp_right_paren (buffer);
2282 break;
2284 case SSA_NAME:
2285 if (SSA_NAME_IDENTIFIER (node))
2286 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2287 spc, flags, false);
2288 pp_underscore (buffer);
2289 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2290 if (SSA_NAME_IS_DEFAULT_DEF (node))
2291 pp_string (buffer, "(D)");
2292 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2293 pp_string (buffer, "(ab)");
2294 break;
2296 case WITH_SIZE_EXPR:
2297 pp_string (buffer, "WITH_SIZE_EXPR <");
2298 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2299 pp_string (buffer, ", ");
2300 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2301 pp_greater (buffer);
2302 break;
2304 case ASSERT_EXPR:
2305 pp_string (buffer, "ASSERT_EXPR <");
2306 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2307 pp_string (buffer, ", ");
2308 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2309 pp_greater (buffer);
2310 break;
2312 case SCEV_KNOWN:
2313 pp_string (buffer, "scev_known");
2314 break;
2316 case SCEV_NOT_KNOWN:
2317 pp_string (buffer, "scev_not_known");
2318 break;
2320 case POLYNOMIAL_CHREC:
2321 pp_left_brace (buffer);
2322 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2323 pp_string (buffer, ", +, ");
2324 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2325 pp_string (buffer, "}_");
2326 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2327 is_stmt = false;
2328 break;
2330 case REALIGN_LOAD_EXPR:
2331 pp_string (buffer, "REALIGN_LOAD <");
2332 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2333 pp_string (buffer, ", ");
2334 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2335 pp_string (buffer, ", ");
2336 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2337 pp_greater (buffer);
2338 break;
2340 case VEC_COND_EXPR:
2341 pp_string (buffer, " VEC_COND_EXPR < ");
2342 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2343 pp_string (buffer, " , ");
2344 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2345 pp_string (buffer, " , ");
2346 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2347 pp_string (buffer, " > ");
2348 break;
2350 case VEC_PERM_EXPR:
2351 pp_string (buffer, " VEC_PERM_EXPR < ");
2352 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2353 pp_string (buffer, " , ");
2354 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2355 pp_string (buffer, " , ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2357 pp_string (buffer, " > ");
2358 break;
2360 case DOT_PROD_EXPR:
2361 pp_string (buffer, " DOT_PROD_EXPR < ");
2362 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2363 pp_string (buffer, ", ");
2364 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2365 pp_string (buffer, ", ");
2366 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2367 pp_string (buffer, " > ");
2368 break;
2370 case WIDEN_MULT_PLUS_EXPR:
2371 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2372 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2373 pp_string (buffer, ", ");
2374 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2375 pp_string (buffer, ", ");
2376 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2377 pp_string (buffer, " > ");
2378 break;
2380 case WIDEN_MULT_MINUS_EXPR:
2381 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2382 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2383 pp_string (buffer, ", ");
2384 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2385 pp_string (buffer, ", ");
2386 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2387 pp_string (buffer, " > ");
2388 break;
2390 case FMA_EXPR:
2391 pp_string (buffer, " FMA_EXPR < ");
2392 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2393 pp_string (buffer, ", ");
2394 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2395 pp_string (buffer, ", ");
2396 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2397 pp_string (buffer, " > ");
2398 break;
2400 case OMP_PARALLEL:
2401 pp_string (buffer, "#pragma omp parallel");
2402 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2404 dump_omp_body:
2405 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2407 newline_and_indent (buffer, spc + 2);
2408 pp_left_brace (buffer);
2409 newline_and_indent (buffer, spc + 4);
2410 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2411 newline_and_indent (buffer, spc + 2);
2412 pp_right_brace (buffer);
2414 is_expr = false;
2415 break;
2417 case OMP_TASK:
2418 pp_string (buffer, "#pragma omp task");
2419 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2420 goto dump_omp_body;
2422 case OMP_FOR:
2423 pp_string (buffer, "#pragma omp for");
2424 goto dump_omp_loop;
2426 case OMP_SIMD:
2427 pp_string (buffer, "#pragma omp simd");
2428 goto dump_omp_loop;
2430 case CILK_SIMD:
2431 pp_string (buffer, "#pragma simd");
2432 goto dump_omp_loop;
2434 case CILK_FOR:
2435 /* This label points one line after dumping the clauses.
2436 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2437 parameters are printed out. */
2438 goto dump_omp_loop_cilk_for;
2440 case OMP_DISTRIBUTE:
2441 pp_string (buffer, "#pragma omp distribute");
2442 goto dump_omp_loop;
2444 case OMP_TEAMS:
2445 pp_string (buffer, "#pragma omp teams");
2446 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2447 goto dump_omp_body;
2449 case OMP_TARGET_DATA:
2450 pp_string (buffer, "#pragma omp target data");
2451 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2452 goto dump_omp_body;
2454 case OMP_TARGET:
2455 pp_string (buffer, "#pragma omp target");
2456 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2457 goto dump_omp_body;
2459 case OMP_TARGET_UPDATE:
2460 pp_string (buffer, "#pragma omp target update");
2461 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2462 is_expr = false;
2463 break;
2465 dump_omp_loop:
2466 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2468 dump_omp_loop_cilk_for:
2469 if (!(flags & TDF_SLIM))
2471 int i;
2473 if (OMP_FOR_PRE_BODY (node))
2475 if (TREE_CODE (node) == CILK_FOR)
2476 pp_string (buffer, " ");
2477 else
2478 newline_and_indent (buffer, spc + 2);
2479 pp_left_brace (buffer);
2480 spc += 4;
2481 newline_and_indent (buffer, spc);
2482 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2483 spc, flags, false);
2485 if (OMP_FOR_INIT (node))
2487 spc -= 2;
2488 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2490 spc += 2;
2491 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2492 newline_and_indent (buffer, spc);
2493 if (TREE_CODE (node) == CILK_FOR)
2494 pp_string (buffer, "_Cilk_for (");
2495 else
2496 pp_string (buffer, "for (");
2497 dump_generic_node (buffer,
2498 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2499 spc, flags, false);
2500 pp_string (buffer, "; ");
2501 dump_generic_node (buffer,
2502 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2503 spc, flags, false);
2504 pp_string (buffer, "; ");
2505 dump_generic_node (buffer,
2506 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2507 spc, flags, false);
2508 pp_right_paren (buffer);
2510 if (TREE_CODE (node) == CILK_FOR)
2511 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2513 if (OMP_FOR_BODY (node))
2515 newline_and_indent (buffer, spc + 2);
2516 pp_left_brace (buffer);
2517 newline_and_indent (buffer, spc + 4);
2518 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2519 false);
2520 newline_and_indent (buffer, spc + 2);
2521 pp_right_brace (buffer);
2523 if (OMP_FOR_INIT (node))
2524 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2525 if (OMP_FOR_PRE_BODY (node))
2527 spc -= 4;
2528 newline_and_indent (buffer, spc + 2);
2529 pp_right_brace (buffer);
2532 is_expr = false;
2533 break;
2535 case OMP_SECTIONS:
2536 pp_string (buffer, "#pragma omp sections");
2537 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2538 goto dump_omp_body;
2540 case OMP_SECTION:
2541 pp_string (buffer, "#pragma omp section");
2542 goto dump_omp_body;
2544 case OMP_MASTER:
2545 pp_string (buffer, "#pragma omp master");
2546 goto dump_omp_body;
2548 case OMP_TASKGROUP:
2549 pp_string (buffer, "#pragma omp taskgroup");
2550 goto dump_omp_body;
2552 case OMP_ORDERED:
2553 pp_string (buffer, "#pragma omp ordered");
2554 goto dump_omp_body;
2556 case OMP_CRITICAL:
2557 pp_string (buffer, "#pragma omp critical");
2558 if (OMP_CRITICAL_NAME (node))
2560 pp_space (buffer);
2561 pp_left_paren (buffer);
2562 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2563 flags, false);
2564 pp_right_paren (buffer);
2566 goto dump_omp_body;
2568 case OMP_ATOMIC:
2569 pp_string (buffer, "#pragma omp atomic");
2570 if (OMP_ATOMIC_SEQ_CST (node))
2571 pp_string (buffer, " seq_cst");
2572 newline_and_indent (buffer, spc + 2);
2573 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2574 pp_space (buffer);
2575 pp_equal (buffer);
2576 pp_space (buffer);
2577 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2578 break;
2580 case OMP_ATOMIC_READ:
2581 pp_string (buffer, "#pragma omp atomic read");
2582 if (OMP_ATOMIC_SEQ_CST (node))
2583 pp_string (buffer, " seq_cst");
2584 newline_and_indent (buffer, spc + 2);
2585 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2586 pp_space (buffer);
2587 break;
2589 case OMP_ATOMIC_CAPTURE_OLD:
2590 case OMP_ATOMIC_CAPTURE_NEW:
2591 pp_string (buffer, "#pragma omp atomic capture");
2592 if (OMP_ATOMIC_SEQ_CST (node))
2593 pp_string (buffer, " seq_cst");
2594 newline_and_indent (buffer, spc + 2);
2595 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2596 pp_space (buffer);
2597 pp_equal (buffer);
2598 pp_space (buffer);
2599 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2600 break;
2602 case OMP_SINGLE:
2603 pp_string (buffer, "#pragma omp single");
2604 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2605 goto dump_omp_body;
2607 case OMP_CLAUSE:
2608 dump_omp_clause (buffer, node, spc, flags);
2609 is_expr = false;
2610 break;
2612 case TRANSACTION_EXPR:
2613 if (TRANSACTION_EXPR_OUTER (node))
2614 pp_string (buffer, "__transaction_atomic [[outer]]");
2615 else if (TRANSACTION_EXPR_RELAXED (node))
2616 pp_string (buffer, "__transaction_relaxed");
2617 else
2618 pp_string (buffer, "__transaction_atomic");
2619 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2621 newline_and_indent (buffer, spc);
2622 pp_left_brace (buffer);
2623 newline_and_indent (buffer, spc + 2);
2624 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2625 spc + 2, flags, false);
2626 newline_and_indent (buffer, spc);
2627 pp_right_brace (buffer);
2629 is_expr = false;
2630 break;
2632 case REDUC_MAX_EXPR:
2633 pp_string (buffer, " REDUC_MAX_EXPR < ");
2634 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2635 pp_string (buffer, " > ");
2636 break;
2638 case REDUC_MIN_EXPR:
2639 pp_string (buffer, " REDUC_MIN_EXPR < ");
2640 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2641 pp_string (buffer, " > ");
2642 break;
2644 case REDUC_PLUS_EXPR:
2645 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2646 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2647 pp_string (buffer, " > ");
2648 break;
2650 case VEC_WIDEN_MULT_HI_EXPR:
2651 case VEC_WIDEN_MULT_LO_EXPR:
2652 case VEC_WIDEN_MULT_EVEN_EXPR:
2653 case VEC_WIDEN_MULT_ODD_EXPR:
2654 case VEC_WIDEN_LSHIFT_HI_EXPR:
2655 case VEC_WIDEN_LSHIFT_LO_EXPR:
2656 pp_space (buffer);
2657 for (str = get_tree_code_name (code); *str; str++)
2658 pp_character (buffer, TOUPPER (*str));
2659 pp_string (buffer, " < ");
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_UNPACK_HI_EXPR:
2667 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2668 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2669 pp_string (buffer, " > ");
2670 break;
2672 case VEC_UNPACK_LO_EXPR:
2673 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2674 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2675 pp_string (buffer, " > ");
2676 break;
2678 case VEC_UNPACK_FLOAT_HI_EXPR:
2679 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2680 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2681 pp_string (buffer, " > ");
2682 break;
2684 case VEC_UNPACK_FLOAT_LO_EXPR:
2685 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2686 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2687 pp_string (buffer, " > ");
2688 break;
2690 case VEC_PACK_TRUNC_EXPR:
2691 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2692 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2693 pp_string (buffer, ", ");
2694 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2695 pp_string (buffer, " > ");
2696 break;
2698 case VEC_PACK_SAT_EXPR:
2699 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2700 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2701 pp_string (buffer, ", ");
2702 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2703 pp_string (buffer, " > ");
2704 break;
2706 case VEC_PACK_FIX_TRUNC_EXPR:
2707 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2708 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2709 pp_string (buffer, ", ");
2710 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2711 pp_string (buffer, " > ");
2712 break;
2714 case BLOCK:
2715 dump_block_node (buffer, node, spc, flags);
2716 break;
2718 case CILK_SPAWN_STMT:
2719 pp_string (buffer, "_Cilk_spawn ");
2720 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2721 break;
2723 case CILK_SYNC_STMT:
2724 pp_string (buffer, "_Cilk_sync");
2725 break;
2727 default:
2728 NIY;
2731 if (is_stmt && is_expr)
2732 pp_semicolon (buffer);
2734 return spc;
2737 /* Print the declaration of a variable. */
2739 void
2740 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2742 INDENT (spc);
2744 if (TREE_CODE(t) == NAMELIST_DECL)
2746 pp_string(buffer, "namelist ");
2747 dump_decl_name (buffer, t, flags);
2748 pp_semicolon (buffer);
2749 return;
2752 if (TREE_CODE (t) == TYPE_DECL)
2753 pp_string (buffer, "typedef ");
2755 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2756 pp_string (buffer, "register ");
2758 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2759 pp_string (buffer, "extern ");
2760 else if (TREE_STATIC (t))
2761 pp_string (buffer, "static ");
2763 /* Print the type and name. */
2764 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2766 tree tmp;
2768 /* Print array's type. */
2769 tmp = TREE_TYPE (t);
2770 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2771 tmp = TREE_TYPE (tmp);
2772 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2774 /* Print variable's name. */
2775 pp_space (buffer);
2776 dump_generic_node (buffer, t, spc, flags, false);
2778 /* Print the dimensions. */
2779 tmp = TREE_TYPE (t);
2780 while (TREE_CODE (tmp) == ARRAY_TYPE)
2782 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2783 tmp = TREE_TYPE (tmp);
2786 else if (TREE_CODE (t) == FUNCTION_DECL)
2788 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2789 pp_space (buffer);
2790 dump_decl_name (buffer, t, flags);
2791 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2793 else
2795 /* Print type declaration. */
2796 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2798 /* Print variable's name. */
2799 pp_space (buffer);
2800 dump_generic_node (buffer, t, spc, flags, false);
2803 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2805 pp_string (buffer, " __asm__ ");
2806 pp_left_paren (buffer);
2807 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2808 pp_right_paren (buffer);
2811 /* The initial value of a function serves to determine whether the function
2812 is declared or defined. So the following does not apply to function
2813 nodes. */
2814 if (TREE_CODE (t) != FUNCTION_DECL)
2816 /* Print the initial value. */
2817 if (DECL_INITIAL (t))
2819 pp_space (buffer);
2820 pp_equal (buffer);
2821 pp_space (buffer);
2822 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2826 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2828 pp_string (buffer, " [value-expr: ");
2829 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2830 pp_right_bracket (buffer);
2833 pp_semicolon (buffer);
2837 /* Prints a structure: name, fields, and methods.
2838 FIXME: Still incomplete. */
2840 static void
2841 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2843 /* Print the name of the structure. */
2844 if (TYPE_NAME (node))
2846 INDENT (spc);
2847 if (TREE_CODE (node) == RECORD_TYPE)
2848 pp_string (buffer, "struct ");
2849 else if ((TREE_CODE (node) == UNION_TYPE
2850 || TREE_CODE (node) == QUAL_UNION_TYPE))
2851 pp_string (buffer, "union ");
2853 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2856 /* Print the contents of the structure. */
2857 pp_newline (buffer);
2858 INDENT (spc);
2859 pp_left_brace (buffer);
2860 pp_newline (buffer);
2862 /* Print the fields of the structure. */
2864 tree tmp;
2865 tmp = TYPE_FIELDS (node);
2866 while (tmp)
2868 /* Avoid to print recursively the structure. */
2869 /* FIXME : Not implemented correctly...,
2870 what about the case when we have a cycle in the contain graph? ...
2871 Maybe this could be solved by looking at the scope in which the
2872 structure was declared. */
2873 if (TREE_TYPE (tmp) != node
2874 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2875 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2877 print_declaration (buffer, tmp, spc+2, flags);
2878 pp_newline (buffer);
2880 tmp = DECL_CHAIN (tmp);
2883 INDENT (spc);
2884 pp_right_brace (buffer);
2887 /* Return the priority of the operator CODE.
2889 From lowest to highest precedence with either left-to-right (L-R)
2890 or right-to-left (R-L) associativity]:
2892 1 [L-R] ,
2893 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2894 3 [R-L] ?:
2895 4 [L-R] ||
2896 5 [L-R] &&
2897 6 [L-R] |
2898 7 [L-R] ^
2899 8 [L-R] &
2900 9 [L-R] == !=
2901 10 [L-R] < <= > >=
2902 11 [L-R] << >>
2903 12 [L-R] + -
2904 13 [L-R] * / %
2905 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2906 15 [L-R] fn() [] -> .
2908 unary +, - and * have higher precedence than the corresponding binary
2909 operators. */
2912 op_code_prio (enum tree_code code)
2914 switch (code)
2916 case TREE_LIST:
2917 case COMPOUND_EXPR:
2918 case BIND_EXPR:
2919 return 1;
2921 case MODIFY_EXPR:
2922 case INIT_EXPR:
2923 return 2;
2925 case COND_EXPR:
2926 return 3;
2928 case TRUTH_OR_EXPR:
2929 case TRUTH_ORIF_EXPR:
2930 return 4;
2932 case TRUTH_AND_EXPR:
2933 case TRUTH_ANDIF_EXPR:
2934 return 5;
2936 case BIT_IOR_EXPR:
2937 return 6;
2939 case BIT_XOR_EXPR:
2940 case TRUTH_XOR_EXPR:
2941 return 7;
2943 case BIT_AND_EXPR:
2944 return 8;
2946 case EQ_EXPR:
2947 case NE_EXPR:
2948 return 9;
2950 case UNLT_EXPR:
2951 case UNLE_EXPR:
2952 case UNGT_EXPR:
2953 case UNGE_EXPR:
2954 case UNEQ_EXPR:
2955 case LTGT_EXPR:
2956 case ORDERED_EXPR:
2957 case UNORDERED_EXPR:
2958 case LT_EXPR:
2959 case LE_EXPR:
2960 case GT_EXPR:
2961 case GE_EXPR:
2962 return 10;
2964 case LSHIFT_EXPR:
2965 case RSHIFT_EXPR:
2966 case LROTATE_EXPR:
2967 case RROTATE_EXPR:
2968 case VEC_WIDEN_LSHIFT_HI_EXPR:
2969 case VEC_WIDEN_LSHIFT_LO_EXPR:
2970 case WIDEN_LSHIFT_EXPR:
2971 return 11;
2973 case WIDEN_SUM_EXPR:
2974 case PLUS_EXPR:
2975 case POINTER_PLUS_EXPR:
2976 case MINUS_EXPR:
2977 return 12;
2979 case VEC_WIDEN_MULT_HI_EXPR:
2980 case VEC_WIDEN_MULT_LO_EXPR:
2981 case WIDEN_MULT_EXPR:
2982 case DOT_PROD_EXPR:
2983 case WIDEN_MULT_PLUS_EXPR:
2984 case WIDEN_MULT_MINUS_EXPR:
2985 case MULT_EXPR:
2986 case MULT_HIGHPART_EXPR:
2987 case TRUNC_DIV_EXPR:
2988 case CEIL_DIV_EXPR:
2989 case FLOOR_DIV_EXPR:
2990 case ROUND_DIV_EXPR:
2991 case RDIV_EXPR:
2992 case EXACT_DIV_EXPR:
2993 case TRUNC_MOD_EXPR:
2994 case CEIL_MOD_EXPR:
2995 case FLOOR_MOD_EXPR:
2996 case ROUND_MOD_EXPR:
2997 case FMA_EXPR:
2998 return 13;
3000 case TRUTH_NOT_EXPR:
3001 case BIT_NOT_EXPR:
3002 case POSTINCREMENT_EXPR:
3003 case POSTDECREMENT_EXPR:
3004 case PREINCREMENT_EXPR:
3005 case PREDECREMENT_EXPR:
3006 case NEGATE_EXPR:
3007 case INDIRECT_REF:
3008 case ADDR_EXPR:
3009 case FLOAT_EXPR:
3010 CASE_CONVERT:
3011 case FIX_TRUNC_EXPR:
3012 case TARGET_EXPR:
3013 return 14;
3015 case CALL_EXPR:
3016 case ARRAY_REF:
3017 case ARRAY_RANGE_REF:
3018 case COMPONENT_REF:
3019 return 15;
3021 /* Special expressions. */
3022 case MIN_EXPR:
3023 case MAX_EXPR:
3024 case ABS_EXPR:
3025 case REALPART_EXPR:
3026 case IMAGPART_EXPR:
3027 case REDUC_MAX_EXPR:
3028 case REDUC_MIN_EXPR:
3029 case REDUC_PLUS_EXPR:
3030 case VEC_LSHIFT_EXPR:
3031 case VEC_RSHIFT_EXPR:
3032 case VEC_UNPACK_HI_EXPR:
3033 case VEC_UNPACK_LO_EXPR:
3034 case VEC_UNPACK_FLOAT_HI_EXPR:
3035 case VEC_UNPACK_FLOAT_LO_EXPR:
3036 case VEC_PACK_TRUNC_EXPR:
3037 case VEC_PACK_SAT_EXPR:
3038 return 16;
3040 default:
3041 /* Return an arbitrarily high precedence to avoid surrounding single
3042 VAR_DECLs in ()s. */
3043 return 9999;
3047 /* Return the priority of the operator OP. */
3050 op_prio (const_tree op)
3052 enum tree_code code;
3054 if (op == NULL)
3055 return 9999;
3057 code = TREE_CODE (op);
3058 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3059 return op_prio (TREE_OPERAND (op, 0));
3061 return op_code_prio (code);
3064 /* Return the symbol associated with operator CODE. */
3066 const char *
3067 op_symbol_code (enum tree_code code)
3069 switch (code)
3071 case MODIFY_EXPR:
3072 return "=";
3074 case TRUTH_OR_EXPR:
3075 case TRUTH_ORIF_EXPR:
3076 return "||";
3078 case TRUTH_AND_EXPR:
3079 case TRUTH_ANDIF_EXPR:
3080 return "&&";
3082 case BIT_IOR_EXPR:
3083 return "|";
3085 case TRUTH_XOR_EXPR:
3086 case BIT_XOR_EXPR:
3087 return "^";
3089 case ADDR_EXPR:
3090 case BIT_AND_EXPR:
3091 return "&";
3093 case ORDERED_EXPR:
3094 return "ord";
3095 case UNORDERED_EXPR:
3096 return "unord";
3098 case EQ_EXPR:
3099 return "==";
3100 case UNEQ_EXPR:
3101 return "u==";
3103 case NE_EXPR:
3104 return "!=";
3106 case LT_EXPR:
3107 return "<";
3108 case UNLT_EXPR:
3109 return "u<";
3111 case LE_EXPR:
3112 return "<=";
3113 case UNLE_EXPR:
3114 return "u<=";
3116 case GT_EXPR:
3117 return ">";
3118 case UNGT_EXPR:
3119 return "u>";
3121 case GE_EXPR:
3122 return ">=";
3123 case UNGE_EXPR:
3124 return "u>=";
3126 case LTGT_EXPR:
3127 return "<>";
3129 case LSHIFT_EXPR:
3130 return "<<";
3132 case RSHIFT_EXPR:
3133 return ">>";
3135 case LROTATE_EXPR:
3136 return "r<<";
3138 case RROTATE_EXPR:
3139 return "r>>";
3141 case VEC_LSHIFT_EXPR:
3142 return "v<<";
3144 case VEC_RSHIFT_EXPR:
3145 return "v>>";
3147 case WIDEN_LSHIFT_EXPR:
3148 return "w<<";
3150 case POINTER_PLUS_EXPR:
3151 return "+";
3153 case PLUS_EXPR:
3154 return "+";
3156 case REDUC_PLUS_EXPR:
3157 return "r+";
3159 case WIDEN_SUM_EXPR:
3160 return "w+";
3162 case WIDEN_MULT_EXPR:
3163 return "w*";
3165 case MULT_HIGHPART_EXPR:
3166 return "h*";
3168 case NEGATE_EXPR:
3169 case MINUS_EXPR:
3170 return "-";
3172 case BIT_NOT_EXPR:
3173 return "~";
3175 case TRUTH_NOT_EXPR:
3176 return "!";
3178 case MULT_EXPR:
3179 case INDIRECT_REF:
3180 return "*";
3182 case TRUNC_DIV_EXPR:
3183 case RDIV_EXPR:
3184 return "/";
3186 case CEIL_DIV_EXPR:
3187 return "/[cl]";
3189 case FLOOR_DIV_EXPR:
3190 return "/[fl]";
3192 case ROUND_DIV_EXPR:
3193 return "/[rd]";
3195 case EXACT_DIV_EXPR:
3196 return "/[ex]";
3198 case TRUNC_MOD_EXPR:
3199 return "%";
3201 case CEIL_MOD_EXPR:
3202 return "%[cl]";
3204 case FLOOR_MOD_EXPR:
3205 return "%[fl]";
3207 case ROUND_MOD_EXPR:
3208 return "%[rd]";
3210 case PREDECREMENT_EXPR:
3211 return " --";
3213 case PREINCREMENT_EXPR:
3214 return " ++";
3216 case POSTDECREMENT_EXPR:
3217 return "-- ";
3219 case POSTINCREMENT_EXPR:
3220 return "++ ";
3222 case MAX_EXPR:
3223 return "max";
3225 case MIN_EXPR:
3226 return "min";
3228 default:
3229 return "<<< ??? >>>";
3233 /* Return the symbol associated with operator OP. */
3235 static const char *
3236 op_symbol (const_tree op)
3238 return op_symbol_code (TREE_CODE (op));
3241 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3242 the gimple_call_fn of a GIMPLE_CALL. */
3244 void
3245 print_call_name (pretty_printer *buffer, tree node, int flags)
3247 tree op0 = node;
3249 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3250 op0 = TREE_OPERAND (op0, 0);
3252 again:
3253 switch (TREE_CODE (op0))
3255 case VAR_DECL:
3256 case PARM_DECL:
3257 case FUNCTION_DECL:
3258 dump_function_name (buffer, op0, flags);
3259 break;
3261 case ADDR_EXPR:
3262 case INDIRECT_REF:
3263 case NOP_EXPR:
3264 op0 = TREE_OPERAND (op0, 0);
3265 goto again;
3267 case COND_EXPR:
3268 pp_left_paren (buffer);
3269 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3270 pp_string (buffer, ") ? ");
3271 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3272 pp_string (buffer, " : ");
3273 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3274 break;
3276 case ARRAY_REF:
3277 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3278 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3279 else
3280 dump_generic_node (buffer, op0, 0, flags, false);
3281 break;
3283 case MEM_REF:
3284 if (integer_zerop (TREE_OPERAND (op0, 1)))
3286 op0 = TREE_OPERAND (op0, 0);
3287 goto again;
3289 /* Fallthru. */
3290 case COMPONENT_REF:
3291 case SSA_NAME:
3292 case OBJ_TYPE_REF:
3293 dump_generic_node (buffer, op0, 0, flags, false);
3294 break;
3296 default:
3297 NIY;
3301 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3303 static void
3304 pretty_print_string (pretty_printer *buffer, const char *str)
3306 if (str == NULL)
3307 return;
3309 while (*str)
3311 switch (str[0])
3313 case '\b':
3314 pp_string (buffer, "\\b");
3315 break;
3317 case '\f':
3318 pp_string (buffer, "\\f");
3319 break;
3321 case '\n':
3322 pp_string (buffer, "\\n");
3323 break;
3325 case '\r':
3326 pp_string (buffer, "\\r");
3327 break;
3329 case '\t':
3330 pp_string (buffer, "\\t");
3331 break;
3333 case '\v':
3334 pp_string (buffer, "\\v");
3335 break;
3337 case '\\':
3338 pp_string (buffer, "\\\\");
3339 break;
3341 case '\"':
3342 pp_string (buffer, "\\\"");
3343 break;
3345 case '\'':
3346 pp_string (buffer, "\\'");
3347 break;
3349 /* No need to handle \0; the loop terminates on \0. */
3351 case '\1':
3352 pp_string (buffer, "\\1");
3353 break;
3355 case '\2':
3356 pp_string (buffer, "\\2");
3357 break;
3359 case '\3':
3360 pp_string (buffer, "\\3");
3361 break;
3363 case '\4':
3364 pp_string (buffer, "\\4");
3365 break;
3367 case '\5':
3368 pp_string (buffer, "\\5");
3369 break;
3371 case '\6':
3372 pp_string (buffer, "\\6");
3373 break;
3375 case '\7':
3376 pp_string (buffer, "\\7");
3377 break;
3379 default:
3380 pp_character (buffer, str[0]);
3381 break;
3383 str++;
3387 static void
3388 maybe_init_pretty_print (FILE *file)
3390 if (!initialized)
3392 new (&buffer) pretty_printer ();
3393 pp_needs_newline (&buffer) = true;
3394 pp_translate_identifiers (&buffer) = false;
3395 initialized = 1;
3398 buffer.buffer->stream = file;
3401 static void
3402 newline_and_indent (pretty_printer *buffer, int spc)
3404 pp_newline (buffer);
3405 INDENT (spc);
3408 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3409 it can also be used in front ends.
3410 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3413 void
3414 percent_K_format (text_info *text)
3416 tree t = va_arg (*text->args_ptr, tree), block;
3417 gcc_assert (text->locus != NULL);
3418 *text->locus = EXPR_LOCATION (t);
3419 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3420 block = TREE_BLOCK (t);
3421 *pp_ti_abstract_origin (text) = NULL;
3423 if (in_lto_p)
3425 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3426 representing the outermost block of an inlined function.
3427 So walk the BLOCK tree until we hit such a scope. */
3428 while (block
3429 && TREE_CODE (block) == BLOCK)
3431 if (inlined_function_outer_scope_p (block))
3433 *pp_ti_abstract_origin (text) = block;
3434 break;
3436 block = BLOCK_SUPERCONTEXT (block);
3438 return;
3441 while (block
3442 && TREE_CODE (block) == BLOCK
3443 && BLOCK_ABSTRACT_ORIGIN (block))
3445 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3447 while (TREE_CODE (ao) == BLOCK
3448 && BLOCK_ABSTRACT_ORIGIN (ao)
3449 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3450 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3452 if (TREE_CODE (ao) == FUNCTION_DECL)
3454 *pp_ti_abstract_origin (text) = block;
3455 break;
3457 block = BLOCK_SUPERCONTEXT (block);
3461 /* Print the identifier ID to PRETTY-PRINTER. */
3463 void
3464 pp_tree_identifier (pretty_printer *pp, tree id)
3466 if (pp_translate_identifiers (pp))
3468 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3469 pp_append_text (pp, text, text + strlen (text));
3471 else
3472 pp_append_text (pp, IDENTIFIER_POINTER (id),
3473 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3476 /* A helper function that is used to dump function information before the
3477 function dump. */
3479 void
3480 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3482 const char *dname, *aname;
3483 struct cgraph_node *node = cgraph_node::get (fdecl);
3484 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3486 dname = lang_hooks.decl_printable_name (fdecl, 2);
3488 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3489 aname = (IDENTIFIER_POINTER
3490 (DECL_ASSEMBLER_NAME (fdecl)));
3491 else
3492 aname = "<unset-asm-name>";
3494 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3495 dname, aname, fun->funcdef_no);
3496 if (!(flags & TDF_NOUID))
3497 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3498 if (node)
3500 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3501 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3502 node->frequency == NODE_FREQUENCY_HOT
3503 ? " (hot)"
3504 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3505 ? " (unlikely executed)"
3506 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3507 ? " (executed once)"
3508 : "");
3510 else
3511 fprintf (dump_file, ")\n\n");
3514 /* Dump double_int D to pretty_printer PP. UNS is true
3515 if D is unsigned and false otherwise. */
3516 void
3517 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3519 if (d.fits_shwi ())
3520 pp_wide_integer (pp, d.low);
3521 else if (d.fits_uhwi ())
3522 pp_unsigned_wide_integer (pp, d.low);
3523 else
3525 unsigned HOST_WIDE_INT low = d.low;
3526 HOST_WIDE_INT high = d.high;
3527 if (!uns && d.is_negative ())
3529 pp_minus (pp);
3530 high = ~high + !low;
3531 low = -low;
3533 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3534 systems? */
3535 sprintf (pp_buffer (pp)->digit_buffer,
3536 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3537 (unsigned HOST_WIDE_INT) high, low);
3538 pp_string (pp, pp_buffer (pp)->digit_buffer);