/cp
[official-gcc.git] / gcc / tree-pretty-print.c
blobeb361c0ac24ed71e0f74d5dd44c74998a9b66e6c
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "alias.h"
26 #include "symtab.h"
27 #include "tree.h"
28 #include "stor-layout.h"
29 #include "hard-reg-set.h"
30 #include "function.h"
31 #include "rtl.h"
32 #include "flags.h"
33 #include "insn-config.h"
34 #include "expmed.h"
35 #include "dojump.h"
36 #include "explow.h"
37 #include "calls.h"
38 #include "emit-rtl.h"
39 #include "varasm.h"
40 #include "stmt.h"
41 #include "expr.h"
42 #include "tree-pretty-print.h"
43 #include "gimple-expr.h"
44 #include "predict.h"
45 #include "cgraph.h"
46 #include "langhooks.h"
47 #include "tree-iterator.h"
48 #include "tree-chrec.h"
49 #include "dumpfile.h"
50 #include "value-prof.h"
51 #include "wide-int-print.h"
52 #include "internal-fn.h"
53 #include "gomp-constants.h"
55 /* Local functions, macros and variables. */
56 static const char *op_symbol (const_tree);
57 static void pretty_print_string (pretty_printer *, const char*);
58 static void newline_and_indent (pretty_printer *, int);
59 static void maybe_init_pretty_print (FILE *);
60 static void print_struct_decl (pretty_printer *, const_tree, int, int);
61 static void do_niy (pretty_printer *, const_tree);
63 #define INDENT(SPACE) do { \
64 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
66 #define NIY do_niy (pp, node)
68 static pretty_printer *tree_pp;
70 /* Try to print something for an unknown tree code. */
72 static void
73 do_niy (pretty_printer *pp, const_tree node)
75 int i, len;
77 pp_string (pp, "<<< Unknown tree: ");
78 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
80 if (EXPR_P (node))
82 len = TREE_OPERAND_LENGTH (node);
83 for (i = 0; i < len; ++i)
85 newline_and_indent (pp, 2);
86 dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false);
90 pp_string (pp, " >>>");
93 /* Debugging function to print out a generic expression. */
95 DEBUG_FUNCTION void
96 debug_generic_expr (tree t)
98 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
99 fprintf (stderr, "\n");
102 /* Debugging function to print out a generic statement. */
104 DEBUG_FUNCTION void
105 debug_generic_stmt (tree t)
107 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
108 fprintf (stderr, "\n");
111 /* Debugging function to print out a chain of trees . */
113 DEBUG_FUNCTION void
114 debug_tree_chain (tree t)
116 hash_set<tree> seen;
118 while (t)
120 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
121 fprintf (stderr, " ");
122 t = TREE_CHAIN (t);
123 if (seen.add (t))
125 fprintf (stderr, "... [cycled back to ");
126 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
127 fprintf (stderr, "]");
128 break;
131 fprintf (stderr, "\n");
134 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
135 void
136 print_generic_decl (FILE *file, tree decl, int flags)
138 maybe_init_pretty_print (file);
139 print_declaration (tree_pp, decl, 2, flags);
140 pp_write_text_to_stream (tree_pp);
143 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
144 to show in the dump. See TDF_* in dumpfile.h. */
146 void
147 print_generic_stmt (FILE *file, tree t, int flags)
149 maybe_init_pretty_print (file);
150 dump_generic_node (tree_pp, t, 0, flags, true);
151 pp_newline_and_flush (tree_pp);
154 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
155 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
156 INDENT spaces. */
158 void
159 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
161 int i;
163 maybe_init_pretty_print (file);
165 for (i = 0; i < indent; i++)
166 pp_space (tree_pp);
167 dump_generic_node (tree_pp, t, indent, flags, true);
168 pp_newline_and_flush (tree_pp);
171 /* Print a single expression T on file FILE. FLAGS specifies details to show
172 in the dump. See TDF_* in dumpfile.h. */
174 void
175 print_generic_expr (FILE *file, tree t, int flags)
177 maybe_init_pretty_print (file);
178 dump_generic_node (tree_pp, t, 0, flags, false);
179 pp_flush (tree_pp);
182 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
183 in FLAGS. */
185 static void
186 dump_decl_name (pretty_printer *pp, tree node, int flags)
188 if (DECL_NAME (node))
190 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
191 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
192 else
193 pp_tree_identifier (pp, DECL_NAME (node));
195 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
197 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
198 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
199 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
201 if (flags & TDF_NOUID)
202 pp_string (pp, "D#xxxx");
203 else
204 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
206 else
208 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
209 if (flags & TDF_NOUID)
210 pp_printf (pp, "%c.xxxx", c);
211 else
212 pp_printf (pp, "%c.%u", c, DECL_UID (node));
215 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
217 if (flags & TDF_NOUID)
218 pp_printf (pp, "ptD.xxxx");
219 else
220 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
224 /* Like the above, but used for pretty printing function calls. */
226 static void
227 dump_function_name (pretty_printer *pp, tree node, int flags)
229 if (CONVERT_EXPR_P (node))
230 node = TREE_OPERAND (node, 0);
231 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
232 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
233 else
234 dump_decl_name (pp, node, flags);
237 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
238 FLAGS are as in dump_generic_node. */
240 static void
241 dump_function_declaration (pretty_printer *pp, tree node,
242 int spc, int flags)
244 bool wrote_arg = false;
245 tree arg;
247 pp_space (pp);
248 pp_left_paren (pp);
250 /* Print the argument types. */
251 arg = TYPE_ARG_TYPES (node);
252 while (arg && arg != void_list_node && arg != error_mark_node)
254 if (wrote_arg)
256 pp_comma (pp);
257 pp_space (pp);
259 wrote_arg = true;
260 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
261 arg = TREE_CHAIN (arg);
264 /* Drop the trailing void_type_node if we had any previous argument. */
265 if (arg == void_list_node && !wrote_arg)
266 pp_string (pp, "void");
267 /* Properly dump vararg function types. */
268 else if (!arg && wrote_arg)
269 pp_string (pp, ", ...");
270 /* Avoid printing any arg for unprototyped functions. */
272 pp_right_paren (pp);
275 /* Dump the domain associated with an array. */
277 static void
278 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
280 pp_left_bracket (pp);
281 if (domain)
283 tree min = TYPE_MIN_VALUE (domain);
284 tree max = TYPE_MAX_VALUE (domain);
286 if (min && max
287 && integer_zerop (min)
288 && tree_fits_shwi_p (max))
289 pp_wide_integer (pp, tree_to_shwi (max) + 1);
290 else
292 if (min)
293 dump_generic_node (pp, min, spc, flags, false);
294 pp_colon (pp);
295 if (max)
296 dump_generic_node (pp, max, spc, flags, false);
299 else
300 pp_string (pp, "<unknown>");
301 pp_right_bracket (pp);
305 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
306 dump_generic_node. */
308 static void
309 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
311 const char *name;
313 switch (OMP_CLAUSE_CODE (clause))
315 case OMP_CLAUSE_PRIVATE:
316 name = "private";
317 goto print_remap;
318 case OMP_CLAUSE_SHARED:
319 name = "shared";
320 goto print_remap;
321 case OMP_CLAUSE_FIRSTPRIVATE:
322 name = "firstprivate";
323 goto print_remap;
324 case OMP_CLAUSE_LASTPRIVATE:
325 name = "lastprivate";
326 goto print_remap;
327 case OMP_CLAUSE_COPYIN:
328 name = "copyin";
329 goto print_remap;
330 case OMP_CLAUSE_COPYPRIVATE:
331 name = "copyprivate";
332 goto print_remap;
333 case OMP_CLAUSE_UNIFORM:
334 name = "uniform";
335 goto print_remap;
336 case OMP_CLAUSE__LOOPTEMP_:
337 name = "_looptemp_";
338 goto print_remap;
339 case OMP_CLAUSE_DEVICE_RESIDENT:
340 name = "device_resident";
341 goto print_remap;
342 case OMP_CLAUSE_USE_DEVICE:
343 name = "use_device";
344 goto print_remap;
345 print_remap:
346 pp_string (pp, name);
347 pp_left_paren (pp);
348 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
349 spc, flags, false);
350 pp_right_paren (pp);
351 break;
353 case OMP_CLAUSE_REDUCTION:
354 pp_string (pp, "reduction(");
355 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
357 pp_string (pp,
358 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
359 pp_colon (pp);
361 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
362 spc, flags, false);
363 pp_right_paren (pp);
364 break;
366 case OMP_CLAUSE_IF:
367 pp_string (pp, "if(");
368 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
369 spc, flags, false);
370 pp_right_paren (pp);
371 break;
373 case OMP_CLAUSE_NUM_THREADS:
374 pp_string (pp, "num_threads(");
375 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
376 spc, flags, false);
377 pp_right_paren (pp);
378 break;
380 case OMP_CLAUSE__CILK_FOR_COUNT_:
381 pp_string (pp, "_Cilk_for_count_(");
382 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
383 spc, flags, false);
384 pp_right_paren (pp);
385 break;
387 case OMP_CLAUSE_NOWAIT:
388 pp_string (pp, "nowait");
389 break;
390 case OMP_CLAUSE_ORDERED:
391 pp_string (pp, "ordered");
392 break;
394 case OMP_CLAUSE_DEFAULT:
395 pp_string (pp, "default(");
396 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
398 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
399 break;
400 case OMP_CLAUSE_DEFAULT_SHARED:
401 pp_string (pp, "shared");
402 break;
403 case OMP_CLAUSE_DEFAULT_NONE:
404 pp_string (pp, "none");
405 break;
406 case OMP_CLAUSE_DEFAULT_PRIVATE:
407 pp_string (pp, "private");
408 break;
409 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
410 pp_string (pp, "firstprivate");
411 break;
412 default:
413 gcc_unreachable ();
415 pp_right_paren (pp);
416 break;
418 case OMP_CLAUSE_SCHEDULE:
419 pp_string (pp, "schedule(");
420 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
422 case OMP_CLAUSE_SCHEDULE_STATIC:
423 pp_string (pp, "static");
424 break;
425 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
426 pp_string (pp, "dynamic");
427 break;
428 case OMP_CLAUSE_SCHEDULE_GUIDED:
429 pp_string (pp, "guided");
430 break;
431 case OMP_CLAUSE_SCHEDULE_RUNTIME:
432 pp_string (pp, "runtime");
433 break;
434 case OMP_CLAUSE_SCHEDULE_AUTO:
435 pp_string (pp, "auto");
436 break;
437 case OMP_CLAUSE_SCHEDULE_CILKFOR:
438 pp_string (pp, "cilk-for grain");
439 break;
440 default:
441 gcc_unreachable ();
443 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
445 pp_comma (pp);
446 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
447 spc, flags, false);
449 pp_right_paren (pp);
450 break;
452 case OMP_CLAUSE_UNTIED:
453 pp_string (pp, "untied");
454 break;
456 case OMP_CLAUSE_COLLAPSE:
457 pp_string (pp, "collapse(");
458 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
459 spc, flags, false);
460 pp_right_paren (pp);
461 break;
463 case OMP_CLAUSE_FINAL:
464 pp_string (pp, "final(");
465 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
466 spc, flags, false);
467 pp_right_paren (pp);
468 break;
470 case OMP_CLAUSE_MERGEABLE:
471 pp_string (pp, "mergeable");
472 break;
474 case OMP_CLAUSE_LINEAR:
475 pp_string (pp, "linear(");
476 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
477 spc, flags, false);
478 pp_colon (pp);
479 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
480 spc, flags, false);
481 pp_right_paren (pp);
482 break;
484 case OMP_CLAUSE_ALIGNED:
485 pp_string (pp, "aligned(");
486 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
487 spc, flags, false);
488 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
490 pp_colon (pp);
491 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
492 spc, flags, false);
494 pp_right_paren (pp);
495 break;
497 case OMP_CLAUSE_DEPEND:
498 pp_string (pp, "depend(");
499 switch (OMP_CLAUSE_DEPEND_KIND (clause))
501 case OMP_CLAUSE_DEPEND_IN:
502 pp_string (pp, "in");
503 break;
504 case OMP_CLAUSE_DEPEND_OUT:
505 pp_string (pp, "out");
506 break;
507 case OMP_CLAUSE_DEPEND_INOUT:
508 pp_string (pp, "inout");
509 break;
510 default:
511 gcc_unreachable ();
513 pp_colon (pp);
514 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
515 spc, flags, false);
516 pp_right_paren (pp);
517 break;
519 case OMP_CLAUSE_MAP:
520 pp_string (pp, "map(");
521 switch (OMP_CLAUSE_MAP_KIND (clause))
523 case GOMP_MAP_ALLOC:
524 case GOMP_MAP_POINTER:
525 pp_string (pp, "alloc");
526 break;
527 case GOMP_MAP_TO:
528 case GOMP_MAP_TO_PSET:
529 pp_string (pp, "to");
530 break;
531 case GOMP_MAP_FROM:
532 pp_string (pp, "from");
533 break;
534 case GOMP_MAP_TOFROM:
535 pp_string (pp, "tofrom");
536 break;
537 case GOMP_MAP_FORCE_ALLOC:
538 pp_string (pp, "force_alloc");
539 break;
540 case GOMP_MAP_FORCE_TO:
541 pp_string (pp, "force_to");
542 break;
543 case GOMP_MAP_FORCE_FROM:
544 pp_string (pp, "force_from");
545 break;
546 case GOMP_MAP_FORCE_TOFROM:
547 pp_string (pp, "force_tofrom");
548 break;
549 case GOMP_MAP_FORCE_PRESENT:
550 pp_string (pp, "force_present");
551 break;
552 case GOMP_MAP_FORCE_DEALLOC:
553 pp_string (pp, "force_dealloc");
554 break;
555 case GOMP_MAP_FORCE_DEVICEPTR:
556 pp_string (pp, "force_deviceptr");
557 break;
558 default:
559 gcc_unreachable ();
561 pp_colon (pp);
562 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
563 spc, flags, false);
564 print_clause_size:
565 if (OMP_CLAUSE_SIZE (clause))
567 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
568 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER)
569 pp_string (pp, " [pointer assign, bias: ");
570 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
571 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET)
572 pp_string (pp, " [pointer set, len: ");
573 else
574 pp_string (pp, " [len: ");
575 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
576 spc, flags, false);
577 pp_right_bracket (pp);
579 pp_right_paren (pp);
580 break;
582 case OMP_CLAUSE_FROM:
583 pp_string (pp, "from(");
584 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
585 spc, flags, false);
586 goto print_clause_size;
588 case OMP_CLAUSE_TO:
589 pp_string (pp, "to(");
590 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
591 spc, flags, false);
592 goto print_clause_size;
594 case OMP_CLAUSE__CACHE_:
595 pp_string (pp, "(");
596 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
597 spc, flags, false);
598 goto print_clause_size;
600 case OMP_CLAUSE_NUM_TEAMS:
601 pp_string (pp, "num_teams(");
602 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
603 spc, flags, false);
604 pp_right_paren (pp);
605 break;
607 case OMP_CLAUSE_THREAD_LIMIT:
608 pp_string (pp, "thread_limit(");
609 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
610 spc, flags, false);
611 pp_right_paren (pp);
612 break;
614 case OMP_CLAUSE_DEVICE:
615 pp_string (pp, "device(");
616 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
617 spc, flags, false);
618 pp_right_paren (pp);
619 break;
621 case OMP_CLAUSE_DIST_SCHEDULE:
622 pp_string (pp, "dist_schedule(static");
623 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
625 pp_comma (pp);
626 dump_generic_node (pp,
627 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
628 spc, flags, false);
630 pp_right_paren (pp);
631 break;
633 case OMP_CLAUSE_PROC_BIND:
634 pp_string (pp, "proc_bind(");
635 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
637 case OMP_CLAUSE_PROC_BIND_MASTER:
638 pp_string (pp, "master");
639 break;
640 case OMP_CLAUSE_PROC_BIND_CLOSE:
641 pp_string (pp, "close");
642 break;
643 case OMP_CLAUSE_PROC_BIND_SPREAD:
644 pp_string (pp, "spread");
645 break;
646 default:
647 gcc_unreachable ();
649 pp_right_paren (pp);
650 break;
652 case OMP_CLAUSE_SAFELEN:
653 pp_string (pp, "safelen(");
654 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
655 spc, flags, false);
656 pp_right_paren (pp);
657 break;
659 case OMP_CLAUSE_SIMDLEN:
660 pp_string (pp, "simdlen(");
661 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
662 spc, flags, false);
663 pp_right_paren (pp);
664 break;
666 case OMP_CLAUSE__SIMDUID_:
667 pp_string (pp, "_simduid_(");
668 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
669 spc, flags, false);
670 pp_right_paren (pp);
671 break;
673 case OMP_CLAUSE_GANG:
674 pp_string (pp, "gang");
675 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
677 pp_string (pp, "(num: ");
678 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
679 spc, flags, false);
681 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
683 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
684 pp_left_paren (pp);
685 else
686 pp_space (pp);
687 pp_string (pp, "static:");
688 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
689 == integer_minus_one_node)
690 pp_character (pp, '*');
691 else
692 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
693 spc, flags, false);
695 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
696 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
697 pp_right_paren (pp);
698 break;
700 case OMP_CLAUSE_ASYNC:
701 pp_string (pp, "async");
702 if (OMP_CLAUSE_ASYNC_EXPR (clause))
704 pp_character(pp, '(');
705 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
706 spc, flags, false);
707 pp_character(pp, ')');
709 break;
711 case OMP_CLAUSE_AUTO:
712 case OMP_CLAUSE_SEQ:
713 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
714 break;
716 case OMP_CLAUSE_WAIT:
717 pp_string (pp, "wait(");
718 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
719 spc, flags, false);
720 pp_character(pp, ')');
721 break;
723 case OMP_CLAUSE_WORKER:
724 pp_string (pp, "worker");
725 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
727 pp_left_paren (pp);
728 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
729 spc, flags, false);
730 pp_right_paren (pp);
732 break;
734 case OMP_CLAUSE_VECTOR:
735 pp_string (pp, "vector");
736 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
738 pp_left_paren (pp);
739 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
740 spc, flags, false);
741 pp_right_paren (pp);
743 break;
745 case OMP_CLAUSE_NUM_GANGS:
746 pp_string (pp, "num_gangs(");
747 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
748 spc, flags, false);
749 pp_character (pp, ')');
750 break;
752 case OMP_CLAUSE_NUM_WORKERS:
753 pp_string (pp, "num_workers(");
754 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
755 spc, flags, false);
756 pp_character (pp, ')');
757 break;
759 case OMP_CLAUSE_VECTOR_LENGTH:
760 pp_string (pp, "vector_length(");
761 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
762 spc, flags, false);
763 pp_character (pp, ')');
764 break;
766 case OMP_CLAUSE_INBRANCH:
767 pp_string (pp, "inbranch");
768 break;
769 case OMP_CLAUSE_NOTINBRANCH:
770 pp_string (pp, "notinbranch");
771 break;
772 case OMP_CLAUSE_FOR:
773 pp_string (pp, "for");
774 break;
775 case OMP_CLAUSE_PARALLEL:
776 pp_string (pp, "parallel");
777 break;
778 case OMP_CLAUSE_SECTIONS:
779 pp_string (pp, "sections");
780 break;
781 case OMP_CLAUSE_TASKGROUP:
782 pp_string (pp, "taskgroup");
783 break;
784 case OMP_CLAUSE_INDEPENDENT:
785 pp_string (pp, "independent");
786 break;
788 default:
789 /* Should never happen. */
790 dump_generic_node (pp, clause, spc, flags, false);
791 break;
796 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
797 dump_generic_node. */
799 void
800 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
802 if (clause == NULL)
803 return;
805 pp_space (pp);
806 while (1)
808 dump_omp_clause (pp, clause, spc, flags);
809 clause = OMP_CLAUSE_CHAIN (clause);
810 if (clause == NULL)
811 return;
812 pp_space (pp);
817 /* Dump location LOC to PP. */
819 void
820 dump_location (pretty_printer *pp, location_t loc)
822 expanded_location xloc = expand_location (loc);
824 pp_left_bracket (pp);
825 if (xloc.file)
827 pp_string (pp, xloc.file);
828 pp_string (pp, ":");
830 pp_decimal_int (pp, xloc.line);
831 pp_colon (pp);
832 pp_decimal_int (pp, xloc.column);
833 pp_string (pp, "] ");
837 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
838 dump_generic_node. */
840 static void
841 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
843 tree t;
845 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
847 if (flags & TDF_ADDRESS)
848 pp_printf (pp, "[%p] ", (void *) block);
850 if (BLOCK_ABSTRACT (block))
851 pp_string (pp, "[abstract] ");
853 if (TREE_ASM_WRITTEN (block))
854 pp_string (pp, "[written] ");
856 if (flags & TDF_SLIM)
857 return;
859 if (BLOCK_SOURCE_LOCATION (block))
860 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
862 newline_and_indent (pp, spc + 2);
864 if (BLOCK_SUPERCONTEXT (block))
866 pp_string (pp, "SUPERCONTEXT: ");
867 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
868 flags | TDF_SLIM, false);
869 newline_and_indent (pp, spc + 2);
872 if (BLOCK_SUBBLOCKS (block))
874 pp_string (pp, "SUBBLOCKS: ");
875 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
877 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
878 pp_space (pp);
880 newline_and_indent (pp, spc + 2);
883 if (BLOCK_CHAIN (block))
885 pp_string (pp, "SIBLINGS: ");
886 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
888 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
889 pp_space (pp);
891 newline_and_indent (pp, spc + 2);
894 if (BLOCK_VARS (block))
896 pp_string (pp, "VARS: ");
897 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
899 dump_generic_node (pp, t, 0, flags, false);
900 pp_space (pp);
902 newline_and_indent (pp, spc + 2);
905 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
907 unsigned i;
908 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
910 pp_string (pp, "NONLOCALIZED_VARS: ");
911 FOR_EACH_VEC_ELT (*nlv, i, t)
913 dump_generic_node (pp, t, 0, flags, false);
914 pp_space (pp);
916 newline_and_indent (pp, spc + 2);
919 if (BLOCK_ABSTRACT_ORIGIN (block))
921 pp_string (pp, "ABSTRACT_ORIGIN: ");
922 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
923 flags | TDF_SLIM, false);
924 newline_and_indent (pp, spc + 2);
927 if (BLOCK_FRAGMENT_ORIGIN (block))
929 pp_string (pp, "FRAGMENT_ORIGIN: ");
930 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
931 flags | TDF_SLIM, false);
932 newline_and_indent (pp, spc + 2);
935 if (BLOCK_FRAGMENT_CHAIN (block))
937 pp_string (pp, "FRAGMENT_CHAIN: ");
938 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
940 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
941 pp_space (pp);
943 newline_and_indent (pp, spc + 2);
948 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
949 indent. FLAGS specifies details to show in the dump (see TDF_* in
950 dumpfile.h). If IS_STMT is true, the object printed is considered
951 to be a statement and it is terminated by ';' if appropriate. */
954 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
955 bool is_stmt)
957 tree type;
958 tree op0, op1;
959 const char *str;
960 bool is_expr;
961 enum tree_code code;
963 if (node == NULL_TREE)
964 return spc;
966 is_expr = EXPR_P (node);
968 if (is_stmt && (flags & TDF_STMTADDR))
969 pp_printf (pp, "<&%p> ", (void *)node);
971 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
972 dump_location (pp, EXPR_LOCATION (node));
974 code = TREE_CODE (node);
975 switch (code)
977 case ERROR_MARK:
978 pp_string (pp, "<<< error >>>");
979 break;
981 case IDENTIFIER_NODE:
982 pp_tree_identifier (pp, node);
983 break;
985 case TREE_LIST:
986 while (node && node != error_mark_node)
988 if (TREE_PURPOSE (node))
990 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
991 pp_space (pp);
993 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
994 node = TREE_CHAIN (node);
995 if (node && TREE_CODE (node) == TREE_LIST)
997 pp_comma (pp);
998 pp_space (pp);
1001 break;
1003 case TREE_BINFO:
1004 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1005 break;
1007 case TREE_VEC:
1009 size_t i;
1010 if (TREE_VEC_LENGTH (node) > 0)
1012 size_t len = TREE_VEC_LENGTH (node);
1013 for (i = 0; i < len - 1; i++)
1015 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1016 false);
1017 pp_comma (pp);
1018 pp_space (pp);
1020 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1021 flags, false);
1024 break;
1026 case VOID_TYPE:
1027 case POINTER_BOUNDS_TYPE:
1028 case INTEGER_TYPE:
1029 case REAL_TYPE:
1030 case FIXED_POINT_TYPE:
1031 case COMPLEX_TYPE:
1032 case VECTOR_TYPE:
1033 case ENUMERAL_TYPE:
1034 case BOOLEAN_TYPE:
1036 unsigned int quals = TYPE_QUALS (node);
1037 enum tree_code_class tclass;
1039 if (quals & TYPE_QUAL_ATOMIC)
1040 pp_string (pp, "atomic ");
1041 if (quals & TYPE_QUAL_CONST)
1042 pp_string (pp, "const ");
1043 else if (quals & TYPE_QUAL_VOLATILE)
1044 pp_string (pp, "volatile ");
1045 else if (quals & TYPE_QUAL_RESTRICT)
1046 pp_string (pp, "restrict ");
1048 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1050 pp_string (pp, "<address-space-");
1051 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1052 pp_string (pp, "> ");
1055 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1057 if (tclass == tcc_declaration)
1059 if (DECL_NAME (node))
1060 dump_decl_name (pp, node, flags);
1061 else
1062 pp_string (pp, "<unnamed type decl>");
1064 else if (tclass == tcc_type)
1066 if (TYPE_NAME (node))
1068 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1069 pp_tree_identifier (pp, TYPE_NAME (node));
1070 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1071 && DECL_NAME (TYPE_NAME (node)))
1072 dump_decl_name (pp, TYPE_NAME (node), flags);
1073 else
1074 pp_string (pp, "<unnamed type>");
1076 else if (TREE_CODE (node) == VECTOR_TYPE)
1078 pp_string (pp, "vector");
1079 pp_left_paren (pp);
1080 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1081 pp_string (pp, ") ");
1082 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1084 else if (TREE_CODE (node) == INTEGER_TYPE)
1086 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1087 pp_string (pp, (TYPE_UNSIGNED (node)
1088 ? "unsigned char"
1089 : "signed char"));
1090 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1091 pp_string (pp, (TYPE_UNSIGNED (node)
1092 ? "unsigned short"
1093 : "signed short"));
1094 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1095 pp_string (pp, (TYPE_UNSIGNED (node)
1096 ? "unsigned int"
1097 : "signed int"));
1098 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1099 pp_string (pp, (TYPE_UNSIGNED (node)
1100 ? "unsigned long"
1101 : "signed long"));
1102 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1103 pp_string (pp, (TYPE_UNSIGNED (node)
1104 ? "unsigned long long"
1105 : "signed long long"));
1106 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1107 && exact_log2 (TYPE_PRECISION (node)) != -1)
1109 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1110 pp_decimal_int (pp, TYPE_PRECISION (node));
1111 pp_string (pp, "_t");
1113 else
1115 pp_string (pp, (TYPE_UNSIGNED (node)
1116 ? "<unnamed-unsigned:"
1117 : "<unnamed-signed:"));
1118 pp_decimal_int (pp, TYPE_PRECISION (node));
1119 pp_greater (pp);
1122 else if (TREE_CODE (node) == COMPLEX_TYPE)
1124 pp_string (pp, "__complex__ ");
1125 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1127 else if (TREE_CODE (node) == REAL_TYPE)
1129 pp_string (pp, "<float:");
1130 pp_decimal_int (pp, TYPE_PRECISION (node));
1131 pp_greater (pp);
1133 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1135 pp_string (pp, "<fixed-point-");
1136 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1137 pp_decimal_int (pp, TYPE_PRECISION (node));
1138 pp_greater (pp);
1140 else if (TREE_CODE (node) == VOID_TYPE)
1141 pp_string (pp, "void");
1142 else
1143 pp_string (pp, "<unnamed type>");
1145 break;
1148 case POINTER_TYPE:
1149 case REFERENCE_TYPE:
1150 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1152 if (TREE_TYPE (node) == NULL)
1154 pp_string (pp, str);
1155 pp_string (pp, "<null type>");
1157 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1159 tree fnode = TREE_TYPE (node);
1161 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1162 pp_space (pp);
1163 pp_left_paren (pp);
1164 pp_string (pp, str);
1165 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1166 dump_decl_name (pp, TYPE_NAME (node), flags);
1167 else if (flags & TDF_NOUID)
1168 pp_printf (pp, "<Txxxx>");
1169 else
1170 pp_printf (pp, "<T%x>", TYPE_UID (node));
1172 pp_right_paren (pp);
1173 dump_function_declaration (pp, fnode, spc, flags);
1175 else
1177 unsigned int quals = TYPE_QUALS (node);
1179 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1180 pp_space (pp);
1181 pp_string (pp, str);
1183 if (quals & TYPE_QUAL_CONST)
1184 pp_string (pp, " const");
1185 if (quals & TYPE_QUAL_VOLATILE)
1186 pp_string (pp, " volatile");
1187 if (quals & TYPE_QUAL_RESTRICT)
1188 pp_string (pp, " restrict");
1190 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1192 pp_string (pp, " <address-space-");
1193 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1194 pp_greater (pp);
1197 if (TYPE_REF_CAN_ALIAS_ALL (node))
1198 pp_string (pp, " {ref-all}");
1200 break;
1202 case OFFSET_TYPE:
1203 NIY;
1204 break;
1206 case MEM_REF:
1208 if (integer_zerop (TREE_OPERAND (node, 1))
1209 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1210 infer them and MEM_ATTR caching will share MEM_REFs
1211 with differently-typed op0s. */
1212 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1213 /* Released SSA_NAMES have no TREE_TYPE. */
1214 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1215 /* Same pointer types, but ignoring POINTER_TYPE vs.
1216 REFERENCE_TYPE. */
1217 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1218 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1219 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1220 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1221 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1222 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1223 /* Same value types ignoring qualifiers. */
1224 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1225 == TYPE_MAIN_VARIANT
1226 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1227 && (!(flags & TDF_ALIAS)
1228 || MR_DEPENDENCE_CLIQUE (node) == 0))
1230 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1232 pp_star (pp);
1233 dump_generic_node (pp, TREE_OPERAND (node, 0),
1234 spc, flags, false);
1236 else
1237 dump_generic_node (pp,
1238 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1239 spc, flags, false);
1241 else
1243 tree ptype;
1245 pp_string (pp, "MEM[");
1246 pp_left_paren (pp);
1247 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1248 dump_generic_node (pp, ptype,
1249 spc, flags | TDF_SLIM, false);
1250 pp_right_paren (pp);
1251 dump_generic_node (pp, TREE_OPERAND (node, 0),
1252 spc, flags, false);
1253 if (!integer_zerop (TREE_OPERAND (node, 1)))
1255 pp_string (pp, " + ");
1256 dump_generic_node (pp, TREE_OPERAND (node, 1),
1257 spc, flags, false);
1259 if ((flags & TDF_ALIAS)
1260 && MR_DEPENDENCE_CLIQUE (node) != 0)
1262 pp_string (pp, " clique ");
1263 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1264 pp_string (pp, " base ");
1265 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1267 pp_right_bracket (pp);
1269 break;
1272 case TARGET_MEM_REF:
1274 const char *sep = "";
1275 tree tmp;
1277 pp_string (pp, "MEM[");
1279 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1281 pp_string (pp, sep);
1282 sep = ", ";
1283 pp_string (pp, "symbol: ");
1284 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1285 spc, flags, false);
1287 else
1289 pp_string (pp, sep);
1290 sep = ", ";
1291 pp_string (pp, "base: ");
1292 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1294 tmp = TMR_INDEX2 (node);
1295 if (tmp)
1297 pp_string (pp, sep);
1298 sep = ", ";
1299 pp_string (pp, "base: ");
1300 dump_generic_node (pp, tmp, spc, flags, false);
1302 tmp = TMR_INDEX (node);
1303 if (tmp)
1305 pp_string (pp, sep);
1306 sep = ", ";
1307 pp_string (pp, "index: ");
1308 dump_generic_node (pp, tmp, spc, flags, false);
1310 tmp = TMR_STEP (node);
1311 if (tmp)
1313 pp_string (pp, sep);
1314 sep = ", ";
1315 pp_string (pp, "step: ");
1316 dump_generic_node (pp, tmp, spc, flags, false);
1318 tmp = TMR_OFFSET (node);
1319 if (tmp)
1321 pp_string (pp, sep);
1322 sep = ", ";
1323 pp_string (pp, "offset: ");
1324 dump_generic_node (pp, tmp, spc, flags, false);
1326 pp_right_bracket (pp);
1328 break;
1330 case ARRAY_TYPE:
1332 tree tmp;
1334 /* Print the innermost component type. */
1335 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1336 tmp = TREE_TYPE (tmp))
1338 dump_generic_node (pp, tmp, spc, flags, false);
1340 /* Print the dimensions. */
1341 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1342 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1343 break;
1346 case RECORD_TYPE:
1347 case UNION_TYPE:
1348 case QUAL_UNION_TYPE:
1350 unsigned int quals = TYPE_QUALS (node);
1352 if (quals & TYPE_QUAL_ATOMIC)
1353 pp_string (pp, "atomic ");
1354 if (quals & TYPE_QUAL_CONST)
1355 pp_string (pp, "const ");
1356 if (quals & TYPE_QUAL_VOLATILE)
1357 pp_string (pp, "volatile ");
1359 /* Print the name of the structure. */
1360 if (TREE_CODE (node) == RECORD_TYPE)
1361 pp_string (pp, "struct ");
1362 else if (TREE_CODE (node) == UNION_TYPE)
1363 pp_string (pp, "union ");
1365 if (TYPE_NAME (node))
1366 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1367 else if (!(flags & TDF_SLIM))
1368 /* FIXME: If we eliminate the 'else' above and attempt
1369 to show the fields for named types, we may get stuck
1370 following a cycle of pointers to structs. The alleged
1371 self-reference check in print_struct_decl will not detect
1372 cycles involving more than one pointer or struct type. */
1373 print_struct_decl (pp, node, spc, flags);
1374 break;
1377 case LANG_TYPE:
1378 NIY;
1379 break;
1381 case INTEGER_CST:
1382 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1384 /* In the case of a pointer, one may want to divide by the
1385 size of the pointed-to type. Unfortunately, this not
1386 straightforward. The C front-end maps expressions
1388 (int *) 5
1389 int *p; (p + 5)
1391 in such a way that the two INTEGER_CST nodes for "5" have
1392 different values but identical types. In the latter
1393 case, the 5 is multiplied by sizeof (int) in c-common.c
1394 (pointer_int_sum) to convert it to a byte address, and
1395 yet the type of the node is left unchanged. Argh. What
1396 is consistent though is that the number value corresponds
1397 to bytes (UNITS) offset.
1399 NB: Neither of the following divisors can be trivially
1400 used to recover the original literal:
1402 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1403 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1404 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1405 pp_string (pp, "B"); /* pseudo-unit */
1407 else if (tree_fits_shwi_p (node))
1408 pp_wide_integer (pp, tree_to_shwi (node));
1409 else if (tree_fits_uhwi_p (node))
1410 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1411 else
1413 wide_int val = node;
1415 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1417 pp_minus (pp);
1418 val = -val;
1420 print_hex (val, pp_buffer (pp)->digit_buffer);
1421 pp_string (pp, pp_buffer (pp)->digit_buffer);
1423 if (TREE_OVERFLOW (node))
1424 pp_string (pp, "(OVF)");
1425 break;
1427 case REAL_CST:
1428 /* Code copied from print_node. */
1430 REAL_VALUE_TYPE d;
1431 if (TREE_OVERFLOW (node))
1432 pp_string (pp, " overflow");
1434 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1435 d = TREE_REAL_CST (node);
1436 if (REAL_VALUE_ISINF (d))
1437 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1438 else if (REAL_VALUE_ISNAN (d))
1439 pp_string (pp, " Nan");
1440 else
1442 char string[100];
1443 real_to_decimal (string, &d, sizeof (string), 0, 1);
1444 pp_string (pp, string);
1446 #else
1448 HOST_WIDE_INT i;
1449 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1450 pp_string (pp, "0x");
1451 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1452 output_formatted_integer (pp, "%02x", *p++);
1454 #endif
1455 break;
1458 case FIXED_CST:
1460 char string[100];
1461 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1462 pp_string (pp, string);
1463 break;
1466 case COMPLEX_CST:
1467 pp_string (pp, "__complex__ (");
1468 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1469 pp_string (pp, ", ");
1470 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1471 pp_right_paren (pp);
1472 break;
1474 case STRING_CST:
1475 pp_string (pp, "\"");
1476 pretty_print_string (pp, TREE_STRING_POINTER (node));
1477 pp_string (pp, "\"");
1478 break;
1480 case VECTOR_CST:
1482 unsigned i;
1483 pp_string (pp, "{ ");
1484 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1486 if (i != 0)
1487 pp_string (pp, ", ");
1488 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1489 spc, flags, false);
1491 pp_string (pp, " }");
1493 break;
1495 case FUNCTION_TYPE:
1496 case METHOD_TYPE:
1497 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1498 pp_space (pp);
1499 if (TREE_CODE (node) == METHOD_TYPE)
1501 if (TYPE_METHOD_BASETYPE (node))
1502 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1503 flags);
1504 else
1505 pp_string (pp, "<null method basetype>");
1506 pp_colon_colon (pp);
1508 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1509 dump_decl_name (pp, TYPE_NAME (node), flags);
1510 else if (flags & TDF_NOUID)
1511 pp_printf (pp, "<Txxxx>");
1512 else
1513 pp_printf (pp, "<T%x>", TYPE_UID (node));
1514 dump_function_declaration (pp, node, spc, flags);
1515 break;
1517 case FUNCTION_DECL:
1518 case CONST_DECL:
1519 dump_decl_name (pp, node, flags);
1520 break;
1522 case LABEL_DECL:
1523 if (DECL_NAME (node))
1524 dump_decl_name (pp, node, flags);
1525 else if (LABEL_DECL_UID (node) != -1)
1526 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1527 else
1529 if (flags & TDF_NOUID)
1530 pp_string (pp, "<D.xxxx>");
1531 else
1532 pp_printf (pp, "<D.%u>", DECL_UID (node));
1534 break;
1536 case TYPE_DECL:
1537 if (DECL_IS_BUILTIN (node))
1539 /* Don't print the declaration of built-in types. */
1540 break;
1542 if (DECL_NAME (node))
1543 dump_decl_name (pp, node, flags);
1544 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1546 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1547 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1548 && TYPE_METHODS (TREE_TYPE (node)))
1550 /* The type is a c++ class: all structures have at least
1551 4 methods. */
1552 pp_string (pp, "class ");
1553 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1555 else
1557 pp_string (pp,
1558 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1559 ? "union" : "struct "));
1560 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1563 else
1564 pp_string (pp, "<anon>");
1565 break;
1567 case VAR_DECL:
1568 case PARM_DECL:
1569 case FIELD_DECL:
1570 case DEBUG_EXPR_DECL:
1571 case NAMESPACE_DECL:
1572 case NAMELIST_DECL:
1573 dump_decl_name (pp, node, flags);
1574 break;
1576 case RESULT_DECL:
1577 pp_string (pp, "<retval>");
1578 break;
1580 case COMPONENT_REF:
1581 op0 = TREE_OPERAND (node, 0);
1582 str = ".";
1583 if (op0
1584 && (TREE_CODE (op0) == INDIRECT_REF
1585 || (TREE_CODE (op0) == MEM_REF
1586 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1587 && integer_zerop (TREE_OPERAND (op0, 1))
1588 /* Dump the types of INTEGER_CSTs explicitly, for we
1589 can't infer them and MEM_ATTR caching will share
1590 MEM_REFs with differently-typed op0s. */
1591 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1592 /* Released SSA_NAMES have no TREE_TYPE. */
1593 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1594 /* Same pointer types, but ignoring POINTER_TYPE vs.
1595 REFERENCE_TYPE. */
1596 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1597 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1598 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1599 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1600 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1601 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1602 /* Same value types ignoring qualifiers. */
1603 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1604 == TYPE_MAIN_VARIANT
1605 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1606 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1608 op0 = TREE_OPERAND (op0, 0);
1609 str = "->";
1611 if (op_prio (op0) < op_prio (node))
1612 pp_left_paren (pp);
1613 dump_generic_node (pp, op0, spc, flags, false);
1614 if (op_prio (op0) < op_prio (node))
1615 pp_right_paren (pp);
1616 pp_string (pp, str);
1617 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1618 op0 = component_ref_field_offset (node);
1619 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1621 pp_string (pp, "{off: ");
1622 dump_generic_node (pp, op0, spc, flags, false);
1623 pp_right_brace (pp);
1625 break;
1627 case BIT_FIELD_REF:
1628 pp_string (pp, "BIT_FIELD_REF <");
1629 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1630 pp_string (pp, ", ");
1631 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1632 pp_string (pp, ", ");
1633 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1634 pp_greater (pp);
1635 break;
1637 case ARRAY_REF:
1638 case ARRAY_RANGE_REF:
1639 op0 = TREE_OPERAND (node, 0);
1640 if (op_prio (op0) < op_prio (node))
1641 pp_left_paren (pp);
1642 dump_generic_node (pp, op0, spc, flags, false);
1643 if (op_prio (op0) < op_prio (node))
1644 pp_right_paren (pp);
1645 pp_left_bracket (pp);
1646 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1647 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1648 pp_string (pp, " ...");
1649 pp_right_bracket (pp);
1651 op0 = array_ref_low_bound (node);
1652 op1 = array_ref_element_size (node);
1654 if (!integer_zerop (op0)
1655 || TREE_OPERAND (node, 2)
1656 || TREE_OPERAND (node, 3))
1658 pp_string (pp, "{lb: ");
1659 dump_generic_node (pp, op0, spc, flags, false);
1660 pp_string (pp, " sz: ");
1661 dump_generic_node (pp, op1, spc, flags, false);
1662 pp_right_brace (pp);
1664 break;
1666 case CONSTRUCTOR:
1668 unsigned HOST_WIDE_INT ix;
1669 tree field, val;
1670 bool is_struct_init = false;
1671 bool is_array_init = false;
1672 widest_int curidx;
1673 pp_left_brace (pp);
1674 if (TREE_CLOBBER_P (node))
1675 pp_string (pp, "CLOBBER");
1676 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1677 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1678 is_struct_init = true;
1679 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1680 && TYPE_DOMAIN (TREE_TYPE (node))
1681 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1682 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1683 == INTEGER_CST)
1685 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1686 is_array_init = true;
1687 curidx = wi::to_widest (minv);
1689 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1691 if (field)
1693 if (is_struct_init)
1695 pp_dot (pp);
1696 dump_generic_node (pp, field, spc, flags, false);
1697 pp_equal (pp);
1699 else if (is_array_init
1700 && (TREE_CODE (field) != INTEGER_CST
1701 || curidx != wi::to_widest (field)))
1703 pp_left_bracket (pp);
1704 if (TREE_CODE (field) == RANGE_EXPR)
1706 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1707 flags, false);
1708 pp_string (pp, " ... ");
1709 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1710 flags, false);
1711 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1712 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1714 else
1715 dump_generic_node (pp, field, spc, flags, false);
1716 if (TREE_CODE (field) == INTEGER_CST)
1717 curidx = wi::to_widest (field);
1718 pp_string (pp, "]=");
1721 if (is_array_init)
1722 curidx += 1;
1723 if (val && TREE_CODE (val) == ADDR_EXPR)
1724 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1725 val = TREE_OPERAND (val, 0);
1726 if (val && TREE_CODE (val) == FUNCTION_DECL)
1727 dump_decl_name (pp, val, flags);
1728 else
1729 dump_generic_node (pp, val, spc, flags, false);
1730 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1732 pp_comma (pp);
1733 pp_space (pp);
1736 pp_right_brace (pp);
1738 break;
1740 case COMPOUND_EXPR:
1742 tree *tp;
1743 if (flags & TDF_SLIM)
1745 pp_string (pp, "<COMPOUND_EXPR>");
1746 break;
1749 dump_generic_node (pp, TREE_OPERAND (node, 0),
1750 spc, flags, !(flags & TDF_SLIM));
1751 if (flags & TDF_SLIM)
1752 newline_and_indent (pp, spc);
1753 else
1755 pp_comma (pp);
1756 pp_space (pp);
1759 for (tp = &TREE_OPERAND (node, 1);
1760 TREE_CODE (*tp) == COMPOUND_EXPR;
1761 tp = &TREE_OPERAND (*tp, 1))
1763 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1764 spc, flags, !(flags & TDF_SLIM));
1765 if (flags & TDF_SLIM)
1766 newline_and_indent (pp, spc);
1767 else
1769 pp_comma (pp);
1770 pp_space (pp);
1774 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1776 break;
1778 case STATEMENT_LIST:
1780 tree_stmt_iterator si;
1781 bool first = true;
1783 if (flags & TDF_SLIM)
1785 pp_string (pp, "<STATEMENT_LIST>");
1786 break;
1789 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1791 if (!first)
1792 newline_and_indent (pp, spc);
1793 else
1794 first = false;
1795 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1798 break;
1800 case MODIFY_EXPR:
1801 case INIT_EXPR:
1802 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1803 false);
1804 pp_space (pp);
1805 pp_equal (pp);
1806 pp_space (pp);
1807 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1808 false);
1809 break;
1811 case TARGET_EXPR:
1812 pp_string (pp, "TARGET_EXPR <");
1813 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1814 pp_comma (pp);
1815 pp_space (pp);
1816 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1817 pp_greater (pp);
1818 break;
1820 case DECL_EXPR:
1821 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1822 is_stmt = false;
1823 break;
1825 case COND_EXPR:
1826 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1828 pp_string (pp, "if (");
1829 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1830 pp_right_paren (pp);
1831 /* The lowered cond_exprs should always be printed in full. */
1832 if (COND_EXPR_THEN (node)
1833 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1834 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1835 && COND_EXPR_ELSE (node)
1836 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1837 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1839 pp_space (pp);
1840 dump_generic_node (pp, COND_EXPR_THEN (node),
1841 0, flags, true);
1842 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1844 pp_string (pp, " else ");
1845 dump_generic_node (pp, COND_EXPR_ELSE (node),
1846 0, flags, true);
1849 else if (!(flags & TDF_SLIM))
1851 /* Output COND_EXPR_THEN. */
1852 if (COND_EXPR_THEN (node))
1854 newline_and_indent (pp, spc+2);
1855 pp_left_brace (pp);
1856 newline_and_indent (pp, spc+4);
1857 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
1858 flags, true);
1859 newline_and_indent (pp, spc+2);
1860 pp_right_brace (pp);
1863 /* Output COND_EXPR_ELSE. */
1864 if (COND_EXPR_ELSE (node)
1865 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1867 newline_and_indent (pp, spc);
1868 pp_string (pp, "else");
1869 newline_and_indent (pp, spc+2);
1870 pp_left_brace (pp);
1871 newline_and_indent (pp, spc+4);
1872 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
1873 flags, true);
1874 newline_and_indent (pp, spc+2);
1875 pp_right_brace (pp);
1878 is_expr = false;
1880 else
1882 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1883 pp_space (pp);
1884 pp_question (pp);
1885 pp_space (pp);
1886 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1887 pp_space (pp);
1888 pp_colon (pp);
1889 pp_space (pp);
1890 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1892 break;
1894 case BIND_EXPR:
1895 pp_left_brace (pp);
1896 if (!(flags & TDF_SLIM))
1898 if (BIND_EXPR_VARS (node))
1900 pp_newline (pp);
1902 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1904 print_declaration (pp, op0, spc+2, flags);
1905 pp_newline (pp);
1909 newline_and_indent (pp, spc+2);
1910 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
1911 newline_and_indent (pp, spc);
1912 pp_right_brace (pp);
1914 is_expr = false;
1915 break;
1917 case CALL_EXPR:
1918 if (CALL_EXPR_FN (node) != NULL_TREE)
1919 print_call_name (pp, CALL_EXPR_FN (node), flags);
1920 else
1921 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
1923 /* Print parameters. */
1924 pp_space (pp);
1925 pp_left_paren (pp);
1927 tree arg;
1928 call_expr_arg_iterator iter;
1929 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1931 dump_generic_node (pp, arg, spc, flags, false);
1932 if (more_call_expr_args_p (&iter))
1934 pp_comma (pp);
1935 pp_space (pp);
1939 if (CALL_EXPR_VA_ARG_PACK (node))
1941 if (call_expr_nargs (node) > 0)
1943 pp_comma (pp);
1944 pp_space (pp);
1946 pp_string (pp, "__builtin_va_arg_pack ()");
1948 pp_right_paren (pp);
1950 op1 = CALL_EXPR_STATIC_CHAIN (node);
1951 if (op1)
1953 pp_string (pp, " [static-chain: ");
1954 dump_generic_node (pp, op1, spc, flags, false);
1955 pp_right_bracket (pp);
1958 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1959 pp_string (pp, " [return slot optimization]");
1960 if (CALL_EXPR_TAILCALL (node))
1961 pp_string (pp, " [tail call]");
1962 break;
1964 case WITH_CLEANUP_EXPR:
1965 NIY;
1966 break;
1968 case CLEANUP_POINT_EXPR:
1969 pp_string (pp, "<<cleanup_point ");
1970 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1971 pp_string (pp, ">>");
1972 break;
1974 case PLACEHOLDER_EXPR:
1975 pp_string (pp, "<PLACEHOLDER_EXPR ");
1976 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1977 pp_greater (pp);
1978 break;
1980 /* Binary arithmetic and logic expressions. */
1981 case WIDEN_SUM_EXPR:
1982 case WIDEN_MULT_EXPR:
1983 case MULT_EXPR:
1984 case MULT_HIGHPART_EXPR:
1985 case PLUS_EXPR:
1986 case POINTER_PLUS_EXPR:
1987 case MINUS_EXPR:
1988 case TRUNC_DIV_EXPR:
1989 case CEIL_DIV_EXPR:
1990 case FLOOR_DIV_EXPR:
1991 case ROUND_DIV_EXPR:
1992 case TRUNC_MOD_EXPR:
1993 case CEIL_MOD_EXPR:
1994 case FLOOR_MOD_EXPR:
1995 case ROUND_MOD_EXPR:
1996 case RDIV_EXPR:
1997 case EXACT_DIV_EXPR:
1998 case LSHIFT_EXPR:
1999 case RSHIFT_EXPR:
2000 case LROTATE_EXPR:
2001 case RROTATE_EXPR:
2002 case WIDEN_LSHIFT_EXPR:
2003 case BIT_IOR_EXPR:
2004 case BIT_XOR_EXPR:
2005 case BIT_AND_EXPR:
2006 case TRUTH_ANDIF_EXPR:
2007 case TRUTH_ORIF_EXPR:
2008 case TRUTH_AND_EXPR:
2009 case TRUTH_OR_EXPR:
2010 case TRUTH_XOR_EXPR:
2011 case LT_EXPR:
2012 case LE_EXPR:
2013 case GT_EXPR:
2014 case GE_EXPR:
2015 case EQ_EXPR:
2016 case NE_EXPR:
2017 case UNLT_EXPR:
2018 case UNLE_EXPR:
2019 case UNGT_EXPR:
2020 case UNGE_EXPR:
2021 case UNEQ_EXPR:
2022 case LTGT_EXPR:
2023 case ORDERED_EXPR:
2024 case UNORDERED_EXPR:
2026 const char *op = op_symbol (node);
2027 op0 = TREE_OPERAND (node, 0);
2028 op1 = TREE_OPERAND (node, 1);
2030 /* When the operands are expressions with less priority,
2031 keep semantics of the tree representation. */
2032 if (op_prio (op0) <= op_prio (node))
2034 pp_left_paren (pp);
2035 dump_generic_node (pp, op0, spc, flags, false);
2036 pp_right_paren (pp);
2038 else
2039 dump_generic_node (pp, op0, spc, flags, false);
2041 pp_space (pp);
2042 pp_string (pp, op);
2043 pp_space (pp);
2045 /* When the operands are expressions with less priority,
2046 keep semantics of the tree representation. */
2047 if (op_prio (op1) <= op_prio (node))
2049 pp_left_paren (pp);
2050 dump_generic_node (pp, op1, spc, flags, false);
2051 pp_right_paren (pp);
2053 else
2054 dump_generic_node (pp, op1, spc, flags, false);
2056 break;
2058 /* Unary arithmetic and logic expressions. */
2059 case NEGATE_EXPR:
2060 case BIT_NOT_EXPR:
2061 case TRUTH_NOT_EXPR:
2062 case ADDR_EXPR:
2063 case PREDECREMENT_EXPR:
2064 case PREINCREMENT_EXPR:
2065 case INDIRECT_REF:
2066 if (TREE_CODE (node) == ADDR_EXPR
2067 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2068 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2069 ; /* Do not output '&' for strings and function pointers. */
2070 else
2071 pp_string (pp, op_symbol (node));
2073 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2075 pp_left_paren (pp);
2076 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2077 pp_right_paren (pp);
2079 else
2080 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2081 break;
2083 case POSTDECREMENT_EXPR:
2084 case POSTINCREMENT_EXPR:
2085 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2087 pp_left_paren (pp);
2088 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2089 pp_right_paren (pp);
2091 else
2092 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2093 pp_string (pp, op_symbol (node));
2094 break;
2096 case MIN_EXPR:
2097 pp_string (pp, "MIN_EXPR <");
2098 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2099 pp_string (pp, ", ");
2100 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2101 pp_greater (pp);
2102 break;
2104 case MAX_EXPR:
2105 pp_string (pp, "MAX_EXPR <");
2106 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2107 pp_string (pp, ", ");
2108 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2109 pp_greater (pp);
2110 break;
2112 case ABS_EXPR:
2113 pp_string (pp, "ABS_EXPR <");
2114 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2115 pp_greater (pp);
2116 break;
2118 case RANGE_EXPR:
2119 NIY;
2120 break;
2122 case ADDR_SPACE_CONVERT_EXPR:
2123 case FIXED_CONVERT_EXPR:
2124 case FIX_TRUNC_EXPR:
2125 case FLOAT_EXPR:
2126 CASE_CONVERT:
2127 type = TREE_TYPE (node);
2128 op0 = TREE_OPERAND (node, 0);
2129 if (type != TREE_TYPE (op0))
2131 pp_left_paren (pp);
2132 dump_generic_node (pp, type, spc, flags, false);
2133 pp_string (pp, ") ");
2135 if (op_prio (op0) < op_prio (node))
2136 pp_left_paren (pp);
2137 dump_generic_node (pp, op0, spc, flags, false);
2138 if (op_prio (op0) < op_prio (node))
2139 pp_right_paren (pp);
2140 break;
2142 case VIEW_CONVERT_EXPR:
2143 pp_string (pp, "VIEW_CONVERT_EXPR<");
2144 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2145 pp_string (pp, ">(");
2146 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2147 pp_right_paren (pp);
2148 break;
2150 case PAREN_EXPR:
2151 pp_string (pp, "((");
2152 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2153 pp_string (pp, "))");
2154 break;
2156 case NON_LVALUE_EXPR:
2157 pp_string (pp, "NON_LVALUE_EXPR <");
2158 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2159 pp_greater (pp);
2160 break;
2162 case SAVE_EXPR:
2163 pp_string (pp, "SAVE_EXPR <");
2164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2165 pp_greater (pp);
2166 break;
2168 case COMPLEX_EXPR:
2169 pp_string (pp, "COMPLEX_EXPR <");
2170 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2171 pp_string (pp, ", ");
2172 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2173 pp_greater (pp);
2174 break;
2176 case CONJ_EXPR:
2177 pp_string (pp, "CONJ_EXPR <");
2178 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2179 pp_greater (pp);
2180 break;
2182 case REALPART_EXPR:
2183 pp_string (pp, "REALPART_EXPR <");
2184 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2185 pp_greater (pp);
2186 break;
2188 case IMAGPART_EXPR:
2189 pp_string (pp, "IMAGPART_EXPR <");
2190 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2191 pp_greater (pp);
2192 break;
2194 case VA_ARG_EXPR:
2195 pp_string (pp, "VA_ARG_EXPR <");
2196 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2197 pp_greater (pp);
2198 break;
2200 case TRY_FINALLY_EXPR:
2201 case TRY_CATCH_EXPR:
2202 pp_string (pp, "try");
2203 newline_and_indent (pp, spc+2);
2204 pp_left_brace (pp);
2205 newline_and_indent (pp, spc+4);
2206 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2207 newline_and_indent (pp, spc+2);
2208 pp_right_brace (pp);
2209 newline_and_indent (pp, spc);
2210 pp_string (pp,
2211 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2212 newline_and_indent (pp, spc+2);
2213 pp_left_brace (pp);
2214 newline_and_indent (pp, spc+4);
2215 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2216 newline_and_indent (pp, spc+2);
2217 pp_right_brace (pp);
2218 is_expr = false;
2219 break;
2221 case CATCH_EXPR:
2222 pp_string (pp, "catch (");
2223 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2224 pp_right_paren (pp);
2225 newline_and_indent (pp, spc+2);
2226 pp_left_brace (pp);
2227 newline_and_indent (pp, spc+4);
2228 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2229 newline_and_indent (pp, spc+2);
2230 pp_right_brace (pp);
2231 is_expr = false;
2232 break;
2234 case EH_FILTER_EXPR:
2235 pp_string (pp, "<<<eh_filter (");
2236 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2237 pp_string (pp, ")>>>");
2238 newline_and_indent (pp, spc+2);
2239 pp_left_brace (pp);
2240 newline_and_indent (pp, spc+4);
2241 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2242 newline_and_indent (pp, spc+2);
2243 pp_right_brace (pp);
2244 is_expr = false;
2245 break;
2247 case LABEL_EXPR:
2248 op0 = TREE_OPERAND (node, 0);
2249 /* If this is for break or continue, don't bother printing it. */
2250 if (DECL_NAME (op0))
2252 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2253 if (strcmp (name, "break") == 0
2254 || strcmp (name, "continue") == 0)
2255 break;
2257 dump_generic_node (pp, op0, spc, flags, false);
2258 pp_colon (pp);
2259 if (DECL_NONLOCAL (op0))
2260 pp_string (pp, " [non-local]");
2261 break;
2263 case LOOP_EXPR:
2264 pp_string (pp, "while (1)");
2265 if (!(flags & TDF_SLIM))
2267 newline_and_indent (pp, spc+2);
2268 pp_left_brace (pp);
2269 newline_and_indent (pp, spc+4);
2270 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2271 newline_and_indent (pp, spc+2);
2272 pp_right_brace (pp);
2274 is_expr = false;
2275 break;
2277 case PREDICT_EXPR:
2278 pp_string (pp, "// predicted ");
2279 if (PREDICT_EXPR_OUTCOME (node))
2280 pp_string (pp, "likely by ");
2281 else
2282 pp_string (pp, "unlikely by ");
2283 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2284 pp_string (pp, " predictor.");
2285 break;
2287 case ANNOTATE_EXPR:
2288 pp_string (pp, "ANNOTATE_EXPR <");
2289 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2290 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2292 case annot_expr_ivdep_kind:
2293 pp_string (pp, ", ivdep");
2294 break;
2295 case annot_expr_no_vector_kind:
2296 pp_string (pp, ", no-vector");
2297 break;
2298 case annot_expr_vector_kind:
2299 pp_string (pp, ", vector");
2300 break;
2301 default:
2302 gcc_unreachable ();
2304 pp_greater (pp);
2305 break;
2307 case RETURN_EXPR:
2308 pp_string (pp, "return");
2309 op0 = TREE_OPERAND (node, 0);
2310 if (op0)
2312 pp_space (pp);
2313 if (TREE_CODE (op0) == MODIFY_EXPR)
2314 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2315 spc, flags, false);
2316 else
2317 dump_generic_node (pp, op0, spc, flags, false);
2319 break;
2321 case EXIT_EXPR:
2322 pp_string (pp, "if (");
2323 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2324 pp_string (pp, ") break");
2325 break;
2327 case SWITCH_EXPR:
2328 pp_string (pp, "switch (");
2329 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2330 pp_right_paren (pp);
2331 if (!(flags & TDF_SLIM))
2333 newline_and_indent (pp, spc+2);
2334 pp_left_brace (pp);
2335 if (SWITCH_BODY (node))
2337 newline_and_indent (pp, spc+4);
2338 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2339 true);
2341 else
2343 tree vec = SWITCH_LABELS (node);
2344 size_t i, n = TREE_VEC_LENGTH (vec);
2345 for (i = 0; i < n; ++i)
2347 tree elt = TREE_VEC_ELT (vec, i);
2348 newline_and_indent (pp, spc+4);
2349 if (elt)
2351 dump_generic_node (pp, elt, spc+4, flags, false);
2352 pp_string (pp, " goto ");
2353 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2354 flags, true);
2355 pp_semicolon (pp);
2357 else
2358 pp_string (pp, "case ???: goto ???;");
2361 newline_and_indent (pp, spc+2);
2362 pp_right_brace (pp);
2364 is_expr = false;
2365 break;
2367 case GOTO_EXPR:
2368 op0 = GOTO_DESTINATION (node);
2369 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2371 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2372 if (strcmp (name, "break") == 0
2373 || strcmp (name, "continue") == 0)
2375 pp_string (pp, name);
2376 break;
2379 pp_string (pp, "goto ");
2380 dump_generic_node (pp, op0, spc, flags, false);
2381 break;
2383 case ASM_EXPR:
2384 pp_string (pp, "__asm__");
2385 if (ASM_VOLATILE_P (node))
2386 pp_string (pp, " __volatile__");
2387 pp_left_paren (pp);
2388 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2389 pp_colon (pp);
2390 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2391 pp_colon (pp);
2392 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2393 if (ASM_CLOBBERS (node))
2395 pp_colon (pp);
2396 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2398 pp_right_paren (pp);
2399 break;
2401 case CASE_LABEL_EXPR:
2402 if (CASE_LOW (node) && CASE_HIGH (node))
2404 pp_string (pp, "case ");
2405 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2406 pp_string (pp, " ... ");
2407 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2409 else if (CASE_LOW (node))
2411 pp_string (pp, "case ");
2412 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2414 else
2415 pp_string (pp, "default");
2416 pp_colon (pp);
2417 break;
2419 case OBJ_TYPE_REF:
2420 pp_string (pp, "OBJ_TYPE_REF(");
2421 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2422 pp_semicolon (pp);
2423 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2425 pp_string (pp, "(");
2426 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2427 pp_string (pp, ")");
2429 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2430 pp_arrow (pp);
2431 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2432 pp_right_paren (pp);
2433 break;
2435 case SSA_NAME:
2436 if (SSA_NAME_IDENTIFIER (node))
2437 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2438 spc, flags, false);
2439 pp_underscore (pp);
2440 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2441 if (SSA_NAME_IS_DEFAULT_DEF (node))
2442 pp_string (pp, "(D)");
2443 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2444 pp_string (pp, "(ab)");
2445 break;
2447 case WITH_SIZE_EXPR:
2448 pp_string (pp, "WITH_SIZE_EXPR <");
2449 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2450 pp_string (pp, ", ");
2451 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2452 pp_greater (pp);
2453 break;
2455 case ASSERT_EXPR:
2456 pp_string (pp, "ASSERT_EXPR <");
2457 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2458 pp_string (pp, ", ");
2459 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2460 pp_greater (pp);
2461 break;
2463 case SCEV_KNOWN:
2464 pp_string (pp, "scev_known");
2465 break;
2467 case SCEV_NOT_KNOWN:
2468 pp_string (pp, "scev_not_known");
2469 break;
2471 case POLYNOMIAL_CHREC:
2472 pp_left_brace (pp);
2473 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2474 pp_string (pp, ", +, ");
2475 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2476 pp_string (pp, "}_");
2477 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2478 is_stmt = false;
2479 break;
2481 case REALIGN_LOAD_EXPR:
2482 pp_string (pp, "REALIGN_LOAD <");
2483 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2484 pp_string (pp, ", ");
2485 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2486 pp_string (pp, ", ");
2487 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2488 pp_greater (pp);
2489 break;
2491 case VEC_COND_EXPR:
2492 pp_string (pp, " VEC_COND_EXPR < ");
2493 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2494 pp_string (pp, " , ");
2495 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2496 pp_string (pp, " , ");
2497 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2498 pp_string (pp, " > ");
2499 break;
2501 case VEC_PERM_EXPR:
2502 pp_string (pp, " VEC_PERM_EXPR < ");
2503 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2504 pp_string (pp, " , ");
2505 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2506 pp_string (pp, " , ");
2507 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2508 pp_string (pp, " > ");
2509 break;
2511 case DOT_PROD_EXPR:
2512 pp_string (pp, " DOT_PROD_EXPR < ");
2513 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2514 pp_string (pp, ", ");
2515 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2516 pp_string (pp, ", ");
2517 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2518 pp_string (pp, " > ");
2519 break;
2521 case WIDEN_MULT_PLUS_EXPR:
2522 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2523 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2524 pp_string (pp, ", ");
2525 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2526 pp_string (pp, ", ");
2527 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2528 pp_string (pp, " > ");
2529 break;
2531 case WIDEN_MULT_MINUS_EXPR:
2532 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2533 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2534 pp_string (pp, ", ");
2535 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2536 pp_string (pp, ", ");
2537 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2538 pp_string (pp, " > ");
2539 break;
2541 case FMA_EXPR:
2542 pp_string (pp, " FMA_EXPR < ");
2543 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2544 pp_string (pp, ", ");
2545 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2546 pp_string (pp, ", ");
2547 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2548 pp_string (pp, " > ");
2549 break;
2551 case OACC_PARALLEL:
2552 pp_string (pp, "#pragma acc parallel");
2553 dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags);
2554 goto dump_omp_body;
2556 case OACC_KERNELS:
2557 pp_string (pp, "#pragma acc kernels");
2558 dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags);
2559 goto dump_omp_body;
2561 case OACC_DATA:
2562 pp_string (pp, "#pragma acc data");
2563 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2564 goto dump_omp_body;
2566 case OACC_HOST_DATA:
2567 pp_string (pp, "#pragma acc host_data");
2568 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2569 goto dump_omp_body;
2571 case OACC_DECLARE:
2572 pp_string (pp, "#pragma acc declare");
2573 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2574 break;
2576 case OACC_UPDATE:
2577 pp_string (pp, "#pragma acc update");
2578 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2579 break;
2581 case OACC_ENTER_DATA:
2582 pp_string (pp, "#pragma acc enter data");
2583 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2584 break;
2586 case OACC_EXIT_DATA:
2587 pp_string (pp, "#pragma acc exit data");
2588 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2589 break;
2591 case OACC_CACHE:
2592 pp_string (pp, "#pragma acc cache");
2593 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2594 break;
2596 case OMP_PARALLEL:
2597 pp_string (pp, "#pragma omp parallel");
2598 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2600 dump_omp_body:
2601 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2603 newline_and_indent (pp, spc + 2);
2604 pp_left_brace (pp);
2605 newline_and_indent (pp, spc + 4);
2606 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2607 newline_and_indent (pp, spc + 2);
2608 pp_right_brace (pp);
2610 is_expr = false;
2611 break;
2613 case OMP_TASK:
2614 pp_string (pp, "#pragma omp task");
2615 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2616 goto dump_omp_body;
2618 case OMP_FOR:
2619 pp_string (pp, "#pragma omp for");
2620 goto dump_omp_loop;
2622 case OMP_SIMD:
2623 pp_string (pp, "#pragma omp simd");
2624 goto dump_omp_loop;
2626 case CILK_SIMD:
2627 pp_string (pp, "#pragma simd");
2628 goto dump_omp_loop;
2630 case CILK_FOR:
2631 /* This label points one line after dumping the clauses.
2632 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2633 parameters are printed out. */
2634 goto dump_omp_loop_cilk_for;
2636 case OMP_DISTRIBUTE:
2637 pp_string (pp, "#pragma omp distribute");
2638 goto dump_omp_loop;
2640 case OACC_LOOP:
2641 pp_string (pp, "#pragma acc loop");
2642 goto dump_omp_loop;
2644 case OMP_TEAMS:
2645 pp_string (pp, "#pragma omp teams");
2646 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2647 goto dump_omp_body;
2649 case OMP_TARGET_DATA:
2650 pp_string (pp, "#pragma omp target data");
2651 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2652 goto dump_omp_body;
2654 case OMP_TARGET:
2655 pp_string (pp, "#pragma omp target");
2656 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2657 goto dump_omp_body;
2659 case OMP_TARGET_UPDATE:
2660 pp_string (pp, "#pragma omp target update");
2661 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2662 is_expr = false;
2663 break;
2665 dump_omp_loop:
2666 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2668 dump_omp_loop_cilk_for:
2669 if (!(flags & TDF_SLIM))
2671 int i;
2673 if (OMP_FOR_PRE_BODY (node))
2675 if (TREE_CODE (node) == CILK_FOR)
2676 pp_string (pp, " ");
2677 else
2678 newline_and_indent (pp, spc + 2);
2679 pp_left_brace (pp);
2680 spc += 4;
2681 newline_and_indent (pp, spc);
2682 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2683 spc, flags, false);
2685 if (OMP_FOR_INIT (node))
2687 spc -= 2;
2688 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2690 spc += 2;
2691 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2692 newline_and_indent (pp, spc);
2693 if (TREE_CODE (node) == CILK_FOR)
2694 pp_string (pp, "_Cilk_for (");
2695 else
2696 pp_string (pp, "for (");
2697 dump_generic_node (pp,
2698 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2699 spc, flags, false);
2700 pp_string (pp, "; ");
2701 dump_generic_node (pp,
2702 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2703 spc, flags, false);
2704 pp_string (pp, "; ");
2705 dump_generic_node (pp,
2706 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2707 spc, flags, false);
2708 pp_right_paren (pp);
2710 if (TREE_CODE (node) == CILK_FOR)
2711 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2713 if (OMP_FOR_BODY (node))
2715 newline_and_indent (pp, spc + 2);
2716 pp_left_brace (pp);
2717 newline_and_indent (pp, spc + 4);
2718 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2719 false);
2720 newline_and_indent (pp, spc + 2);
2721 pp_right_brace (pp);
2723 if (OMP_FOR_INIT (node))
2724 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2725 if (OMP_FOR_PRE_BODY (node))
2727 spc -= 4;
2728 newline_and_indent (pp, spc + 2);
2729 pp_right_brace (pp);
2732 is_expr = false;
2733 break;
2735 case OMP_SECTIONS:
2736 pp_string (pp, "#pragma omp sections");
2737 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2738 goto dump_omp_body;
2740 case OMP_SECTION:
2741 pp_string (pp, "#pragma omp section");
2742 goto dump_omp_body;
2744 case OMP_MASTER:
2745 pp_string (pp, "#pragma omp master");
2746 goto dump_omp_body;
2748 case OMP_TASKGROUP:
2749 pp_string (pp, "#pragma omp taskgroup");
2750 goto dump_omp_body;
2752 case OMP_ORDERED:
2753 pp_string (pp, "#pragma omp ordered");
2754 goto dump_omp_body;
2756 case OMP_CRITICAL:
2757 pp_string (pp, "#pragma omp critical");
2758 if (OMP_CRITICAL_NAME (node))
2760 pp_space (pp);
2761 pp_left_paren (pp);
2762 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2763 flags, false);
2764 pp_right_paren (pp);
2766 goto dump_omp_body;
2768 case OMP_ATOMIC:
2769 pp_string (pp, "#pragma omp atomic");
2770 if (OMP_ATOMIC_SEQ_CST (node))
2771 pp_string (pp, " seq_cst");
2772 newline_and_indent (pp, spc + 2);
2773 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2774 pp_space (pp);
2775 pp_equal (pp);
2776 pp_space (pp);
2777 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2778 break;
2780 case OMP_ATOMIC_READ:
2781 pp_string (pp, "#pragma omp atomic read");
2782 if (OMP_ATOMIC_SEQ_CST (node))
2783 pp_string (pp, " seq_cst");
2784 newline_and_indent (pp, spc + 2);
2785 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2786 pp_space (pp);
2787 break;
2789 case OMP_ATOMIC_CAPTURE_OLD:
2790 case OMP_ATOMIC_CAPTURE_NEW:
2791 pp_string (pp, "#pragma omp atomic capture");
2792 if (OMP_ATOMIC_SEQ_CST (node))
2793 pp_string (pp, " seq_cst");
2794 newline_and_indent (pp, spc + 2);
2795 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2796 pp_space (pp);
2797 pp_equal (pp);
2798 pp_space (pp);
2799 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2800 break;
2802 case OMP_SINGLE:
2803 pp_string (pp, "#pragma omp single");
2804 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2805 goto dump_omp_body;
2807 case OMP_CLAUSE:
2808 dump_omp_clause (pp, node, spc, flags);
2809 is_expr = false;
2810 break;
2812 case TRANSACTION_EXPR:
2813 if (TRANSACTION_EXPR_OUTER (node))
2814 pp_string (pp, "__transaction_atomic [[outer]]");
2815 else if (TRANSACTION_EXPR_RELAXED (node))
2816 pp_string (pp, "__transaction_relaxed");
2817 else
2818 pp_string (pp, "__transaction_atomic");
2819 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2821 newline_and_indent (pp, spc);
2822 pp_left_brace (pp);
2823 newline_and_indent (pp, spc + 2);
2824 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
2825 spc + 2, flags, false);
2826 newline_and_indent (pp, spc);
2827 pp_right_brace (pp);
2829 is_expr = false;
2830 break;
2832 case REDUC_MAX_EXPR:
2833 pp_string (pp, " REDUC_MAX_EXPR < ");
2834 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2835 pp_string (pp, " > ");
2836 break;
2838 case REDUC_MIN_EXPR:
2839 pp_string (pp, " REDUC_MIN_EXPR < ");
2840 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2841 pp_string (pp, " > ");
2842 break;
2844 case REDUC_PLUS_EXPR:
2845 pp_string (pp, " REDUC_PLUS_EXPR < ");
2846 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2847 pp_string (pp, " > ");
2848 break;
2850 case VEC_WIDEN_MULT_HI_EXPR:
2851 case VEC_WIDEN_MULT_LO_EXPR:
2852 case VEC_WIDEN_MULT_EVEN_EXPR:
2853 case VEC_WIDEN_MULT_ODD_EXPR:
2854 case VEC_WIDEN_LSHIFT_HI_EXPR:
2855 case VEC_WIDEN_LSHIFT_LO_EXPR:
2856 pp_space (pp);
2857 for (str = get_tree_code_name (code); *str; str++)
2858 pp_character (pp, TOUPPER (*str));
2859 pp_string (pp, " < ");
2860 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2861 pp_string (pp, ", ");
2862 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2863 pp_string (pp, " > ");
2864 break;
2866 case VEC_UNPACK_HI_EXPR:
2867 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
2868 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2869 pp_string (pp, " > ");
2870 break;
2872 case VEC_UNPACK_LO_EXPR:
2873 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
2874 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2875 pp_string (pp, " > ");
2876 break;
2878 case VEC_UNPACK_FLOAT_HI_EXPR:
2879 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2880 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2881 pp_string (pp, " > ");
2882 break;
2884 case VEC_UNPACK_FLOAT_LO_EXPR:
2885 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2886 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2887 pp_string (pp, " > ");
2888 break;
2890 case VEC_PACK_TRUNC_EXPR:
2891 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
2892 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2893 pp_string (pp, ", ");
2894 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2895 pp_string (pp, " > ");
2896 break;
2898 case VEC_PACK_SAT_EXPR:
2899 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
2900 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2901 pp_string (pp, ", ");
2902 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2903 pp_string (pp, " > ");
2904 break;
2906 case VEC_PACK_FIX_TRUNC_EXPR:
2907 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
2908 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2909 pp_string (pp, ", ");
2910 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2911 pp_string (pp, " > ");
2912 break;
2914 case BLOCK:
2915 dump_block_node (pp, node, spc, flags);
2916 break;
2918 case CILK_SPAWN_STMT:
2919 pp_string (pp, "_Cilk_spawn ");
2920 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2921 break;
2923 case CILK_SYNC_STMT:
2924 pp_string (pp, "_Cilk_sync");
2925 break;
2927 default:
2928 NIY;
2931 if (is_stmt && is_expr)
2932 pp_semicolon (pp);
2934 return spc;
2937 /* Print the declaration of a variable. */
2939 void
2940 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
2942 INDENT (spc);
2944 if (TREE_CODE(t) == NAMELIST_DECL)
2946 pp_string(pp, "namelist ");
2947 dump_decl_name (pp, t, flags);
2948 pp_semicolon (pp);
2949 return;
2952 if (TREE_CODE (t) == TYPE_DECL)
2953 pp_string (pp, "typedef ");
2955 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2956 pp_string (pp, "register ");
2958 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2959 pp_string (pp, "extern ");
2960 else if (TREE_STATIC (t))
2961 pp_string (pp, "static ");
2963 /* Print the type and name. */
2964 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2966 tree tmp;
2968 /* Print array's type. */
2969 tmp = TREE_TYPE (t);
2970 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2971 tmp = TREE_TYPE (tmp);
2972 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
2974 /* Print variable's name. */
2975 pp_space (pp);
2976 dump_generic_node (pp, t, spc, flags, false);
2978 /* Print the dimensions. */
2979 tmp = TREE_TYPE (t);
2980 while (TREE_CODE (tmp) == ARRAY_TYPE)
2982 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2983 tmp = TREE_TYPE (tmp);
2986 else if (TREE_CODE (t) == FUNCTION_DECL)
2988 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2989 pp_space (pp);
2990 dump_decl_name (pp, t, flags);
2991 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
2993 else
2995 /* Print type declaration. */
2996 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
2998 /* Print variable's name. */
2999 pp_space (pp);
3000 dump_generic_node (pp, t, spc, flags, false);
3003 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3005 pp_string (pp, " __asm__ ");
3006 pp_left_paren (pp);
3007 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3008 pp_right_paren (pp);
3011 /* The initial value of a function serves to determine whether the function
3012 is declared or defined. So the following does not apply to function
3013 nodes. */
3014 if (TREE_CODE (t) != FUNCTION_DECL)
3016 /* Print the initial value. */
3017 if (DECL_INITIAL (t))
3019 pp_space (pp);
3020 pp_equal (pp);
3021 pp_space (pp);
3022 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3026 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3028 pp_string (pp, " [value-expr: ");
3029 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3030 pp_right_bracket (pp);
3033 pp_semicolon (pp);
3037 /* Prints a structure: name, fields, and methods.
3038 FIXME: Still incomplete. */
3040 static void
3041 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3043 /* Print the name of the structure. */
3044 if (TYPE_NAME (node))
3046 INDENT (spc);
3047 if (TREE_CODE (node) == RECORD_TYPE)
3048 pp_string (pp, "struct ");
3049 else if ((TREE_CODE (node) == UNION_TYPE
3050 || TREE_CODE (node) == QUAL_UNION_TYPE))
3051 pp_string (pp, "union ");
3053 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3056 /* Print the contents of the structure. */
3057 pp_newline (pp);
3058 INDENT (spc);
3059 pp_left_brace (pp);
3060 pp_newline (pp);
3062 /* Print the fields of the structure. */
3064 tree tmp;
3065 tmp = TYPE_FIELDS (node);
3066 while (tmp)
3068 /* Avoid to print recursively the structure. */
3069 /* FIXME : Not implemented correctly...,
3070 what about the case when we have a cycle in the contain graph? ...
3071 Maybe this could be solved by looking at the scope in which the
3072 structure was declared. */
3073 if (TREE_TYPE (tmp) != node
3074 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3075 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3077 print_declaration (pp, tmp, spc+2, flags);
3078 pp_newline (pp);
3080 tmp = DECL_CHAIN (tmp);
3083 INDENT (spc);
3084 pp_right_brace (pp);
3087 /* Return the priority of the operator CODE.
3089 From lowest to highest precedence with either left-to-right (L-R)
3090 or right-to-left (R-L) associativity]:
3092 1 [L-R] ,
3093 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3094 3 [R-L] ?:
3095 4 [L-R] ||
3096 5 [L-R] &&
3097 6 [L-R] |
3098 7 [L-R] ^
3099 8 [L-R] &
3100 9 [L-R] == !=
3101 10 [L-R] < <= > >=
3102 11 [L-R] << >>
3103 12 [L-R] + -
3104 13 [L-R] * / %
3105 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3106 15 [L-R] fn() [] -> .
3108 unary +, - and * have higher precedence than the corresponding binary
3109 operators. */
3112 op_code_prio (enum tree_code code)
3114 switch (code)
3116 case TREE_LIST:
3117 case COMPOUND_EXPR:
3118 case BIND_EXPR:
3119 return 1;
3121 case MODIFY_EXPR:
3122 case INIT_EXPR:
3123 return 2;
3125 case COND_EXPR:
3126 return 3;
3128 case TRUTH_OR_EXPR:
3129 case TRUTH_ORIF_EXPR:
3130 return 4;
3132 case TRUTH_AND_EXPR:
3133 case TRUTH_ANDIF_EXPR:
3134 return 5;
3136 case BIT_IOR_EXPR:
3137 return 6;
3139 case BIT_XOR_EXPR:
3140 case TRUTH_XOR_EXPR:
3141 return 7;
3143 case BIT_AND_EXPR:
3144 return 8;
3146 case EQ_EXPR:
3147 case NE_EXPR:
3148 return 9;
3150 case UNLT_EXPR:
3151 case UNLE_EXPR:
3152 case UNGT_EXPR:
3153 case UNGE_EXPR:
3154 case UNEQ_EXPR:
3155 case LTGT_EXPR:
3156 case ORDERED_EXPR:
3157 case UNORDERED_EXPR:
3158 case LT_EXPR:
3159 case LE_EXPR:
3160 case GT_EXPR:
3161 case GE_EXPR:
3162 return 10;
3164 case LSHIFT_EXPR:
3165 case RSHIFT_EXPR:
3166 case LROTATE_EXPR:
3167 case RROTATE_EXPR:
3168 case VEC_WIDEN_LSHIFT_HI_EXPR:
3169 case VEC_WIDEN_LSHIFT_LO_EXPR:
3170 case WIDEN_LSHIFT_EXPR:
3171 return 11;
3173 case WIDEN_SUM_EXPR:
3174 case PLUS_EXPR:
3175 case POINTER_PLUS_EXPR:
3176 case MINUS_EXPR:
3177 return 12;
3179 case VEC_WIDEN_MULT_HI_EXPR:
3180 case VEC_WIDEN_MULT_LO_EXPR:
3181 case WIDEN_MULT_EXPR:
3182 case DOT_PROD_EXPR:
3183 case WIDEN_MULT_PLUS_EXPR:
3184 case WIDEN_MULT_MINUS_EXPR:
3185 case MULT_EXPR:
3186 case MULT_HIGHPART_EXPR:
3187 case TRUNC_DIV_EXPR:
3188 case CEIL_DIV_EXPR:
3189 case FLOOR_DIV_EXPR:
3190 case ROUND_DIV_EXPR:
3191 case RDIV_EXPR:
3192 case EXACT_DIV_EXPR:
3193 case TRUNC_MOD_EXPR:
3194 case CEIL_MOD_EXPR:
3195 case FLOOR_MOD_EXPR:
3196 case ROUND_MOD_EXPR:
3197 case FMA_EXPR:
3198 return 13;
3200 case TRUTH_NOT_EXPR:
3201 case BIT_NOT_EXPR:
3202 case POSTINCREMENT_EXPR:
3203 case POSTDECREMENT_EXPR:
3204 case PREINCREMENT_EXPR:
3205 case PREDECREMENT_EXPR:
3206 case NEGATE_EXPR:
3207 case INDIRECT_REF:
3208 case ADDR_EXPR:
3209 case FLOAT_EXPR:
3210 CASE_CONVERT:
3211 case FIX_TRUNC_EXPR:
3212 case TARGET_EXPR:
3213 return 14;
3215 case CALL_EXPR:
3216 case ARRAY_REF:
3217 case ARRAY_RANGE_REF:
3218 case COMPONENT_REF:
3219 return 15;
3221 /* Special expressions. */
3222 case MIN_EXPR:
3223 case MAX_EXPR:
3224 case ABS_EXPR:
3225 case REALPART_EXPR:
3226 case IMAGPART_EXPR:
3227 case REDUC_MAX_EXPR:
3228 case REDUC_MIN_EXPR:
3229 case REDUC_PLUS_EXPR:
3230 case VEC_UNPACK_HI_EXPR:
3231 case VEC_UNPACK_LO_EXPR:
3232 case VEC_UNPACK_FLOAT_HI_EXPR:
3233 case VEC_UNPACK_FLOAT_LO_EXPR:
3234 case VEC_PACK_TRUNC_EXPR:
3235 case VEC_PACK_SAT_EXPR:
3236 return 16;
3238 default:
3239 /* Return an arbitrarily high precedence to avoid surrounding single
3240 VAR_DECLs in ()s. */
3241 return 9999;
3245 /* Return the priority of the operator OP. */
3248 op_prio (const_tree op)
3250 enum tree_code code;
3252 if (op == NULL)
3253 return 9999;
3255 code = TREE_CODE (op);
3256 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3257 return op_prio (TREE_OPERAND (op, 0));
3259 return op_code_prio (code);
3262 /* Return the symbol associated with operator CODE. */
3264 const char *
3265 op_symbol_code (enum tree_code code)
3267 switch (code)
3269 case MODIFY_EXPR:
3270 return "=";
3272 case TRUTH_OR_EXPR:
3273 case TRUTH_ORIF_EXPR:
3274 return "||";
3276 case TRUTH_AND_EXPR:
3277 case TRUTH_ANDIF_EXPR:
3278 return "&&";
3280 case BIT_IOR_EXPR:
3281 return "|";
3283 case TRUTH_XOR_EXPR:
3284 case BIT_XOR_EXPR:
3285 return "^";
3287 case ADDR_EXPR:
3288 case BIT_AND_EXPR:
3289 return "&";
3291 case ORDERED_EXPR:
3292 return "ord";
3293 case UNORDERED_EXPR:
3294 return "unord";
3296 case EQ_EXPR:
3297 return "==";
3298 case UNEQ_EXPR:
3299 return "u==";
3301 case NE_EXPR:
3302 return "!=";
3304 case LT_EXPR:
3305 return "<";
3306 case UNLT_EXPR:
3307 return "u<";
3309 case LE_EXPR:
3310 return "<=";
3311 case UNLE_EXPR:
3312 return "u<=";
3314 case GT_EXPR:
3315 return ">";
3316 case UNGT_EXPR:
3317 return "u>";
3319 case GE_EXPR:
3320 return ">=";
3321 case UNGE_EXPR:
3322 return "u>=";
3324 case LTGT_EXPR:
3325 return "<>";
3327 case LSHIFT_EXPR:
3328 return "<<";
3330 case RSHIFT_EXPR:
3331 return ">>";
3333 case LROTATE_EXPR:
3334 return "r<<";
3336 case RROTATE_EXPR:
3337 return "r>>";
3339 case WIDEN_LSHIFT_EXPR:
3340 return "w<<";
3342 case POINTER_PLUS_EXPR:
3343 return "+";
3345 case PLUS_EXPR:
3346 return "+";
3348 case REDUC_PLUS_EXPR:
3349 return "r+";
3351 case WIDEN_SUM_EXPR:
3352 return "w+";
3354 case WIDEN_MULT_EXPR:
3355 return "w*";
3357 case MULT_HIGHPART_EXPR:
3358 return "h*";
3360 case NEGATE_EXPR:
3361 case MINUS_EXPR:
3362 return "-";
3364 case BIT_NOT_EXPR:
3365 return "~";
3367 case TRUTH_NOT_EXPR:
3368 return "!";
3370 case MULT_EXPR:
3371 case INDIRECT_REF:
3372 return "*";
3374 case TRUNC_DIV_EXPR:
3375 case RDIV_EXPR:
3376 return "/";
3378 case CEIL_DIV_EXPR:
3379 return "/[cl]";
3381 case FLOOR_DIV_EXPR:
3382 return "/[fl]";
3384 case ROUND_DIV_EXPR:
3385 return "/[rd]";
3387 case EXACT_DIV_EXPR:
3388 return "/[ex]";
3390 case TRUNC_MOD_EXPR:
3391 return "%";
3393 case CEIL_MOD_EXPR:
3394 return "%[cl]";
3396 case FLOOR_MOD_EXPR:
3397 return "%[fl]";
3399 case ROUND_MOD_EXPR:
3400 return "%[rd]";
3402 case PREDECREMENT_EXPR:
3403 return " --";
3405 case PREINCREMENT_EXPR:
3406 return " ++";
3408 case POSTDECREMENT_EXPR:
3409 return "-- ";
3411 case POSTINCREMENT_EXPR:
3412 return "++ ";
3414 case MAX_EXPR:
3415 return "max";
3417 case MIN_EXPR:
3418 return "min";
3420 default:
3421 return "<<< ??? >>>";
3425 /* Return the symbol associated with operator OP. */
3427 static const char *
3428 op_symbol (const_tree op)
3430 return op_symbol_code (TREE_CODE (op));
3433 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3434 the gimple_call_fn of a GIMPLE_CALL. */
3436 void
3437 print_call_name (pretty_printer *pp, tree node, int flags)
3439 tree op0 = node;
3441 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3442 op0 = TREE_OPERAND (op0, 0);
3444 again:
3445 switch (TREE_CODE (op0))
3447 case VAR_DECL:
3448 case PARM_DECL:
3449 case FUNCTION_DECL:
3450 dump_function_name (pp, op0, flags);
3451 break;
3453 case ADDR_EXPR:
3454 case INDIRECT_REF:
3455 CASE_CONVERT:
3456 op0 = TREE_OPERAND (op0, 0);
3457 goto again;
3459 case COND_EXPR:
3460 pp_left_paren (pp);
3461 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3462 pp_string (pp, ") ? ");
3463 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3464 pp_string (pp, " : ");
3465 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3466 break;
3468 case ARRAY_REF:
3469 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3470 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3471 else
3472 dump_generic_node (pp, op0, 0, flags, false);
3473 break;
3475 case MEM_REF:
3476 if (integer_zerop (TREE_OPERAND (op0, 1)))
3478 op0 = TREE_OPERAND (op0, 0);
3479 goto again;
3481 /* Fallthru. */
3482 case COMPONENT_REF:
3483 case SSA_NAME:
3484 case OBJ_TYPE_REF:
3485 dump_generic_node (pp, op0, 0, flags, false);
3486 break;
3488 default:
3489 NIY;
3493 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3495 static void
3496 pretty_print_string (pretty_printer *pp, const char *str)
3498 if (str == NULL)
3499 return;
3501 while (*str)
3503 switch (str[0])
3505 case '\b':
3506 pp_string (pp, "\\b");
3507 break;
3509 case '\f':
3510 pp_string (pp, "\\f");
3511 break;
3513 case '\n':
3514 pp_string (pp, "\\n");
3515 break;
3517 case '\r':
3518 pp_string (pp, "\\r");
3519 break;
3521 case '\t':
3522 pp_string (pp, "\\t");
3523 break;
3525 case '\v':
3526 pp_string (pp, "\\v");
3527 break;
3529 case '\\':
3530 pp_string (pp, "\\\\");
3531 break;
3533 case '\"':
3534 pp_string (pp, "\\\"");
3535 break;
3537 case '\'':
3538 pp_string (pp, "\\'");
3539 break;
3541 /* No need to handle \0; the loop terminates on \0. */
3543 case '\1':
3544 pp_string (pp, "\\1");
3545 break;
3547 case '\2':
3548 pp_string (pp, "\\2");
3549 break;
3551 case '\3':
3552 pp_string (pp, "\\3");
3553 break;
3555 case '\4':
3556 pp_string (pp, "\\4");
3557 break;
3559 case '\5':
3560 pp_string (pp, "\\5");
3561 break;
3563 case '\6':
3564 pp_string (pp, "\\6");
3565 break;
3567 case '\7':
3568 pp_string (pp, "\\7");
3569 break;
3571 default:
3572 pp_character (pp, str[0]);
3573 break;
3575 str++;
3579 static void
3580 maybe_init_pretty_print (FILE *file)
3582 if (!tree_pp)
3584 tree_pp = new pretty_printer ();
3585 pp_needs_newline (tree_pp) = true;
3586 pp_translate_identifiers (tree_pp) = false;
3589 tree_pp->buffer->stream = file;
3592 static void
3593 newline_and_indent (pretty_printer *pp, int spc)
3595 pp_newline (pp);
3596 INDENT (spc);
3599 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3600 it can also be used in front ends.
3601 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3604 void
3605 percent_K_format (text_info *text)
3607 tree t = va_arg (*text->args_ptr, tree), block;
3608 text->set_location (0, EXPR_LOCATION (t));
3609 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3610 block = TREE_BLOCK (t);
3611 *pp_ti_abstract_origin (text) = NULL;
3613 if (in_lto_p)
3615 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3616 representing the outermost block of an inlined function.
3617 So walk the BLOCK tree until we hit such a scope. */
3618 while (block
3619 && TREE_CODE (block) == BLOCK)
3621 if (inlined_function_outer_scope_p (block))
3623 *pp_ti_abstract_origin (text) = block;
3624 break;
3626 block = BLOCK_SUPERCONTEXT (block);
3628 return;
3631 while (block
3632 && TREE_CODE (block) == BLOCK
3633 && BLOCK_ABSTRACT_ORIGIN (block))
3635 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3637 while (TREE_CODE (ao) == BLOCK
3638 && BLOCK_ABSTRACT_ORIGIN (ao)
3639 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3640 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3642 if (TREE_CODE (ao) == FUNCTION_DECL)
3644 *pp_ti_abstract_origin (text) = block;
3645 break;
3647 block = BLOCK_SUPERCONTEXT (block);
3651 /* Print the identifier ID to PRETTY-PRINTER. */
3653 void
3654 pp_tree_identifier (pretty_printer *pp, tree id)
3656 if (pp_translate_identifiers (pp))
3658 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3659 pp_append_text (pp, text, text + strlen (text));
3661 else
3662 pp_append_text (pp, IDENTIFIER_POINTER (id),
3663 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3666 /* A helper function that is used to dump function information before the
3667 function dump. */
3669 void
3670 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3672 const char *dname, *aname;
3673 struct cgraph_node *node = cgraph_node::get (fdecl);
3674 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3676 dname = lang_hooks.decl_printable_name (fdecl, 2);
3678 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3679 aname = (IDENTIFIER_POINTER
3680 (DECL_ASSEMBLER_NAME (fdecl)));
3681 else
3682 aname = "<unset-asm-name>";
3684 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3685 dname, aname, fun->funcdef_no);
3686 if (!(flags & TDF_NOUID))
3687 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3688 if (node)
3690 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3691 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3692 node->frequency == NODE_FREQUENCY_HOT
3693 ? " (hot)"
3694 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3695 ? " (unlikely executed)"
3696 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3697 ? " (executed once)"
3698 : "");
3700 else
3701 fprintf (dump_file, ")\n\n");
3704 /* Dump double_int D to pretty_printer PP. UNS is true
3705 if D is unsigned and false otherwise. */
3706 void
3707 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3709 if (d.fits_shwi ())
3710 pp_wide_integer (pp, d.low);
3711 else if (d.fits_uhwi ())
3712 pp_unsigned_wide_integer (pp, d.low);
3713 else
3715 unsigned HOST_WIDE_INT low = d.low;
3716 HOST_WIDE_INT high = d.high;
3717 if (!uns && d.is_negative ())
3719 pp_minus (pp);
3720 high = ~high + !low;
3721 low = -low;
3723 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3724 systems? */
3725 sprintf (pp_buffer (pp)->digit_buffer,
3726 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3727 (unsigned HOST_WIDE_INT) high, low);
3728 pp_string (pp, pp_buffer (pp)->digit_buffer);