runtime: set library name based on compiler name
[official-gcc.git] / gcc / tree-pretty-print.c
blob53720ded5cd375e9d9b7bf4b1bead1846e07e846
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 "predict.h"
33 #include "hash-map.h"
34 #include "is-a.h"
35 #include "plugin-api.h"
36 #include "vec.h"
37 #include "machmode.h"
38 #include "hard-reg-set.h"
39 #include "input.h"
40 #include "function.h"
41 #include "ipa-ref.h"
42 #include "cgraph.h"
43 #include "langhooks.h"
44 #include "tree-iterator.h"
45 #include "tree-chrec.h"
46 #include "dumpfile.h"
47 #include "value-prof.h"
48 #include "wide-int-print.h"
49 #include "internal-fn.h"
51 #include <new> // For placement-new.
53 /* Local functions, macros and variables. */
54 static const char *op_symbol (const_tree);
55 static void pretty_print_string (pretty_printer *, const char*);
56 static void newline_and_indent (pretty_printer *, int);
57 static void maybe_init_pretty_print (FILE *);
58 static void print_struct_decl (pretty_printer *, const_tree, int, int);
59 static void do_niy (pretty_printer *, const_tree);
61 #define INDENT(SPACE) do { \
62 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
64 #define NIY do_niy (buffer, node)
66 static pretty_printer buffer;
67 static int initialized = 0;
69 /* Try to print something for an unknown tree code. */
71 static void
72 do_niy (pretty_printer *buffer, const_tree node)
74 int i, len;
76 pp_string (buffer, "<<< Unknown tree: ");
77 pp_string (buffer, get_tree_code_name (TREE_CODE (node)));
79 if (EXPR_P (node))
81 len = TREE_OPERAND_LENGTH (node);
82 for (i = 0; i < len; ++i)
84 newline_and_indent (buffer, 2);
85 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
89 pp_string (buffer, " >>>");
92 /* Debugging function to print out a generic expression. */
94 DEBUG_FUNCTION void
95 debug_generic_expr (tree t)
97 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
98 fprintf (stderr, "\n");
101 /* Debugging function to print out a generic statement. */
103 DEBUG_FUNCTION void
104 debug_generic_stmt (tree t)
106 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
107 fprintf (stderr, "\n");
110 /* Debugging function to print out a chain of trees . */
112 DEBUG_FUNCTION void
113 debug_tree_chain (tree t)
115 hash_set<tree> seen;
117 while (t)
119 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
120 fprintf (stderr, " ");
121 t = TREE_CHAIN (t);
122 if (seen.add (t))
124 fprintf (stderr, "... [cycled back to ");
125 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
126 fprintf (stderr, "]");
127 break;
130 fprintf (stderr, "\n");
133 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
134 void
135 print_generic_decl (FILE *file, tree decl, int flags)
137 maybe_init_pretty_print (file);
138 print_declaration (&buffer, decl, 2, flags);
139 pp_write_text_to_stream (&buffer);
142 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
143 to show in the dump. See TDF_* in dumpfile.h. */
145 void
146 print_generic_stmt (FILE *file, tree t, int flags)
148 maybe_init_pretty_print (file);
149 dump_generic_node (&buffer, t, 0, flags, true);
150 pp_newline_and_flush (&buffer);
153 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
154 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
155 INDENT spaces. */
157 void
158 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
160 int i;
162 maybe_init_pretty_print (file);
164 for (i = 0; i < indent; i++)
165 pp_space (&buffer);
166 dump_generic_node (&buffer, t, indent, flags, true);
167 pp_newline_and_flush (&buffer);
170 /* Print a single expression T on file FILE. FLAGS specifies details to show
171 in the dump. See TDF_* in dumpfile.h. */
173 void
174 print_generic_expr (FILE *file, tree t, int flags)
176 maybe_init_pretty_print (file);
177 dump_generic_node (&buffer, t, 0, flags, false);
178 pp_flush (&buffer);
181 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
182 in FLAGS. */
184 static void
185 dump_decl_name (pretty_printer *buffer, tree node, int flags)
187 if (DECL_NAME (node))
189 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
190 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
191 else
192 pp_tree_identifier (buffer, DECL_NAME (node));
194 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
196 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
197 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
198 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
200 if (flags & TDF_NOUID)
201 pp_string (buffer, "D#xxxx");
202 else
203 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
205 else
207 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
208 if (flags & TDF_NOUID)
209 pp_printf (buffer, "%c.xxxx", c);
210 else
211 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
214 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
216 if (flags & TDF_NOUID)
217 pp_printf (buffer, "ptD.xxxx");
218 else
219 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
223 /* Like the above, but used for pretty printing function calls. */
225 static void
226 dump_function_name (pretty_printer *buffer, tree node, int flags)
228 if (CONVERT_EXPR_P (node))
229 node = TREE_OPERAND (node, 0);
230 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
231 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
232 else
233 dump_decl_name (buffer, node, flags);
236 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
237 FLAGS are as in dump_generic_node. */
239 static void
240 dump_function_declaration (pretty_printer *buffer, tree node,
241 int spc, int flags)
243 bool wrote_arg = false;
244 tree arg;
246 pp_space (buffer);
247 pp_left_paren (buffer);
249 /* Print the argument types. */
250 arg = TYPE_ARG_TYPES (node);
251 while (arg && arg != void_list_node && arg != error_mark_node)
253 if (wrote_arg)
255 pp_comma (buffer);
256 pp_space (buffer);
258 wrote_arg = true;
259 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
260 arg = TREE_CHAIN (arg);
263 /* Drop the trailing void_type_node if we had any previous argument. */
264 if (arg == void_list_node && !wrote_arg)
265 pp_string (buffer, "void");
266 /* Properly dump vararg function types. */
267 else if (!arg && wrote_arg)
268 pp_string (buffer, ", ...");
269 /* Avoid printing any arg for unprototyped functions. */
271 pp_right_paren (buffer);
274 /* Dump the domain associated with an array. */
276 static void
277 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
279 pp_left_bracket (buffer);
280 if (domain)
282 tree min = TYPE_MIN_VALUE (domain);
283 tree max = TYPE_MAX_VALUE (domain);
285 if (min && max
286 && integer_zerop (min)
287 && tree_fits_shwi_p (max))
288 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
289 else
291 if (min)
292 dump_generic_node (buffer, min, spc, flags, false);
293 pp_colon (buffer);
294 if (max)
295 dump_generic_node (buffer, max, spc, flags, false);
298 else
299 pp_string (buffer, "<unknown>");
300 pp_right_bracket (buffer);
304 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
305 dump_generic_node. */
307 static void
308 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
310 const char *name;
312 switch (OMP_CLAUSE_CODE (clause))
314 case OMP_CLAUSE_PRIVATE:
315 name = "private";
316 goto print_remap;
317 case OMP_CLAUSE_SHARED:
318 name = "shared";
319 goto print_remap;
320 case OMP_CLAUSE_FIRSTPRIVATE:
321 name = "firstprivate";
322 goto print_remap;
323 case OMP_CLAUSE_LASTPRIVATE:
324 name = "lastprivate";
325 goto print_remap;
326 case OMP_CLAUSE_COPYIN:
327 name = "copyin";
328 goto print_remap;
329 case OMP_CLAUSE_COPYPRIVATE:
330 name = "copyprivate";
331 goto print_remap;
332 case OMP_CLAUSE_UNIFORM:
333 name = "uniform";
334 goto print_remap;
335 case OMP_CLAUSE__LOOPTEMP_:
336 name = "_looptemp_";
337 goto print_remap;
338 print_remap:
339 pp_string (buffer, name);
340 pp_left_paren (buffer);
341 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
342 spc, flags, false);
343 pp_right_paren (buffer);
344 break;
346 case OMP_CLAUSE_REDUCTION:
347 pp_string (buffer, "reduction(");
348 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
350 pp_string (buffer,
351 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
352 pp_colon (buffer);
354 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
355 spc, flags, false);
356 pp_right_paren (buffer);
357 break;
359 case OMP_CLAUSE_IF:
360 pp_string (buffer, "if(");
361 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
362 spc, flags, false);
363 pp_right_paren (buffer);
364 break;
366 case OMP_CLAUSE_NUM_THREADS:
367 pp_string (buffer, "num_threads(");
368 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
369 spc, flags, false);
370 pp_right_paren (buffer);
371 break;
373 case OMP_CLAUSE__CILK_FOR_COUNT_:
374 pp_string (buffer, "_Cilk_for_count_(");
375 dump_generic_node (buffer, OMP_CLAUSE_OPERAND (clause, 0),
376 spc, flags, false);
377 pp_right_paren (buffer);
378 break;
380 case OMP_CLAUSE_NOWAIT:
381 pp_string (buffer, "nowait");
382 break;
383 case OMP_CLAUSE_ORDERED:
384 pp_string (buffer, "ordered");
385 break;
387 case OMP_CLAUSE_DEFAULT:
388 pp_string (buffer, "default(");
389 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
391 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
392 break;
393 case OMP_CLAUSE_DEFAULT_SHARED:
394 pp_string (buffer, "shared");
395 break;
396 case OMP_CLAUSE_DEFAULT_NONE:
397 pp_string (buffer, "none");
398 break;
399 case OMP_CLAUSE_DEFAULT_PRIVATE:
400 pp_string (buffer, "private");
401 break;
402 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
403 pp_string (buffer, "firstprivate");
404 break;
405 default:
406 gcc_unreachable ();
408 pp_right_paren (buffer);
409 break;
411 case OMP_CLAUSE_SCHEDULE:
412 pp_string (buffer, "schedule(");
413 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
415 case OMP_CLAUSE_SCHEDULE_STATIC:
416 pp_string (buffer, "static");
417 break;
418 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
419 pp_string (buffer, "dynamic");
420 break;
421 case OMP_CLAUSE_SCHEDULE_GUIDED:
422 pp_string (buffer, "guided");
423 break;
424 case OMP_CLAUSE_SCHEDULE_RUNTIME:
425 pp_string (buffer, "runtime");
426 break;
427 case OMP_CLAUSE_SCHEDULE_AUTO:
428 pp_string (buffer, "auto");
429 break;
430 case OMP_CLAUSE_SCHEDULE_CILKFOR:
431 pp_string (buffer, "cilk-for grain");
432 break;
433 default:
434 gcc_unreachable ();
436 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
438 pp_comma (buffer);
439 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
440 spc, flags, false);
442 pp_right_paren (buffer);
443 break;
445 case OMP_CLAUSE_UNTIED:
446 pp_string (buffer, "untied");
447 break;
449 case OMP_CLAUSE_COLLAPSE:
450 pp_string (buffer, "collapse(");
451 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
452 spc, flags, false);
453 pp_right_paren (buffer);
454 break;
456 case OMP_CLAUSE_FINAL:
457 pp_string (buffer, "final(");
458 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
459 spc, flags, false);
460 pp_right_paren (buffer);
461 break;
463 case OMP_CLAUSE_MERGEABLE:
464 pp_string (buffer, "mergeable");
465 break;
467 case OMP_CLAUSE_LINEAR:
468 pp_string (buffer, "linear(");
469 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
470 spc, flags, false);
471 pp_colon (buffer);
472 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
473 spc, flags, false);
474 pp_right_paren (buffer);
475 break;
477 case OMP_CLAUSE_ALIGNED:
478 pp_string (buffer, "aligned(");
479 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
480 spc, flags, false);
481 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
483 pp_colon (buffer);
484 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
485 spc, flags, false);
487 pp_right_paren (buffer);
488 break;
490 case OMP_CLAUSE_DEPEND:
491 pp_string (buffer, "depend(");
492 switch (OMP_CLAUSE_DEPEND_KIND (clause))
494 case OMP_CLAUSE_DEPEND_IN:
495 pp_string (buffer, "in");
496 break;
497 case OMP_CLAUSE_DEPEND_OUT:
498 pp_string (buffer, "out");
499 break;
500 case OMP_CLAUSE_DEPEND_INOUT:
501 pp_string (buffer, "inout");
502 break;
503 default:
504 gcc_unreachable ();
506 pp_colon (buffer);
507 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
508 spc, flags, false);
509 pp_right_paren (buffer);
510 break;
512 case OMP_CLAUSE_MAP:
513 pp_string (buffer, "map(");
514 switch (OMP_CLAUSE_MAP_KIND (clause))
516 case OMP_CLAUSE_MAP_ALLOC:
517 case OMP_CLAUSE_MAP_POINTER:
518 pp_string (buffer, "alloc");
519 break;
520 case OMP_CLAUSE_MAP_TO:
521 case OMP_CLAUSE_MAP_TO_PSET:
522 pp_string (buffer, "to");
523 break;
524 case OMP_CLAUSE_MAP_FROM:
525 pp_string (buffer, "from");
526 break;
527 case OMP_CLAUSE_MAP_TOFROM:
528 pp_string (buffer, "tofrom");
529 break;
530 default:
531 gcc_unreachable ();
533 pp_colon (buffer);
534 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
535 spc, flags, false);
536 print_clause_size:
537 if (OMP_CLAUSE_SIZE (clause))
539 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
540 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
541 pp_string (buffer, " [pointer assign, bias: ");
542 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
543 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_TO_PSET)
544 pp_string (buffer, " [pointer set, len: ");
545 else
546 pp_string (buffer, " [len: ");
547 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
548 spc, flags, false);
549 pp_right_bracket (buffer);
551 pp_right_paren (buffer);
552 break;
554 case OMP_CLAUSE_FROM:
555 pp_string (buffer, "from(");
556 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
557 spc, flags, false);
558 goto print_clause_size;
560 case OMP_CLAUSE_TO:
561 pp_string (buffer, "to(");
562 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
563 spc, flags, false);
564 goto print_clause_size;
566 case OMP_CLAUSE_NUM_TEAMS:
567 pp_string (buffer, "num_teams(");
568 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
569 spc, flags, false);
570 pp_right_paren (buffer);
571 break;
573 case OMP_CLAUSE_THREAD_LIMIT:
574 pp_string (buffer, "thread_limit(");
575 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
576 spc, flags, false);
577 pp_right_paren (buffer);
578 break;
580 case OMP_CLAUSE_DEVICE:
581 pp_string (buffer, "device(");
582 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
583 spc, flags, false);
584 pp_right_paren (buffer);
585 break;
587 case OMP_CLAUSE_DIST_SCHEDULE:
588 pp_string (buffer, "dist_schedule(static");
589 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
591 pp_comma (buffer);
592 dump_generic_node (buffer,
593 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
594 spc, flags, false);
596 pp_right_paren (buffer);
597 break;
599 case OMP_CLAUSE_PROC_BIND:
600 pp_string (buffer, "proc_bind(");
601 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
603 case OMP_CLAUSE_PROC_BIND_MASTER:
604 pp_string (buffer, "master");
605 break;
606 case OMP_CLAUSE_PROC_BIND_CLOSE:
607 pp_string (buffer, "close");
608 break;
609 case OMP_CLAUSE_PROC_BIND_SPREAD:
610 pp_string (buffer, "spread");
611 break;
612 default:
613 gcc_unreachable ();
615 pp_right_paren (buffer);
616 break;
618 case OMP_CLAUSE_SAFELEN:
619 pp_string (buffer, "safelen(");
620 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
621 spc, flags, false);
622 pp_right_paren (buffer);
623 break;
625 case OMP_CLAUSE_SIMDLEN:
626 pp_string (buffer, "simdlen(");
627 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
628 spc, flags, false);
629 pp_right_paren (buffer);
630 break;
632 case OMP_CLAUSE__SIMDUID_:
633 pp_string (buffer, "_simduid_(");
634 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
635 spc, flags, false);
636 pp_right_paren (buffer);
637 break;
639 case OMP_CLAUSE_INBRANCH:
640 pp_string (buffer, "inbranch");
641 break;
642 case OMP_CLAUSE_NOTINBRANCH:
643 pp_string (buffer, "notinbranch");
644 break;
645 case OMP_CLAUSE_FOR:
646 pp_string (buffer, "for");
647 break;
648 case OMP_CLAUSE_PARALLEL:
649 pp_string (buffer, "parallel");
650 break;
651 case OMP_CLAUSE_SECTIONS:
652 pp_string (buffer, "sections");
653 break;
654 case OMP_CLAUSE_TASKGROUP:
655 pp_string (buffer, "taskgroup");
656 break;
658 default:
659 /* Should never happen. */
660 dump_generic_node (buffer, clause, spc, flags, false);
661 break;
666 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
667 dump_generic_node. */
669 void
670 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
672 if (clause == NULL)
673 return;
675 pp_space (buffer);
676 while (1)
678 dump_omp_clause (buffer, clause, spc, flags);
679 clause = OMP_CLAUSE_CHAIN (clause);
680 if (clause == NULL)
681 return;
682 pp_space (buffer);
687 /* Dump location LOC to BUFFER. */
689 void
690 dump_location (pretty_printer *buffer, location_t loc)
692 expanded_location xloc = expand_location (loc);
694 pp_left_bracket (buffer);
695 if (xloc.file)
697 pp_string (buffer, xloc.file);
698 pp_string (buffer, ":");
700 pp_decimal_int (buffer, xloc.line);
701 pp_colon (buffer);
702 pp_decimal_int (buffer, xloc.column);
703 pp_string (buffer, "] ");
707 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
708 dump_generic_node. */
710 static void
711 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
713 tree t;
715 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
717 if (flags & TDF_ADDRESS)
718 pp_printf (buffer, "[%p] ", (void *) block);
720 if (BLOCK_ABSTRACT (block))
721 pp_string (buffer, "[abstract] ");
723 if (TREE_ASM_WRITTEN (block))
724 pp_string (buffer, "[written] ");
726 if (flags & TDF_SLIM)
727 return;
729 if (BLOCK_SOURCE_LOCATION (block))
730 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
732 newline_and_indent (buffer, spc + 2);
734 if (BLOCK_SUPERCONTEXT (block))
736 pp_string (buffer, "SUPERCONTEXT: ");
737 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
738 flags | TDF_SLIM, false);
739 newline_and_indent (buffer, spc + 2);
742 if (BLOCK_SUBBLOCKS (block))
744 pp_string (buffer, "SUBBLOCKS: ");
745 for (t = BLOCK_SUBBLOCKS (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_CHAIN (block))
755 pp_string (buffer, "SIBLINGS: ");
756 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
758 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
759 pp_space (buffer);
761 newline_and_indent (buffer, spc + 2);
764 if (BLOCK_VARS (block))
766 pp_string (buffer, "VARS: ");
767 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
769 dump_generic_node (buffer, t, 0, flags, false);
770 pp_space (buffer);
772 newline_and_indent (buffer, spc + 2);
775 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
777 unsigned i;
778 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
780 pp_string (buffer, "NONLOCALIZED_VARS: ");
781 FOR_EACH_VEC_ELT (*nlv, i, t)
783 dump_generic_node (buffer, t, 0, flags, false);
784 pp_space (buffer);
786 newline_and_indent (buffer, spc + 2);
789 if (BLOCK_ABSTRACT_ORIGIN (block))
791 pp_string (buffer, "ABSTRACT_ORIGIN: ");
792 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
793 flags | TDF_SLIM, false);
794 newline_and_indent (buffer, spc + 2);
797 if (BLOCK_FRAGMENT_ORIGIN (block))
799 pp_string (buffer, "FRAGMENT_ORIGIN: ");
800 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
801 flags | TDF_SLIM, false);
802 newline_and_indent (buffer, spc + 2);
805 if (BLOCK_FRAGMENT_CHAIN (block))
807 pp_string (buffer, "FRAGMENT_CHAIN: ");
808 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
810 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
811 pp_space (buffer);
813 newline_and_indent (buffer, spc + 2);
818 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
819 indent. FLAGS specifies details to show in the dump (see TDF_* in
820 dumpfile.h). If IS_STMT is true, the object printed is considered
821 to be a statement and it is terminated by ';' if appropriate. */
824 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
825 bool is_stmt)
827 tree type;
828 tree op0, op1;
829 const char *str;
830 bool is_expr;
831 enum tree_code code;
833 if (node == NULL_TREE)
834 return spc;
836 is_expr = EXPR_P (node);
838 if (is_stmt && (flags & TDF_STMTADDR))
839 pp_printf (buffer, "<&%p> ", (void *)node);
841 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
842 dump_location (buffer, EXPR_LOCATION (node));
844 code = TREE_CODE (node);
845 switch (code)
847 case ERROR_MARK:
848 pp_string (buffer, "<<< error >>>");
849 break;
851 case IDENTIFIER_NODE:
852 pp_tree_identifier (buffer, node);
853 break;
855 case TREE_LIST:
856 while (node && node != error_mark_node)
858 if (TREE_PURPOSE (node))
860 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
861 pp_space (buffer);
863 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
864 node = TREE_CHAIN (node);
865 if (node && TREE_CODE (node) == TREE_LIST)
867 pp_comma (buffer);
868 pp_space (buffer);
871 break;
873 case TREE_BINFO:
874 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
875 break;
877 case TREE_VEC:
879 size_t i;
880 if (TREE_VEC_LENGTH (node) > 0)
882 size_t len = TREE_VEC_LENGTH (node);
883 for (i = 0; i < len - 1; i++)
885 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
886 false);
887 pp_comma (buffer);
888 pp_space (buffer);
890 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
891 flags, false);
894 break;
896 case VOID_TYPE:
897 case POINTER_BOUNDS_TYPE:
898 case INTEGER_TYPE:
899 case REAL_TYPE:
900 case FIXED_POINT_TYPE:
901 case COMPLEX_TYPE:
902 case VECTOR_TYPE:
903 case ENUMERAL_TYPE:
904 case BOOLEAN_TYPE:
906 unsigned int quals = TYPE_QUALS (node);
907 enum tree_code_class tclass;
909 if (quals & TYPE_QUAL_ATOMIC)
910 pp_string (buffer, "atomic ");
911 if (quals & TYPE_QUAL_CONST)
912 pp_string (buffer, "const ");
913 else if (quals & TYPE_QUAL_VOLATILE)
914 pp_string (buffer, "volatile ");
915 else if (quals & TYPE_QUAL_RESTRICT)
916 pp_string (buffer, "restrict ");
918 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
920 pp_string (buffer, "<address-space-");
921 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
922 pp_string (buffer, "> ");
925 tclass = TREE_CODE_CLASS (TREE_CODE (node));
927 if (tclass == tcc_declaration)
929 if (DECL_NAME (node))
930 dump_decl_name (buffer, node, flags);
931 else
932 pp_string (buffer, "<unnamed type decl>");
934 else if (tclass == tcc_type)
936 if (TYPE_NAME (node))
938 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
939 pp_tree_identifier (buffer, TYPE_NAME (node));
940 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
941 && DECL_NAME (TYPE_NAME (node)))
942 dump_decl_name (buffer, TYPE_NAME (node), flags);
943 else
944 pp_string (buffer, "<unnamed type>");
946 else if (TREE_CODE (node) == VECTOR_TYPE)
948 pp_string (buffer, "vector");
949 pp_left_paren (buffer);
950 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
951 pp_string (buffer, ") ");
952 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
954 else if (TREE_CODE (node) == INTEGER_TYPE)
956 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
957 pp_string (buffer, (TYPE_UNSIGNED (node)
958 ? "unsigned char"
959 : "signed char"));
960 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
961 pp_string (buffer, (TYPE_UNSIGNED (node)
962 ? "unsigned short"
963 : "signed short"));
964 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
965 pp_string (buffer, (TYPE_UNSIGNED (node)
966 ? "unsigned int"
967 : "signed int"));
968 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
969 pp_string (buffer, (TYPE_UNSIGNED (node)
970 ? "unsigned long"
971 : "signed long"));
972 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
973 pp_string (buffer, (TYPE_UNSIGNED (node)
974 ? "unsigned long long"
975 : "signed long long"));
976 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
977 && exact_log2 (TYPE_PRECISION (node)) != -1)
979 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
980 pp_decimal_int (buffer, TYPE_PRECISION (node));
981 pp_string (buffer, "_t");
983 else
985 pp_string (buffer, (TYPE_UNSIGNED (node)
986 ? "<unnamed-unsigned:"
987 : "<unnamed-signed:"));
988 pp_decimal_int (buffer, TYPE_PRECISION (node));
989 pp_greater (buffer);
992 else if (TREE_CODE (node) == COMPLEX_TYPE)
994 pp_string (buffer, "__complex__ ");
995 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
997 else if (TREE_CODE (node) == REAL_TYPE)
999 pp_string (buffer, "<float:");
1000 pp_decimal_int (buffer, TYPE_PRECISION (node));
1001 pp_greater (buffer);
1003 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1005 pp_string (buffer, "<fixed-point-");
1006 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1007 pp_decimal_int (buffer, TYPE_PRECISION (node));
1008 pp_greater (buffer);
1010 else if (TREE_CODE (node) == VOID_TYPE)
1011 pp_string (buffer, "void");
1012 else
1013 pp_string (buffer, "<unnamed type>");
1015 break;
1018 case POINTER_TYPE:
1019 case REFERENCE_TYPE:
1020 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1022 if (TREE_TYPE (node) == NULL)
1024 pp_string (buffer, str);
1025 pp_string (buffer, "<null type>");
1027 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1029 tree fnode = TREE_TYPE (node);
1031 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1032 pp_space (buffer);
1033 pp_left_paren (buffer);
1034 pp_string (buffer, str);
1035 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1036 dump_decl_name (buffer, TYPE_NAME (node), flags);
1037 else if (flags & TDF_NOUID)
1038 pp_printf (buffer, "<Txxxx>");
1039 else
1040 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1042 pp_right_paren (buffer);
1043 dump_function_declaration (buffer, fnode, spc, flags);
1045 else
1047 unsigned int quals = TYPE_QUALS (node);
1049 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1050 pp_space (buffer);
1051 pp_string (buffer, str);
1053 if (quals & TYPE_QUAL_CONST)
1054 pp_string (buffer, " const");
1055 if (quals & TYPE_QUAL_VOLATILE)
1056 pp_string (buffer, " volatile");
1057 if (quals & TYPE_QUAL_RESTRICT)
1058 pp_string (buffer, " restrict");
1060 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1062 pp_string (buffer, " <address-space-");
1063 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1064 pp_greater (buffer);
1067 if (TYPE_REF_CAN_ALIAS_ALL (node))
1068 pp_string (buffer, " {ref-all}");
1070 break;
1072 case OFFSET_TYPE:
1073 NIY;
1074 break;
1076 case MEM_REF:
1078 if (integer_zerop (TREE_OPERAND (node, 1))
1079 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1080 infer them and MEM_ATTR caching will share MEM_REFs
1081 with differently-typed op0s. */
1082 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1083 /* Released SSA_NAMES have no TREE_TYPE. */
1084 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1085 /* Same pointer types, but ignoring POINTER_TYPE vs.
1086 REFERENCE_TYPE. */
1087 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1088 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1089 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1090 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1091 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1092 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1093 /* Same value types ignoring qualifiers. */
1094 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1095 == TYPE_MAIN_VARIANT
1096 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1098 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1100 pp_star (buffer);
1101 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1102 spc, flags, false);
1104 else
1105 dump_generic_node (buffer,
1106 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1107 spc, flags, false);
1109 else
1111 tree ptype;
1113 pp_string (buffer, "MEM[");
1114 pp_left_paren (buffer);
1115 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1116 dump_generic_node (buffer, ptype,
1117 spc, flags | TDF_SLIM, false);
1118 pp_right_paren (buffer);
1119 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1120 spc, flags, false);
1121 if (!integer_zerop (TREE_OPERAND (node, 1)))
1123 pp_string (buffer, " + ");
1124 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1125 spc, flags, false);
1127 pp_right_bracket (buffer);
1129 break;
1132 case TARGET_MEM_REF:
1134 const char *sep = "";
1135 tree tmp;
1137 pp_string (buffer, "MEM[");
1139 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1141 pp_string (buffer, sep);
1142 sep = ", ";
1143 pp_string (buffer, "symbol: ");
1144 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1145 spc, flags, false);
1147 else
1149 pp_string (buffer, sep);
1150 sep = ", ";
1151 pp_string (buffer, "base: ");
1152 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1154 tmp = TMR_INDEX2 (node);
1155 if (tmp)
1157 pp_string (buffer, sep);
1158 sep = ", ";
1159 pp_string (buffer, "base: ");
1160 dump_generic_node (buffer, tmp, spc, flags, false);
1162 tmp = TMR_INDEX (node);
1163 if (tmp)
1165 pp_string (buffer, sep);
1166 sep = ", ";
1167 pp_string (buffer, "index: ");
1168 dump_generic_node (buffer, tmp, spc, flags, false);
1170 tmp = TMR_STEP (node);
1171 if (tmp)
1173 pp_string (buffer, sep);
1174 sep = ", ";
1175 pp_string (buffer, "step: ");
1176 dump_generic_node (buffer, tmp, spc, flags, false);
1178 tmp = TMR_OFFSET (node);
1179 if (tmp)
1181 pp_string (buffer, sep);
1182 sep = ", ";
1183 pp_string (buffer, "offset: ");
1184 dump_generic_node (buffer, tmp, spc, flags, false);
1186 pp_right_bracket (buffer);
1188 break;
1190 case ARRAY_TYPE:
1192 tree tmp;
1194 /* Print the innermost component type. */
1195 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1196 tmp = TREE_TYPE (tmp))
1198 dump_generic_node (buffer, tmp, spc, flags, false);
1200 /* Print the dimensions. */
1201 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1202 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1203 break;
1206 case RECORD_TYPE:
1207 case UNION_TYPE:
1208 case QUAL_UNION_TYPE:
1210 unsigned int quals = TYPE_QUALS (node);
1212 if (quals & TYPE_QUAL_ATOMIC)
1213 pp_string (buffer, "atomic ");
1214 if (quals & TYPE_QUAL_CONST)
1215 pp_string (buffer, "const ");
1216 if (quals & TYPE_QUAL_VOLATILE)
1217 pp_string (buffer, "volatile ");
1219 /* Print the name of the structure. */
1220 if (TREE_CODE (node) == RECORD_TYPE)
1221 pp_string (buffer, "struct ");
1222 else if (TREE_CODE (node) == UNION_TYPE)
1223 pp_string (buffer, "union ");
1225 if (TYPE_NAME (node))
1226 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1227 else if (!(flags & TDF_SLIM))
1228 /* FIXME: If we eliminate the 'else' above and attempt
1229 to show the fields for named types, we may get stuck
1230 following a cycle of pointers to structs. The alleged
1231 self-reference check in print_struct_decl will not detect
1232 cycles involving more than one pointer or struct type. */
1233 print_struct_decl (buffer, node, spc, flags);
1234 break;
1237 case LANG_TYPE:
1238 NIY;
1239 break;
1241 case INTEGER_CST:
1242 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1244 /* In the case of a pointer, one may want to divide by the
1245 size of the pointed-to type. Unfortunately, this not
1246 straightforward. The C front-end maps expressions
1248 (int *) 5
1249 int *p; (p + 5)
1251 in such a way that the two INTEGER_CST nodes for "5" have
1252 different values but identical types. In the latter
1253 case, the 5 is multiplied by sizeof (int) in c-common.c
1254 (pointer_int_sum) to convert it to a byte address, and
1255 yet the type of the node is left unchanged. Argh. What
1256 is consistent though is that the number value corresponds
1257 to bytes (UNITS) offset.
1259 NB: Neither of the following divisors can be trivially
1260 used to recover the original literal:
1262 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1263 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1264 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1265 pp_string (buffer, "B"); /* pseudo-unit */
1267 else if (tree_fits_shwi_p (node))
1268 pp_wide_integer (buffer, tree_to_shwi (node));
1269 else if (tree_fits_uhwi_p (node))
1270 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1271 else
1273 wide_int val = node;
1275 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1277 pp_minus (buffer);
1278 val = -val;
1280 print_hex (val, pp_buffer (buffer)->digit_buffer);
1281 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1283 if (TREE_OVERFLOW (node))
1284 pp_string (buffer, "(OVF)");
1285 break;
1287 case REAL_CST:
1288 /* Code copied from print_node. */
1290 REAL_VALUE_TYPE d;
1291 if (TREE_OVERFLOW (node))
1292 pp_string (buffer, " overflow");
1294 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1295 d = TREE_REAL_CST (node);
1296 if (REAL_VALUE_ISINF (d))
1297 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1298 else if (REAL_VALUE_ISNAN (d))
1299 pp_string (buffer, " Nan");
1300 else
1302 char string[100];
1303 real_to_decimal (string, &d, sizeof (string), 0, 1);
1304 pp_string (buffer, string);
1306 #else
1308 HOST_WIDE_INT i;
1309 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1310 pp_string (buffer, "0x");
1311 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1312 output_formatted_integer (buffer, "%02x", *p++);
1314 #endif
1315 break;
1318 case FIXED_CST:
1320 char string[100];
1321 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1322 pp_string (buffer, string);
1323 break;
1326 case COMPLEX_CST:
1327 pp_string (buffer, "__complex__ (");
1328 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1329 pp_string (buffer, ", ");
1330 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1331 pp_right_paren (buffer);
1332 break;
1334 case STRING_CST:
1335 pp_string (buffer, "\"");
1336 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1337 pp_string (buffer, "\"");
1338 break;
1340 case VECTOR_CST:
1342 unsigned i;
1343 pp_string (buffer, "{ ");
1344 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1346 if (i != 0)
1347 pp_string (buffer, ", ");
1348 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1349 spc, flags, false);
1351 pp_string (buffer, " }");
1353 break;
1355 case FUNCTION_TYPE:
1356 case METHOD_TYPE:
1357 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1358 pp_space (buffer);
1359 if (TREE_CODE (node) == METHOD_TYPE)
1361 if (TYPE_METHOD_BASETYPE (node))
1362 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1363 flags);
1364 else
1365 pp_string (buffer, "<null method basetype>");
1366 pp_colon_colon (buffer);
1368 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1369 dump_decl_name (buffer, TYPE_NAME (node), flags);
1370 else if (flags & TDF_NOUID)
1371 pp_printf (buffer, "<Txxxx>");
1372 else
1373 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1374 dump_function_declaration (buffer, node, spc, flags);
1375 break;
1377 case FUNCTION_DECL:
1378 case CONST_DECL:
1379 dump_decl_name (buffer, node, flags);
1380 break;
1382 case LABEL_DECL:
1383 if (DECL_NAME (node))
1384 dump_decl_name (buffer, node, flags);
1385 else if (LABEL_DECL_UID (node) != -1)
1386 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1387 else
1389 if (flags & TDF_NOUID)
1390 pp_string (buffer, "<D.xxxx>");
1391 else
1392 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1394 break;
1396 case TYPE_DECL:
1397 if (DECL_IS_BUILTIN (node))
1399 /* Don't print the declaration of built-in types. */
1400 break;
1402 if (DECL_NAME (node))
1403 dump_decl_name (buffer, node, flags);
1404 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1406 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1407 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1408 && TYPE_METHODS (TREE_TYPE (node)))
1410 /* The type is a c++ class: all structures have at least
1411 4 methods. */
1412 pp_string (buffer, "class ");
1413 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1415 else
1417 pp_string (buffer,
1418 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1419 ? "union" : "struct "));
1420 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1423 else
1424 pp_string (buffer, "<anon>");
1425 break;
1427 case VAR_DECL:
1428 case PARM_DECL:
1429 case FIELD_DECL:
1430 case DEBUG_EXPR_DECL:
1431 case NAMESPACE_DECL:
1432 case NAMELIST_DECL:
1433 dump_decl_name (buffer, node, flags);
1434 break;
1436 case RESULT_DECL:
1437 pp_string (buffer, "<retval>");
1438 break;
1440 case COMPONENT_REF:
1441 op0 = TREE_OPERAND (node, 0);
1442 str = ".";
1443 if (op0
1444 && (TREE_CODE (op0) == INDIRECT_REF
1445 || (TREE_CODE (op0) == MEM_REF
1446 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1447 && integer_zerop (TREE_OPERAND (op0, 1))
1448 /* Dump the types of INTEGER_CSTs explicitly, for we
1449 can't infer them and MEM_ATTR caching will share
1450 MEM_REFs with differently-typed op0s. */
1451 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1452 /* Released SSA_NAMES have no TREE_TYPE. */
1453 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1454 /* Same pointer types, but ignoring POINTER_TYPE vs.
1455 REFERENCE_TYPE. */
1456 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1457 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1458 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1459 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1460 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1461 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1462 /* Same value types ignoring qualifiers. */
1463 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1464 == TYPE_MAIN_VARIANT
1465 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1467 op0 = TREE_OPERAND (op0, 0);
1468 str = "->";
1470 if (op_prio (op0) < op_prio (node))
1471 pp_left_paren (buffer);
1472 dump_generic_node (buffer, op0, spc, flags, false);
1473 if (op_prio (op0) < op_prio (node))
1474 pp_right_paren (buffer);
1475 pp_string (buffer, str);
1476 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1477 op0 = component_ref_field_offset (node);
1478 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1480 pp_string (buffer, "{off: ");
1481 dump_generic_node (buffer, op0, spc, flags, false);
1482 pp_right_brace (buffer);
1484 break;
1486 case BIT_FIELD_REF:
1487 pp_string (buffer, "BIT_FIELD_REF <");
1488 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1489 pp_string (buffer, ", ");
1490 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1491 pp_string (buffer, ", ");
1492 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1493 pp_greater (buffer);
1494 break;
1496 case ARRAY_REF:
1497 case ARRAY_RANGE_REF:
1498 op0 = TREE_OPERAND (node, 0);
1499 if (op_prio (op0) < op_prio (node))
1500 pp_left_paren (buffer);
1501 dump_generic_node (buffer, op0, spc, flags, false);
1502 if (op_prio (op0) < op_prio (node))
1503 pp_right_paren (buffer);
1504 pp_left_bracket (buffer);
1505 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1506 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1507 pp_string (buffer, " ...");
1508 pp_right_bracket (buffer);
1510 op0 = array_ref_low_bound (node);
1511 op1 = array_ref_element_size (node);
1513 if (!integer_zerop (op0)
1514 || TREE_OPERAND (node, 2)
1515 || TREE_OPERAND (node, 3))
1517 pp_string (buffer, "{lb: ");
1518 dump_generic_node (buffer, op0, spc, flags, false);
1519 pp_string (buffer, " sz: ");
1520 dump_generic_node (buffer, op1, spc, flags, false);
1521 pp_right_brace (buffer);
1523 break;
1525 case CONSTRUCTOR:
1527 unsigned HOST_WIDE_INT ix;
1528 tree field, val;
1529 bool is_struct_init = false;
1530 bool is_array_init = false;
1531 widest_int curidx;
1532 pp_left_brace (buffer);
1533 if (TREE_CLOBBER_P (node))
1534 pp_string (buffer, "CLOBBER");
1535 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1536 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1537 is_struct_init = true;
1538 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1539 && TYPE_DOMAIN (TREE_TYPE (node))
1540 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1541 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1542 == INTEGER_CST)
1544 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1545 is_array_init = true;
1546 curidx = wi::to_widest (minv);
1548 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1550 if (field)
1552 if (is_struct_init)
1554 pp_dot (buffer);
1555 dump_generic_node (buffer, field, spc, flags, false);
1556 pp_equal (buffer);
1558 else if (is_array_init
1559 && (TREE_CODE (field) != INTEGER_CST
1560 || curidx != wi::to_widest (field)))
1562 pp_left_bracket (buffer);
1563 if (TREE_CODE (field) == RANGE_EXPR)
1565 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1566 flags, false);
1567 pp_string (buffer, " ... ");
1568 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1569 flags, false);
1570 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1571 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1573 else
1574 dump_generic_node (buffer, field, spc, flags, false);
1575 if (TREE_CODE (field) == INTEGER_CST)
1576 curidx = wi::to_widest (field);
1577 pp_string (buffer, "]=");
1580 if (is_array_init)
1581 curidx += 1;
1582 if (val && TREE_CODE (val) == ADDR_EXPR)
1583 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1584 val = TREE_OPERAND (val, 0);
1585 if (val && TREE_CODE (val) == FUNCTION_DECL)
1586 dump_decl_name (buffer, val, flags);
1587 else
1588 dump_generic_node (buffer, val, spc, flags, false);
1589 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1591 pp_comma (buffer);
1592 pp_space (buffer);
1595 pp_right_brace (buffer);
1597 break;
1599 case COMPOUND_EXPR:
1601 tree *tp;
1602 if (flags & TDF_SLIM)
1604 pp_string (buffer, "<COMPOUND_EXPR>");
1605 break;
1608 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1609 spc, flags, !(flags & TDF_SLIM));
1610 if (flags & TDF_SLIM)
1611 newline_and_indent (buffer, spc);
1612 else
1614 pp_comma (buffer);
1615 pp_space (buffer);
1618 for (tp = &TREE_OPERAND (node, 1);
1619 TREE_CODE (*tp) == COMPOUND_EXPR;
1620 tp = &TREE_OPERAND (*tp, 1))
1622 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1623 spc, flags, !(flags & TDF_SLIM));
1624 if (flags & TDF_SLIM)
1625 newline_and_indent (buffer, spc);
1626 else
1628 pp_comma (buffer);
1629 pp_space (buffer);
1633 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1635 break;
1637 case STATEMENT_LIST:
1639 tree_stmt_iterator si;
1640 bool first = true;
1642 if (flags & TDF_SLIM)
1644 pp_string (buffer, "<STATEMENT_LIST>");
1645 break;
1648 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1650 if (!first)
1651 newline_and_indent (buffer, spc);
1652 else
1653 first = false;
1654 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1657 break;
1659 case MODIFY_EXPR:
1660 case INIT_EXPR:
1661 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1662 false);
1663 pp_space (buffer);
1664 pp_equal (buffer);
1665 pp_space (buffer);
1666 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1667 false);
1668 break;
1670 case TARGET_EXPR:
1671 pp_string (buffer, "TARGET_EXPR <");
1672 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1673 pp_comma (buffer);
1674 pp_space (buffer);
1675 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1676 pp_greater (buffer);
1677 break;
1679 case DECL_EXPR:
1680 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1681 is_stmt = false;
1682 break;
1684 case COND_EXPR:
1685 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1687 pp_string (buffer, "if (");
1688 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1689 pp_right_paren (buffer);
1690 /* The lowered cond_exprs should always be printed in full. */
1691 if (COND_EXPR_THEN (node)
1692 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1693 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1694 && COND_EXPR_ELSE (node)
1695 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1696 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1698 pp_space (buffer);
1699 dump_generic_node (buffer, COND_EXPR_THEN (node),
1700 0, flags, true);
1701 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1703 pp_string (buffer, " else ");
1704 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1705 0, flags, true);
1708 else if (!(flags & TDF_SLIM))
1710 /* Output COND_EXPR_THEN. */
1711 if (COND_EXPR_THEN (node))
1713 newline_and_indent (buffer, spc+2);
1714 pp_left_brace (buffer);
1715 newline_and_indent (buffer, spc+4);
1716 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1717 flags, true);
1718 newline_and_indent (buffer, spc+2);
1719 pp_right_brace (buffer);
1722 /* Output COND_EXPR_ELSE. */
1723 if (COND_EXPR_ELSE (node)
1724 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1726 newline_and_indent (buffer, spc);
1727 pp_string (buffer, "else");
1728 newline_and_indent (buffer, spc+2);
1729 pp_left_brace (buffer);
1730 newline_and_indent (buffer, spc+4);
1731 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1732 flags, true);
1733 newline_and_indent (buffer, spc+2);
1734 pp_right_brace (buffer);
1737 is_expr = false;
1739 else
1741 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1742 pp_space (buffer);
1743 pp_question (buffer);
1744 pp_space (buffer);
1745 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1746 pp_space (buffer);
1747 pp_colon (buffer);
1748 pp_space (buffer);
1749 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1751 break;
1753 case BIND_EXPR:
1754 pp_left_brace (buffer);
1755 if (!(flags & TDF_SLIM))
1757 if (BIND_EXPR_VARS (node))
1759 pp_newline (buffer);
1761 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1763 print_declaration (buffer, op0, spc+2, flags);
1764 pp_newline (buffer);
1768 newline_and_indent (buffer, spc+2);
1769 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1770 newline_and_indent (buffer, spc);
1771 pp_right_brace (buffer);
1773 is_expr = false;
1774 break;
1776 case CALL_EXPR:
1777 if (CALL_EXPR_FN (node) != NULL_TREE)
1778 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1779 else
1780 pp_string (buffer, internal_fn_name (CALL_EXPR_IFN (node)));
1782 /* Print parameters. */
1783 pp_space (buffer);
1784 pp_left_paren (buffer);
1786 tree arg;
1787 call_expr_arg_iterator iter;
1788 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1790 dump_generic_node (buffer, arg, spc, flags, false);
1791 if (more_call_expr_args_p (&iter))
1793 pp_comma (buffer);
1794 pp_space (buffer);
1798 if (CALL_EXPR_VA_ARG_PACK (node))
1800 if (call_expr_nargs (node) > 0)
1802 pp_comma (buffer);
1803 pp_space (buffer);
1805 pp_string (buffer, "__builtin_va_arg_pack ()");
1807 pp_right_paren (buffer);
1809 op1 = CALL_EXPR_STATIC_CHAIN (node);
1810 if (op1)
1812 pp_string (buffer, " [static-chain: ");
1813 dump_generic_node (buffer, op1, spc, flags, false);
1814 pp_right_bracket (buffer);
1817 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1818 pp_string (buffer, " [return slot optimization]");
1819 if (CALL_EXPR_TAILCALL (node))
1820 pp_string (buffer, " [tail call]");
1821 break;
1823 case WITH_CLEANUP_EXPR:
1824 NIY;
1825 break;
1827 case CLEANUP_POINT_EXPR:
1828 pp_string (buffer, "<<cleanup_point ");
1829 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1830 pp_string (buffer, ">>");
1831 break;
1833 case PLACEHOLDER_EXPR:
1834 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1835 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1836 pp_greater (buffer);
1837 break;
1839 /* Binary arithmetic and logic expressions. */
1840 case WIDEN_SUM_EXPR:
1841 case WIDEN_MULT_EXPR:
1842 case MULT_EXPR:
1843 case MULT_HIGHPART_EXPR:
1844 case PLUS_EXPR:
1845 case POINTER_PLUS_EXPR:
1846 case MINUS_EXPR:
1847 case TRUNC_DIV_EXPR:
1848 case CEIL_DIV_EXPR:
1849 case FLOOR_DIV_EXPR:
1850 case ROUND_DIV_EXPR:
1851 case TRUNC_MOD_EXPR:
1852 case CEIL_MOD_EXPR:
1853 case FLOOR_MOD_EXPR:
1854 case ROUND_MOD_EXPR:
1855 case RDIV_EXPR:
1856 case EXACT_DIV_EXPR:
1857 case LSHIFT_EXPR:
1858 case RSHIFT_EXPR:
1859 case LROTATE_EXPR:
1860 case RROTATE_EXPR:
1861 case WIDEN_LSHIFT_EXPR:
1862 case BIT_IOR_EXPR:
1863 case BIT_XOR_EXPR:
1864 case BIT_AND_EXPR:
1865 case TRUTH_ANDIF_EXPR:
1866 case TRUTH_ORIF_EXPR:
1867 case TRUTH_AND_EXPR:
1868 case TRUTH_OR_EXPR:
1869 case TRUTH_XOR_EXPR:
1870 case LT_EXPR:
1871 case LE_EXPR:
1872 case GT_EXPR:
1873 case GE_EXPR:
1874 case EQ_EXPR:
1875 case NE_EXPR:
1876 case UNLT_EXPR:
1877 case UNLE_EXPR:
1878 case UNGT_EXPR:
1879 case UNGE_EXPR:
1880 case UNEQ_EXPR:
1881 case LTGT_EXPR:
1882 case ORDERED_EXPR:
1883 case UNORDERED_EXPR:
1885 const char *op = op_symbol (node);
1886 op0 = TREE_OPERAND (node, 0);
1887 op1 = TREE_OPERAND (node, 1);
1889 /* When the operands are expressions with less priority,
1890 keep semantics of the tree representation. */
1891 if (op_prio (op0) <= op_prio (node))
1893 pp_left_paren (buffer);
1894 dump_generic_node (buffer, op0, spc, flags, false);
1895 pp_right_paren (buffer);
1897 else
1898 dump_generic_node (buffer, op0, spc, flags, false);
1900 pp_space (buffer);
1901 pp_string (buffer, op);
1902 pp_space (buffer);
1904 /* When the operands are expressions with less priority,
1905 keep semantics of the tree representation. */
1906 if (op_prio (op1) <= op_prio (node))
1908 pp_left_paren (buffer);
1909 dump_generic_node (buffer, op1, spc, flags, false);
1910 pp_right_paren (buffer);
1912 else
1913 dump_generic_node (buffer, op1, spc, flags, false);
1915 break;
1917 /* Unary arithmetic and logic expressions. */
1918 case NEGATE_EXPR:
1919 case BIT_NOT_EXPR:
1920 case TRUTH_NOT_EXPR:
1921 case ADDR_EXPR:
1922 case PREDECREMENT_EXPR:
1923 case PREINCREMENT_EXPR:
1924 case INDIRECT_REF:
1925 if (TREE_CODE (node) == ADDR_EXPR
1926 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1927 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1928 ; /* Do not output '&' for strings and function pointers. */
1929 else
1930 pp_string (buffer, op_symbol (node));
1932 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1934 pp_left_paren (buffer);
1935 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1936 pp_right_paren (buffer);
1938 else
1939 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1940 break;
1942 case POSTDECREMENT_EXPR:
1943 case POSTINCREMENT_EXPR:
1944 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1946 pp_left_paren (buffer);
1947 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1948 pp_right_paren (buffer);
1950 else
1951 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1952 pp_string (buffer, op_symbol (node));
1953 break;
1955 case MIN_EXPR:
1956 pp_string (buffer, "MIN_EXPR <");
1957 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1958 pp_string (buffer, ", ");
1959 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1960 pp_greater (buffer);
1961 break;
1963 case MAX_EXPR:
1964 pp_string (buffer, "MAX_EXPR <");
1965 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1966 pp_string (buffer, ", ");
1967 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1968 pp_greater (buffer);
1969 break;
1971 case ABS_EXPR:
1972 pp_string (buffer, "ABS_EXPR <");
1973 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1974 pp_greater (buffer);
1975 break;
1977 case RANGE_EXPR:
1978 NIY;
1979 break;
1981 case ADDR_SPACE_CONVERT_EXPR:
1982 case FIXED_CONVERT_EXPR:
1983 case FIX_TRUNC_EXPR:
1984 case FLOAT_EXPR:
1985 CASE_CONVERT:
1986 type = TREE_TYPE (node);
1987 op0 = TREE_OPERAND (node, 0);
1988 if (type != TREE_TYPE (op0))
1990 pp_left_paren (buffer);
1991 dump_generic_node (buffer, type, spc, flags, false);
1992 pp_string (buffer, ") ");
1994 if (op_prio (op0) < op_prio (node))
1995 pp_left_paren (buffer);
1996 dump_generic_node (buffer, op0, spc, flags, false);
1997 if (op_prio (op0) < op_prio (node))
1998 pp_right_paren (buffer);
1999 break;
2001 case VIEW_CONVERT_EXPR:
2002 pp_string (buffer, "VIEW_CONVERT_EXPR<");
2003 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
2004 pp_string (buffer, ">(");
2005 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2006 pp_right_paren (buffer);
2007 break;
2009 case PAREN_EXPR:
2010 pp_string (buffer, "((");
2011 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2012 pp_string (buffer, "))");
2013 break;
2015 case NON_LVALUE_EXPR:
2016 pp_string (buffer, "NON_LVALUE_EXPR <");
2017 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2018 pp_greater (buffer);
2019 break;
2021 case SAVE_EXPR:
2022 pp_string (buffer, "SAVE_EXPR <");
2023 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2024 pp_greater (buffer);
2025 break;
2027 case COMPLEX_EXPR:
2028 pp_string (buffer, "COMPLEX_EXPR <");
2029 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2030 pp_string (buffer, ", ");
2031 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2032 pp_greater (buffer);
2033 break;
2035 case CONJ_EXPR:
2036 pp_string (buffer, "CONJ_EXPR <");
2037 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2038 pp_greater (buffer);
2039 break;
2041 case REALPART_EXPR:
2042 pp_string (buffer, "REALPART_EXPR <");
2043 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2044 pp_greater (buffer);
2045 break;
2047 case IMAGPART_EXPR:
2048 pp_string (buffer, "IMAGPART_EXPR <");
2049 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2050 pp_greater (buffer);
2051 break;
2053 case VA_ARG_EXPR:
2054 pp_string (buffer, "VA_ARG_EXPR <");
2055 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2056 pp_greater (buffer);
2057 break;
2059 case TRY_FINALLY_EXPR:
2060 case TRY_CATCH_EXPR:
2061 pp_string (buffer, "try");
2062 newline_and_indent (buffer, spc+2);
2063 pp_left_brace (buffer);
2064 newline_and_indent (buffer, spc+4);
2065 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2066 newline_and_indent (buffer, spc+2);
2067 pp_right_brace (buffer);
2068 newline_and_indent (buffer, spc);
2069 pp_string (buffer,
2070 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2071 newline_and_indent (buffer, spc+2);
2072 pp_left_brace (buffer);
2073 newline_and_indent (buffer, spc+4);
2074 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2075 newline_and_indent (buffer, spc+2);
2076 pp_right_brace (buffer);
2077 is_expr = false;
2078 break;
2080 case CATCH_EXPR:
2081 pp_string (buffer, "catch (");
2082 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2083 pp_right_paren (buffer);
2084 newline_and_indent (buffer, spc+2);
2085 pp_left_brace (buffer);
2086 newline_and_indent (buffer, spc+4);
2087 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2088 newline_and_indent (buffer, spc+2);
2089 pp_right_brace (buffer);
2090 is_expr = false;
2091 break;
2093 case EH_FILTER_EXPR:
2094 pp_string (buffer, "<<<eh_filter (");
2095 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2096 pp_string (buffer, ")>>>");
2097 newline_and_indent (buffer, spc+2);
2098 pp_left_brace (buffer);
2099 newline_and_indent (buffer, spc+4);
2100 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2101 newline_and_indent (buffer, spc+2);
2102 pp_right_brace (buffer);
2103 is_expr = false;
2104 break;
2106 case LABEL_EXPR:
2107 op0 = TREE_OPERAND (node, 0);
2108 /* If this is for break or continue, don't bother printing it. */
2109 if (DECL_NAME (op0))
2111 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2112 if (strcmp (name, "break") == 0
2113 || strcmp (name, "continue") == 0)
2114 break;
2116 dump_generic_node (buffer, op0, spc, flags, false);
2117 pp_colon (buffer);
2118 if (DECL_NONLOCAL (op0))
2119 pp_string (buffer, " [non-local]");
2120 break;
2122 case LOOP_EXPR:
2123 pp_string (buffer, "while (1)");
2124 if (!(flags & TDF_SLIM))
2126 newline_and_indent (buffer, spc+2);
2127 pp_left_brace (buffer);
2128 newline_and_indent (buffer, spc+4);
2129 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2130 newline_and_indent (buffer, spc+2);
2131 pp_right_brace (buffer);
2133 is_expr = false;
2134 break;
2136 case PREDICT_EXPR:
2137 pp_string (buffer, "// predicted ");
2138 if (PREDICT_EXPR_OUTCOME (node))
2139 pp_string (buffer, "likely by ");
2140 else
2141 pp_string (buffer, "unlikely by ");
2142 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2143 pp_string (buffer, " predictor.");
2144 break;
2146 case ANNOTATE_EXPR:
2147 pp_string (buffer, "ANNOTATE_EXPR <");
2148 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2149 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2151 case annot_expr_ivdep_kind:
2152 pp_string (buffer, ", ivdep");
2153 break;
2154 case annot_expr_no_vector_kind:
2155 pp_string (buffer, ", no-vector");
2156 break;
2157 case annot_expr_vector_kind:
2158 pp_string (buffer, ", vector");
2159 break;
2160 default:
2161 gcc_unreachable ();
2163 pp_greater (buffer);
2164 break;
2166 case RETURN_EXPR:
2167 pp_string (buffer, "return");
2168 op0 = TREE_OPERAND (node, 0);
2169 if (op0)
2171 pp_space (buffer);
2172 if (TREE_CODE (op0) == MODIFY_EXPR)
2173 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2174 spc, flags, false);
2175 else
2176 dump_generic_node (buffer, op0, spc, flags, false);
2178 break;
2180 case EXIT_EXPR:
2181 pp_string (buffer, "if (");
2182 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2183 pp_string (buffer, ") break");
2184 break;
2186 case SWITCH_EXPR:
2187 pp_string (buffer, "switch (");
2188 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2189 pp_right_paren (buffer);
2190 if (!(flags & TDF_SLIM))
2192 newline_and_indent (buffer, spc+2);
2193 pp_left_brace (buffer);
2194 if (SWITCH_BODY (node))
2196 newline_and_indent (buffer, spc+4);
2197 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2198 true);
2200 else
2202 tree vec = SWITCH_LABELS (node);
2203 size_t i, n = TREE_VEC_LENGTH (vec);
2204 for (i = 0; i < n; ++i)
2206 tree elt = TREE_VEC_ELT (vec, i);
2207 newline_and_indent (buffer, spc+4);
2208 if (elt)
2210 dump_generic_node (buffer, elt, spc+4, flags, false);
2211 pp_string (buffer, " goto ");
2212 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2213 flags, true);
2214 pp_semicolon (buffer);
2216 else
2217 pp_string (buffer, "case ???: goto ???;");
2220 newline_and_indent (buffer, spc+2);
2221 pp_right_brace (buffer);
2223 is_expr = false;
2224 break;
2226 case GOTO_EXPR:
2227 op0 = GOTO_DESTINATION (node);
2228 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2230 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2231 if (strcmp (name, "break") == 0
2232 || strcmp (name, "continue") == 0)
2234 pp_string (buffer, name);
2235 break;
2238 pp_string (buffer, "goto ");
2239 dump_generic_node (buffer, op0, spc, flags, false);
2240 break;
2242 case ASM_EXPR:
2243 pp_string (buffer, "__asm__");
2244 if (ASM_VOLATILE_P (node))
2245 pp_string (buffer, " __volatile__");
2246 pp_left_paren (buffer);
2247 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2248 pp_colon (buffer);
2249 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2250 pp_colon (buffer);
2251 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2252 if (ASM_CLOBBERS (node))
2254 pp_colon (buffer);
2255 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2257 pp_right_paren (buffer);
2258 break;
2260 case CASE_LABEL_EXPR:
2261 if (CASE_LOW (node) && CASE_HIGH (node))
2263 pp_string (buffer, "case ");
2264 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2265 pp_string (buffer, " ... ");
2266 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2268 else if (CASE_LOW (node))
2270 pp_string (buffer, "case ");
2271 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2273 else
2274 pp_string (buffer, "default");
2275 pp_colon (buffer);
2276 break;
2278 case OBJ_TYPE_REF:
2279 pp_string (buffer, "OBJ_TYPE_REF(");
2280 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2281 pp_semicolon (buffer);
2282 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2284 pp_string (buffer, "(");
2285 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2286 pp_string (buffer, ")");
2288 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2289 pp_arrow (buffer);
2290 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2291 pp_right_paren (buffer);
2292 break;
2294 case SSA_NAME:
2295 if (SSA_NAME_IDENTIFIER (node))
2296 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2297 spc, flags, false);
2298 pp_underscore (buffer);
2299 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2300 if (SSA_NAME_IS_DEFAULT_DEF (node))
2301 pp_string (buffer, "(D)");
2302 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2303 pp_string (buffer, "(ab)");
2304 break;
2306 case WITH_SIZE_EXPR:
2307 pp_string (buffer, "WITH_SIZE_EXPR <");
2308 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2309 pp_string (buffer, ", ");
2310 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2311 pp_greater (buffer);
2312 break;
2314 case ASSERT_EXPR:
2315 pp_string (buffer, "ASSERT_EXPR <");
2316 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2317 pp_string (buffer, ", ");
2318 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2319 pp_greater (buffer);
2320 break;
2322 case SCEV_KNOWN:
2323 pp_string (buffer, "scev_known");
2324 break;
2326 case SCEV_NOT_KNOWN:
2327 pp_string (buffer, "scev_not_known");
2328 break;
2330 case POLYNOMIAL_CHREC:
2331 pp_left_brace (buffer);
2332 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2333 pp_string (buffer, ", +, ");
2334 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2335 pp_string (buffer, "}_");
2336 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2337 is_stmt = false;
2338 break;
2340 case REALIGN_LOAD_EXPR:
2341 pp_string (buffer, "REALIGN_LOAD <");
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_greater (buffer);
2348 break;
2350 case VEC_COND_EXPR:
2351 pp_string (buffer, " VEC_COND_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 VEC_PERM_EXPR:
2361 pp_string (buffer, " VEC_PERM_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 DOT_PROD_EXPR:
2371 pp_string (buffer, " DOT_PROD_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_PLUS_EXPR:
2381 pp_string (buffer, " WIDEN_MULT_PLUS_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 WIDEN_MULT_MINUS_EXPR:
2391 pp_string (buffer, " WIDEN_MULT_MINUS_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 FMA_EXPR:
2401 pp_string (buffer, " FMA_EXPR < ");
2402 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2403 pp_string (buffer, ", ");
2404 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2405 pp_string (buffer, ", ");
2406 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2407 pp_string (buffer, " > ");
2408 break;
2410 case OMP_PARALLEL:
2411 pp_string (buffer, "#pragma omp parallel");
2412 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2414 dump_omp_body:
2415 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2417 newline_and_indent (buffer, spc + 2);
2418 pp_left_brace (buffer);
2419 newline_and_indent (buffer, spc + 4);
2420 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2421 newline_and_indent (buffer, spc + 2);
2422 pp_right_brace (buffer);
2424 is_expr = false;
2425 break;
2427 case OMP_TASK:
2428 pp_string (buffer, "#pragma omp task");
2429 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2430 goto dump_omp_body;
2432 case OMP_FOR:
2433 pp_string (buffer, "#pragma omp for");
2434 goto dump_omp_loop;
2436 case OMP_SIMD:
2437 pp_string (buffer, "#pragma omp simd");
2438 goto dump_omp_loop;
2440 case CILK_SIMD:
2441 pp_string (buffer, "#pragma simd");
2442 goto dump_omp_loop;
2444 case CILK_FOR:
2445 /* This label points one line after dumping the clauses.
2446 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2447 parameters are printed out. */
2448 goto dump_omp_loop_cilk_for;
2450 case OMP_DISTRIBUTE:
2451 pp_string (buffer, "#pragma omp distribute");
2452 goto dump_omp_loop;
2454 case OMP_TEAMS:
2455 pp_string (buffer, "#pragma omp teams");
2456 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2457 goto dump_omp_body;
2459 case OMP_TARGET_DATA:
2460 pp_string (buffer, "#pragma omp target data");
2461 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2462 goto dump_omp_body;
2464 case OMP_TARGET:
2465 pp_string (buffer, "#pragma omp target");
2466 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2467 goto dump_omp_body;
2469 case OMP_TARGET_UPDATE:
2470 pp_string (buffer, "#pragma omp target update");
2471 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2472 is_expr = false;
2473 break;
2475 dump_omp_loop:
2476 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2478 dump_omp_loop_cilk_for:
2479 if (!(flags & TDF_SLIM))
2481 int i;
2483 if (OMP_FOR_PRE_BODY (node))
2485 if (TREE_CODE (node) == CILK_FOR)
2486 pp_string (buffer, " ");
2487 else
2488 newline_and_indent (buffer, spc + 2);
2489 pp_left_brace (buffer);
2490 spc += 4;
2491 newline_and_indent (buffer, spc);
2492 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2493 spc, flags, false);
2495 if (OMP_FOR_INIT (node))
2497 spc -= 2;
2498 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2500 spc += 2;
2501 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2502 newline_and_indent (buffer, spc);
2503 if (TREE_CODE (node) == CILK_FOR)
2504 pp_string (buffer, "_Cilk_for (");
2505 else
2506 pp_string (buffer, "for (");
2507 dump_generic_node (buffer,
2508 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2509 spc, flags, false);
2510 pp_string (buffer, "; ");
2511 dump_generic_node (buffer,
2512 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2513 spc, flags, false);
2514 pp_string (buffer, "; ");
2515 dump_generic_node (buffer,
2516 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2517 spc, flags, false);
2518 pp_right_paren (buffer);
2520 if (TREE_CODE (node) == CILK_FOR)
2521 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2523 if (OMP_FOR_BODY (node))
2525 newline_and_indent (buffer, spc + 2);
2526 pp_left_brace (buffer);
2527 newline_and_indent (buffer, spc + 4);
2528 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2529 false);
2530 newline_and_indent (buffer, spc + 2);
2531 pp_right_brace (buffer);
2533 if (OMP_FOR_INIT (node))
2534 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2535 if (OMP_FOR_PRE_BODY (node))
2537 spc -= 4;
2538 newline_and_indent (buffer, spc + 2);
2539 pp_right_brace (buffer);
2542 is_expr = false;
2543 break;
2545 case OMP_SECTIONS:
2546 pp_string (buffer, "#pragma omp sections");
2547 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2548 goto dump_omp_body;
2550 case OMP_SECTION:
2551 pp_string (buffer, "#pragma omp section");
2552 goto dump_omp_body;
2554 case OMP_MASTER:
2555 pp_string (buffer, "#pragma omp master");
2556 goto dump_omp_body;
2558 case OMP_TASKGROUP:
2559 pp_string (buffer, "#pragma omp taskgroup");
2560 goto dump_omp_body;
2562 case OMP_ORDERED:
2563 pp_string (buffer, "#pragma omp ordered");
2564 goto dump_omp_body;
2566 case OMP_CRITICAL:
2567 pp_string (buffer, "#pragma omp critical");
2568 if (OMP_CRITICAL_NAME (node))
2570 pp_space (buffer);
2571 pp_left_paren (buffer);
2572 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2573 flags, false);
2574 pp_right_paren (buffer);
2576 goto dump_omp_body;
2578 case OMP_ATOMIC:
2579 pp_string (buffer, "#pragma omp atomic");
2580 if (OMP_ATOMIC_SEQ_CST (node))
2581 pp_string (buffer, " seq_cst");
2582 newline_and_indent (buffer, spc + 2);
2583 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2584 pp_space (buffer);
2585 pp_equal (buffer);
2586 pp_space (buffer);
2587 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2588 break;
2590 case OMP_ATOMIC_READ:
2591 pp_string (buffer, "#pragma omp atomic read");
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 break;
2599 case OMP_ATOMIC_CAPTURE_OLD:
2600 case OMP_ATOMIC_CAPTURE_NEW:
2601 pp_string (buffer, "#pragma omp atomic capture");
2602 if (OMP_ATOMIC_SEQ_CST (node))
2603 pp_string (buffer, " seq_cst");
2604 newline_and_indent (buffer, spc + 2);
2605 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2606 pp_space (buffer);
2607 pp_equal (buffer);
2608 pp_space (buffer);
2609 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2610 break;
2612 case OMP_SINGLE:
2613 pp_string (buffer, "#pragma omp single");
2614 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2615 goto dump_omp_body;
2617 case OMP_CLAUSE:
2618 dump_omp_clause (buffer, node, spc, flags);
2619 is_expr = false;
2620 break;
2622 case TRANSACTION_EXPR:
2623 if (TRANSACTION_EXPR_OUTER (node))
2624 pp_string (buffer, "__transaction_atomic [[outer]]");
2625 else if (TRANSACTION_EXPR_RELAXED (node))
2626 pp_string (buffer, "__transaction_relaxed");
2627 else
2628 pp_string (buffer, "__transaction_atomic");
2629 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2631 newline_and_indent (buffer, spc);
2632 pp_left_brace (buffer);
2633 newline_and_indent (buffer, spc + 2);
2634 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2635 spc + 2, flags, false);
2636 newline_and_indent (buffer, spc);
2637 pp_right_brace (buffer);
2639 is_expr = false;
2640 break;
2642 case REDUC_MAX_EXPR:
2643 pp_string (buffer, " REDUC_MAX_EXPR < ");
2644 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2645 pp_string (buffer, " > ");
2646 break;
2648 case REDUC_MIN_EXPR:
2649 pp_string (buffer, " REDUC_MIN_EXPR < ");
2650 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2651 pp_string (buffer, " > ");
2652 break;
2654 case REDUC_PLUS_EXPR:
2655 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2656 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2657 pp_string (buffer, " > ");
2658 break;
2660 case VEC_WIDEN_MULT_HI_EXPR:
2661 case VEC_WIDEN_MULT_LO_EXPR:
2662 case VEC_WIDEN_MULT_EVEN_EXPR:
2663 case VEC_WIDEN_MULT_ODD_EXPR:
2664 case VEC_WIDEN_LSHIFT_HI_EXPR:
2665 case VEC_WIDEN_LSHIFT_LO_EXPR:
2666 pp_space (buffer);
2667 for (str = get_tree_code_name (code); *str; str++)
2668 pp_character (buffer, TOUPPER (*str));
2669 pp_string (buffer, " < ");
2670 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2671 pp_string (buffer, ", ");
2672 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2673 pp_string (buffer, " > ");
2674 break;
2676 case VEC_UNPACK_HI_EXPR:
2677 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2678 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2679 pp_string (buffer, " > ");
2680 break;
2682 case VEC_UNPACK_LO_EXPR:
2683 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2684 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2685 pp_string (buffer, " > ");
2686 break;
2688 case VEC_UNPACK_FLOAT_HI_EXPR:
2689 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2690 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2691 pp_string (buffer, " > ");
2692 break;
2694 case VEC_UNPACK_FLOAT_LO_EXPR:
2695 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2696 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2697 pp_string (buffer, " > ");
2698 break;
2700 case VEC_PACK_TRUNC_EXPR:
2701 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2702 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2703 pp_string (buffer, ", ");
2704 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2705 pp_string (buffer, " > ");
2706 break;
2708 case VEC_PACK_SAT_EXPR:
2709 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2710 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2711 pp_string (buffer, ", ");
2712 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2713 pp_string (buffer, " > ");
2714 break;
2716 case VEC_PACK_FIX_TRUNC_EXPR:
2717 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2718 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2719 pp_string (buffer, ", ");
2720 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2721 pp_string (buffer, " > ");
2722 break;
2724 case BLOCK:
2725 dump_block_node (buffer, node, spc, flags);
2726 break;
2728 case CILK_SPAWN_STMT:
2729 pp_string (buffer, "_Cilk_spawn ");
2730 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2731 break;
2733 case CILK_SYNC_STMT:
2734 pp_string (buffer, "_Cilk_sync");
2735 break;
2737 default:
2738 NIY;
2741 if (is_stmt && is_expr)
2742 pp_semicolon (buffer);
2744 return spc;
2747 /* Print the declaration of a variable. */
2749 void
2750 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2752 INDENT (spc);
2754 if (TREE_CODE(t) == NAMELIST_DECL)
2756 pp_string(buffer, "namelist ");
2757 dump_decl_name (buffer, t, flags);
2758 pp_semicolon (buffer);
2759 return;
2762 if (TREE_CODE (t) == TYPE_DECL)
2763 pp_string (buffer, "typedef ");
2765 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2766 pp_string (buffer, "register ");
2768 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2769 pp_string (buffer, "extern ");
2770 else if (TREE_STATIC (t))
2771 pp_string (buffer, "static ");
2773 /* Print the type and name. */
2774 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2776 tree tmp;
2778 /* Print array's type. */
2779 tmp = TREE_TYPE (t);
2780 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2781 tmp = TREE_TYPE (tmp);
2782 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2784 /* Print variable's name. */
2785 pp_space (buffer);
2786 dump_generic_node (buffer, t, spc, flags, false);
2788 /* Print the dimensions. */
2789 tmp = TREE_TYPE (t);
2790 while (TREE_CODE (tmp) == ARRAY_TYPE)
2792 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2793 tmp = TREE_TYPE (tmp);
2796 else if (TREE_CODE (t) == FUNCTION_DECL)
2798 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2799 pp_space (buffer);
2800 dump_decl_name (buffer, t, flags);
2801 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2803 else
2805 /* Print type declaration. */
2806 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2808 /* Print variable's name. */
2809 pp_space (buffer);
2810 dump_generic_node (buffer, t, spc, flags, false);
2813 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2815 pp_string (buffer, " __asm__ ");
2816 pp_left_paren (buffer);
2817 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2818 pp_right_paren (buffer);
2821 /* The initial value of a function serves to determine whether the function
2822 is declared or defined. So the following does not apply to function
2823 nodes. */
2824 if (TREE_CODE (t) != FUNCTION_DECL)
2826 /* Print the initial value. */
2827 if (DECL_INITIAL (t))
2829 pp_space (buffer);
2830 pp_equal (buffer);
2831 pp_space (buffer);
2832 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2836 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2838 pp_string (buffer, " [value-expr: ");
2839 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2840 pp_right_bracket (buffer);
2843 pp_semicolon (buffer);
2847 /* Prints a structure: name, fields, and methods.
2848 FIXME: Still incomplete. */
2850 static void
2851 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2853 /* Print the name of the structure. */
2854 if (TYPE_NAME (node))
2856 INDENT (spc);
2857 if (TREE_CODE (node) == RECORD_TYPE)
2858 pp_string (buffer, "struct ");
2859 else if ((TREE_CODE (node) == UNION_TYPE
2860 || TREE_CODE (node) == QUAL_UNION_TYPE))
2861 pp_string (buffer, "union ");
2863 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2866 /* Print the contents of the structure. */
2867 pp_newline (buffer);
2868 INDENT (spc);
2869 pp_left_brace (buffer);
2870 pp_newline (buffer);
2872 /* Print the fields of the structure. */
2874 tree tmp;
2875 tmp = TYPE_FIELDS (node);
2876 while (tmp)
2878 /* Avoid to print recursively the structure. */
2879 /* FIXME : Not implemented correctly...,
2880 what about the case when we have a cycle in the contain graph? ...
2881 Maybe this could be solved by looking at the scope in which the
2882 structure was declared. */
2883 if (TREE_TYPE (tmp) != node
2884 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2885 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2887 print_declaration (buffer, tmp, spc+2, flags);
2888 pp_newline (buffer);
2890 tmp = DECL_CHAIN (tmp);
2893 INDENT (spc);
2894 pp_right_brace (buffer);
2897 /* Return the priority of the operator CODE.
2899 From lowest to highest precedence with either left-to-right (L-R)
2900 or right-to-left (R-L) associativity]:
2902 1 [L-R] ,
2903 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2904 3 [R-L] ?:
2905 4 [L-R] ||
2906 5 [L-R] &&
2907 6 [L-R] |
2908 7 [L-R] ^
2909 8 [L-R] &
2910 9 [L-R] == !=
2911 10 [L-R] < <= > >=
2912 11 [L-R] << >>
2913 12 [L-R] + -
2914 13 [L-R] * / %
2915 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2916 15 [L-R] fn() [] -> .
2918 unary +, - and * have higher precedence than the corresponding binary
2919 operators. */
2922 op_code_prio (enum tree_code code)
2924 switch (code)
2926 case TREE_LIST:
2927 case COMPOUND_EXPR:
2928 case BIND_EXPR:
2929 return 1;
2931 case MODIFY_EXPR:
2932 case INIT_EXPR:
2933 return 2;
2935 case COND_EXPR:
2936 return 3;
2938 case TRUTH_OR_EXPR:
2939 case TRUTH_ORIF_EXPR:
2940 return 4;
2942 case TRUTH_AND_EXPR:
2943 case TRUTH_ANDIF_EXPR:
2944 return 5;
2946 case BIT_IOR_EXPR:
2947 return 6;
2949 case BIT_XOR_EXPR:
2950 case TRUTH_XOR_EXPR:
2951 return 7;
2953 case BIT_AND_EXPR:
2954 return 8;
2956 case EQ_EXPR:
2957 case NE_EXPR:
2958 return 9;
2960 case UNLT_EXPR:
2961 case UNLE_EXPR:
2962 case UNGT_EXPR:
2963 case UNGE_EXPR:
2964 case UNEQ_EXPR:
2965 case LTGT_EXPR:
2966 case ORDERED_EXPR:
2967 case UNORDERED_EXPR:
2968 case LT_EXPR:
2969 case LE_EXPR:
2970 case GT_EXPR:
2971 case GE_EXPR:
2972 return 10;
2974 case LSHIFT_EXPR:
2975 case RSHIFT_EXPR:
2976 case LROTATE_EXPR:
2977 case RROTATE_EXPR:
2978 case VEC_WIDEN_LSHIFT_HI_EXPR:
2979 case VEC_WIDEN_LSHIFT_LO_EXPR:
2980 case WIDEN_LSHIFT_EXPR:
2981 return 11;
2983 case WIDEN_SUM_EXPR:
2984 case PLUS_EXPR:
2985 case POINTER_PLUS_EXPR:
2986 case MINUS_EXPR:
2987 return 12;
2989 case VEC_WIDEN_MULT_HI_EXPR:
2990 case VEC_WIDEN_MULT_LO_EXPR:
2991 case WIDEN_MULT_EXPR:
2992 case DOT_PROD_EXPR:
2993 case WIDEN_MULT_PLUS_EXPR:
2994 case WIDEN_MULT_MINUS_EXPR:
2995 case MULT_EXPR:
2996 case MULT_HIGHPART_EXPR:
2997 case TRUNC_DIV_EXPR:
2998 case CEIL_DIV_EXPR:
2999 case FLOOR_DIV_EXPR:
3000 case ROUND_DIV_EXPR:
3001 case RDIV_EXPR:
3002 case EXACT_DIV_EXPR:
3003 case TRUNC_MOD_EXPR:
3004 case CEIL_MOD_EXPR:
3005 case FLOOR_MOD_EXPR:
3006 case ROUND_MOD_EXPR:
3007 case FMA_EXPR:
3008 return 13;
3010 case TRUTH_NOT_EXPR:
3011 case BIT_NOT_EXPR:
3012 case POSTINCREMENT_EXPR:
3013 case POSTDECREMENT_EXPR:
3014 case PREINCREMENT_EXPR:
3015 case PREDECREMENT_EXPR:
3016 case NEGATE_EXPR:
3017 case INDIRECT_REF:
3018 case ADDR_EXPR:
3019 case FLOAT_EXPR:
3020 CASE_CONVERT:
3021 case FIX_TRUNC_EXPR:
3022 case TARGET_EXPR:
3023 return 14;
3025 case CALL_EXPR:
3026 case ARRAY_REF:
3027 case ARRAY_RANGE_REF:
3028 case COMPONENT_REF:
3029 return 15;
3031 /* Special expressions. */
3032 case MIN_EXPR:
3033 case MAX_EXPR:
3034 case ABS_EXPR:
3035 case REALPART_EXPR:
3036 case IMAGPART_EXPR:
3037 case REDUC_MAX_EXPR:
3038 case REDUC_MIN_EXPR:
3039 case REDUC_PLUS_EXPR:
3040 case VEC_UNPACK_HI_EXPR:
3041 case VEC_UNPACK_LO_EXPR:
3042 case VEC_UNPACK_FLOAT_HI_EXPR:
3043 case VEC_UNPACK_FLOAT_LO_EXPR:
3044 case VEC_PACK_TRUNC_EXPR:
3045 case VEC_PACK_SAT_EXPR:
3046 return 16;
3048 default:
3049 /* Return an arbitrarily high precedence to avoid surrounding single
3050 VAR_DECLs in ()s. */
3051 return 9999;
3055 /* Return the priority of the operator OP. */
3058 op_prio (const_tree op)
3060 enum tree_code code;
3062 if (op == NULL)
3063 return 9999;
3065 code = TREE_CODE (op);
3066 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3067 return op_prio (TREE_OPERAND (op, 0));
3069 return op_code_prio (code);
3072 /* Return the symbol associated with operator CODE. */
3074 const char *
3075 op_symbol_code (enum tree_code code)
3077 switch (code)
3079 case MODIFY_EXPR:
3080 return "=";
3082 case TRUTH_OR_EXPR:
3083 case TRUTH_ORIF_EXPR:
3084 return "||";
3086 case TRUTH_AND_EXPR:
3087 case TRUTH_ANDIF_EXPR:
3088 return "&&";
3090 case BIT_IOR_EXPR:
3091 return "|";
3093 case TRUTH_XOR_EXPR:
3094 case BIT_XOR_EXPR:
3095 return "^";
3097 case ADDR_EXPR:
3098 case BIT_AND_EXPR:
3099 return "&";
3101 case ORDERED_EXPR:
3102 return "ord";
3103 case UNORDERED_EXPR:
3104 return "unord";
3106 case EQ_EXPR:
3107 return "==";
3108 case UNEQ_EXPR:
3109 return "u==";
3111 case NE_EXPR:
3112 return "!=";
3114 case LT_EXPR:
3115 return "<";
3116 case UNLT_EXPR:
3117 return "u<";
3119 case LE_EXPR:
3120 return "<=";
3121 case UNLE_EXPR:
3122 return "u<=";
3124 case GT_EXPR:
3125 return ">";
3126 case UNGT_EXPR:
3127 return "u>";
3129 case GE_EXPR:
3130 return ">=";
3131 case UNGE_EXPR:
3132 return "u>=";
3134 case LTGT_EXPR:
3135 return "<>";
3137 case LSHIFT_EXPR:
3138 return "<<";
3140 case RSHIFT_EXPR:
3141 return ">>";
3143 case LROTATE_EXPR:
3144 return "r<<";
3146 case RROTATE_EXPR:
3147 return "r>>";
3149 case WIDEN_LSHIFT_EXPR:
3150 return "w<<";
3152 case POINTER_PLUS_EXPR:
3153 return "+";
3155 case PLUS_EXPR:
3156 return "+";
3158 case REDUC_PLUS_EXPR:
3159 return "r+";
3161 case WIDEN_SUM_EXPR:
3162 return "w+";
3164 case WIDEN_MULT_EXPR:
3165 return "w*";
3167 case MULT_HIGHPART_EXPR:
3168 return "h*";
3170 case NEGATE_EXPR:
3171 case MINUS_EXPR:
3172 return "-";
3174 case BIT_NOT_EXPR:
3175 return "~";
3177 case TRUTH_NOT_EXPR:
3178 return "!";
3180 case MULT_EXPR:
3181 case INDIRECT_REF:
3182 return "*";
3184 case TRUNC_DIV_EXPR:
3185 case RDIV_EXPR:
3186 return "/";
3188 case CEIL_DIV_EXPR:
3189 return "/[cl]";
3191 case FLOOR_DIV_EXPR:
3192 return "/[fl]";
3194 case ROUND_DIV_EXPR:
3195 return "/[rd]";
3197 case EXACT_DIV_EXPR:
3198 return "/[ex]";
3200 case TRUNC_MOD_EXPR:
3201 return "%";
3203 case CEIL_MOD_EXPR:
3204 return "%[cl]";
3206 case FLOOR_MOD_EXPR:
3207 return "%[fl]";
3209 case ROUND_MOD_EXPR:
3210 return "%[rd]";
3212 case PREDECREMENT_EXPR:
3213 return " --";
3215 case PREINCREMENT_EXPR:
3216 return " ++";
3218 case POSTDECREMENT_EXPR:
3219 return "-- ";
3221 case POSTINCREMENT_EXPR:
3222 return "++ ";
3224 case MAX_EXPR:
3225 return "max";
3227 case MIN_EXPR:
3228 return "min";
3230 default:
3231 return "<<< ??? >>>";
3235 /* Return the symbol associated with operator OP. */
3237 static const char *
3238 op_symbol (const_tree op)
3240 return op_symbol_code (TREE_CODE (op));
3243 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3244 the gimple_call_fn of a GIMPLE_CALL. */
3246 void
3247 print_call_name (pretty_printer *buffer, tree node, int flags)
3249 tree op0 = node;
3251 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3252 op0 = TREE_OPERAND (op0, 0);
3254 again:
3255 switch (TREE_CODE (op0))
3257 case VAR_DECL:
3258 case PARM_DECL:
3259 case FUNCTION_DECL:
3260 dump_function_name (buffer, op0, flags);
3261 break;
3263 case ADDR_EXPR:
3264 case INDIRECT_REF:
3265 CASE_CONVERT:
3266 op0 = TREE_OPERAND (op0, 0);
3267 goto again;
3269 case COND_EXPR:
3270 pp_left_paren (buffer);
3271 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3272 pp_string (buffer, ") ? ");
3273 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3274 pp_string (buffer, " : ");
3275 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3276 break;
3278 case ARRAY_REF:
3279 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3280 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3281 else
3282 dump_generic_node (buffer, op0, 0, flags, false);
3283 break;
3285 case MEM_REF:
3286 if (integer_zerop (TREE_OPERAND (op0, 1)))
3288 op0 = TREE_OPERAND (op0, 0);
3289 goto again;
3291 /* Fallthru. */
3292 case COMPONENT_REF:
3293 case SSA_NAME:
3294 case OBJ_TYPE_REF:
3295 dump_generic_node (buffer, op0, 0, flags, false);
3296 break;
3298 default:
3299 NIY;
3303 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3305 static void
3306 pretty_print_string (pretty_printer *buffer, const char *str)
3308 if (str == NULL)
3309 return;
3311 while (*str)
3313 switch (str[0])
3315 case '\b':
3316 pp_string (buffer, "\\b");
3317 break;
3319 case '\f':
3320 pp_string (buffer, "\\f");
3321 break;
3323 case '\n':
3324 pp_string (buffer, "\\n");
3325 break;
3327 case '\r':
3328 pp_string (buffer, "\\r");
3329 break;
3331 case '\t':
3332 pp_string (buffer, "\\t");
3333 break;
3335 case '\v':
3336 pp_string (buffer, "\\v");
3337 break;
3339 case '\\':
3340 pp_string (buffer, "\\\\");
3341 break;
3343 case '\"':
3344 pp_string (buffer, "\\\"");
3345 break;
3347 case '\'':
3348 pp_string (buffer, "\\'");
3349 break;
3351 /* No need to handle \0; the loop terminates on \0. */
3353 case '\1':
3354 pp_string (buffer, "\\1");
3355 break;
3357 case '\2':
3358 pp_string (buffer, "\\2");
3359 break;
3361 case '\3':
3362 pp_string (buffer, "\\3");
3363 break;
3365 case '\4':
3366 pp_string (buffer, "\\4");
3367 break;
3369 case '\5':
3370 pp_string (buffer, "\\5");
3371 break;
3373 case '\6':
3374 pp_string (buffer, "\\6");
3375 break;
3377 case '\7':
3378 pp_string (buffer, "\\7");
3379 break;
3381 default:
3382 pp_character (buffer, str[0]);
3383 break;
3385 str++;
3389 static void
3390 maybe_init_pretty_print (FILE *file)
3392 if (!initialized)
3394 new (&buffer) pretty_printer ();
3395 pp_needs_newline (&buffer) = true;
3396 pp_translate_identifiers (&buffer) = false;
3397 initialized = 1;
3400 buffer.buffer->stream = file;
3403 static void
3404 newline_and_indent (pretty_printer *buffer, int spc)
3406 pp_newline (buffer);
3407 INDENT (spc);
3410 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3411 it can also be used in front ends.
3412 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3415 void
3416 percent_K_format (text_info *text)
3418 tree t = va_arg (*text->args_ptr, tree), block;
3419 gcc_assert (text->locus != NULL);
3420 *text->locus = EXPR_LOCATION (t);
3421 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3422 block = TREE_BLOCK (t);
3423 *pp_ti_abstract_origin (text) = NULL;
3425 if (in_lto_p)
3427 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3428 representing the outermost block of an inlined function.
3429 So walk the BLOCK tree until we hit such a scope. */
3430 while (block
3431 && TREE_CODE (block) == BLOCK)
3433 if (inlined_function_outer_scope_p (block))
3435 *pp_ti_abstract_origin (text) = block;
3436 break;
3438 block = BLOCK_SUPERCONTEXT (block);
3440 return;
3443 while (block
3444 && TREE_CODE (block) == BLOCK
3445 && BLOCK_ABSTRACT_ORIGIN (block))
3447 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3449 while (TREE_CODE (ao) == BLOCK
3450 && BLOCK_ABSTRACT_ORIGIN (ao)
3451 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3452 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3454 if (TREE_CODE (ao) == FUNCTION_DECL)
3456 *pp_ti_abstract_origin (text) = block;
3457 break;
3459 block = BLOCK_SUPERCONTEXT (block);
3463 /* Print the identifier ID to PRETTY-PRINTER. */
3465 void
3466 pp_tree_identifier (pretty_printer *pp, tree id)
3468 if (pp_translate_identifiers (pp))
3470 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3471 pp_append_text (pp, text, text + strlen (text));
3473 else
3474 pp_append_text (pp, IDENTIFIER_POINTER (id),
3475 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3478 /* A helper function that is used to dump function information before the
3479 function dump. */
3481 void
3482 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3484 const char *dname, *aname;
3485 struct cgraph_node *node = cgraph_node::get (fdecl);
3486 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3488 dname = lang_hooks.decl_printable_name (fdecl, 2);
3490 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3491 aname = (IDENTIFIER_POINTER
3492 (DECL_ASSEMBLER_NAME (fdecl)));
3493 else
3494 aname = "<unset-asm-name>";
3496 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3497 dname, aname, fun->funcdef_no);
3498 if (!(flags & TDF_NOUID))
3499 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3500 if (node)
3502 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3503 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3504 node->frequency == NODE_FREQUENCY_HOT
3505 ? " (hot)"
3506 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3507 ? " (unlikely executed)"
3508 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3509 ? " (executed once)"
3510 : "");
3512 else
3513 fprintf (dump_file, ")\n\n");
3516 /* Dump double_int D to pretty_printer PP. UNS is true
3517 if D is unsigned and false otherwise. */
3518 void
3519 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3521 if (d.fits_shwi ())
3522 pp_wide_integer (pp, d.low);
3523 else if (d.fits_uhwi ())
3524 pp_unsigned_wide_integer (pp, d.low);
3525 else
3527 unsigned HOST_WIDE_INT low = d.low;
3528 HOST_WIDE_INT high = d.high;
3529 if (!uns && d.is_negative ())
3531 pp_minus (pp);
3532 high = ~high + !low;
3533 low = -low;
3535 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3536 systems? */
3537 sprintf (pp_buffer (pp)->digit_buffer,
3538 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3539 (unsigned HOST_WIDE_INT) high, low);
3540 pp_string (pp, pp_buffer (pp)->digit_buffer);