mn10300: Use the STC bb-reorder algorithm at -Os
[official-gcc.git] / gcc / tree-pretty-print.c
blob11f9005110785ae8a316149e13471e49f6d224cc
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 "backend.h"
25 #include "predict.h"
26 #include "alias.h"
27 #include "tree.h"
28 #include "stor-layout.h"
29 #include "rtl.h"
30 #include "flags.h"
31 #include "insn-config.h"
32 #include "expmed.h"
33 #include "dojump.h"
34 #include "explow.h"
35 #include "calls.h"
36 #include "emit-rtl.h"
37 #include "varasm.h"
38 #include "stmt.h"
39 #include "expr.h"
40 #include "tree-pretty-print.h"
41 #include "gimple-expr.h"
42 #include "cgraph.h"
43 #include "langhooks.h"
44 #include "tree-iterator.h"
45 #include "tree-chrec.h"
46 #include "dumpfile.h"
47 #include "value-prof.h"
48 #include "wide-int-print.h"
49 #include "internal-fn.h"
50 #include "gomp-constants.h"
52 /* Local functions, macros and variables. */
53 static const char *op_symbol (const_tree);
54 static void pretty_print_string (pretty_printer *, const char*);
55 static void newline_and_indent (pretty_printer *, int);
56 static void maybe_init_pretty_print (FILE *);
57 static void print_struct_decl (pretty_printer *, const_tree, int, int);
58 static void do_niy (pretty_printer *, const_tree);
60 #define INDENT(SPACE) do { \
61 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
63 #define NIY do_niy (pp, node)
65 static pretty_printer *tree_pp;
67 /* Try to print something for an unknown tree code. */
69 static void
70 do_niy (pretty_printer *pp, const_tree node)
72 int i, len;
74 pp_string (pp, "<<< Unknown tree: ");
75 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
77 if (EXPR_P (node))
79 len = TREE_OPERAND_LENGTH (node);
80 for (i = 0; i < len; ++i)
82 newline_and_indent (pp, 2);
83 dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false);
87 pp_string (pp, " >>>");
90 /* Debugging function to print out a generic expression. */
92 DEBUG_FUNCTION void
93 debug_generic_expr (tree t)
95 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
96 fprintf (stderr, "\n");
99 /* Debugging function to print out a generic statement. */
101 DEBUG_FUNCTION void
102 debug_generic_stmt (tree t)
104 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
105 fprintf (stderr, "\n");
108 /* Debugging function to print out a chain of trees . */
110 DEBUG_FUNCTION void
111 debug_tree_chain (tree t)
113 hash_set<tree> seen;
115 while (t)
117 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
118 fprintf (stderr, " ");
119 t = TREE_CHAIN (t);
120 if (seen.add (t))
122 fprintf (stderr, "... [cycled back to ");
123 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
124 fprintf (stderr, "]");
125 break;
128 fprintf (stderr, "\n");
131 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
132 void
133 print_generic_decl (FILE *file, tree decl, int flags)
135 maybe_init_pretty_print (file);
136 print_declaration (tree_pp, decl, 2, flags);
137 pp_write_text_to_stream (tree_pp);
140 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
141 to show in the dump. See TDF_* in dumpfile.h. */
143 void
144 print_generic_stmt (FILE *file, tree t, int flags)
146 maybe_init_pretty_print (file);
147 dump_generic_node (tree_pp, t, 0, flags, true);
148 pp_newline_and_flush (tree_pp);
151 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
152 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
153 INDENT spaces. */
155 void
156 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
158 int i;
160 maybe_init_pretty_print (file);
162 for (i = 0; i < indent; i++)
163 pp_space (tree_pp);
164 dump_generic_node (tree_pp, t, indent, flags, true);
165 pp_newline_and_flush (tree_pp);
168 /* Print a single expression T on file FILE. FLAGS specifies details to show
169 in the dump. See TDF_* in dumpfile.h. */
171 void
172 print_generic_expr (FILE *file, tree t, int flags)
174 maybe_init_pretty_print (file);
175 dump_generic_node (tree_pp, t, 0, flags, false);
176 pp_flush (tree_pp);
179 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
180 in FLAGS. */
182 static void
183 dump_decl_name (pretty_printer *pp, tree node, int flags)
185 if (DECL_NAME (node))
187 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
188 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
189 else
190 pp_tree_identifier (pp, DECL_NAME (node));
192 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
194 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
195 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
196 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
198 if (flags & TDF_NOUID)
199 pp_string (pp, "D#xxxx");
200 else
201 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
203 else
205 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
206 if (flags & TDF_NOUID)
207 pp_printf (pp, "%c.xxxx", c);
208 else
209 pp_printf (pp, "%c.%u", c, DECL_UID (node));
212 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
214 if (flags & TDF_NOUID)
215 pp_printf (pp, "ptD.xxxx");
216 else
217 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
221 /* Like the above, but used for pretty printing function calls. */
223 static void
224 dump_function_name (pretty_printer *pp, tree node, int flags)
226 if (CONVERT_EXPR_P (node))
227 node = TREE_OPERAND (node, 0);
228 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
229 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
230 else
231 dump_decl_name (pp, node, flags);
234 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
235 FLAGS are as in dump_generic_node. */
237 static void
238 dump_function_declaration (pretty_printer *pp, tree node,
239 int spc, int flags)
241 bool wrote_arg = false;
242 tree arg;
244 pp_space (pp);
245 pp_left_paren (pp);
247 /* Print the argument types. */
248 arg = TYPE_ARG_TYPES (node);
249 while (arg && arg != void_list_node && arg != error_mark_node)
251 if (wrote_arg)
253 pp_comma (pp);
254 pp_space (pp);
256 wrote_arg = true;
257 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
258 arg = TREE_CHAIN (arg);
261 /* Drop the trailing void_type_node if we had any previous argument. */
262 if (arg == void_list_node && !wrote_arg)
263 pp_string (pp, "void");
264 /* Properly dump vararg function types. */
265 else if (!arg && wrote_arg)
266 pp_string (pp, ", ...");
267 /* Avoid printing any arg for unprototyped functions. */
269 pp_right_paren (pp);
272 /* Dump the domain associated with an array. */
274 static void
275 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
277 pp_left_bracket (pp);
278 if (domain)
280 tree min = TYPE_MIN_VALUE (domain);
281 tree max = TYPE_MAX_VALUE (domain);
283 if (min && max
284 && integer_zerop (min)
285 && tree_fits_shwi_p (max))
286 pp_wide_integer (pp, tree_to_shwi (max) + 1);
287 else
289 if (min)
290 dump_generic_node (pp, min, spc, flags, false);
291 pp_colon (pp);
292 if (max)
293 dump_generic_node (pp, max, spc, flags, false);
296 else
297 pp_string (pp, "<unknown>");
298 pp_right_bracket (pp);
302 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
303 dump_generic_node. */
305 static void
306 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
308 const char *name;
310 switch (OMP_CLAUSE_CODE (clause))
312 case OMP_CLAUSE_PRIVATE:
313 name = "private";
314 goto print_remap;
315 case OMP_CLAUSE_SHARED:
316 name = "shared";
317 goto print_remap;
318 case OMP_CLAUSE_FIRSTPRIVATE:
319 name = "firstprivate";
320 goto print_remap;
321 case OMP_CLAUSE_LASTPRIVATE:
322 name = "lastprivate";
323 goto print_remap;
324 case OMP_CLAUSE_COPYIN:
325 name = "copyin";
326 goto print_remap;
327 case OMP_CLAUSE_COPYPRIVATE:
328 name = "copyprivate";
329 goto print_remap;
330 case OMP_CLAUSE_UNIFORM:
331 name = "uniform";
332 goto print_remap;
333 case OMP_CLAUSE_USE_DEVICE_PTR:
334 name = "use_device_ptr";
335 goto print_remap;
336 case OMP_CLAUSE_IS_DEVICE_PTR:
337 name = "is_device_ptr";
338 goto print_remap;
339 case OMP_CLAUSE__LOOPTEMP_:
340 name = "_looptemp_";
341 goto print_remap;
342 case OMP_CLAUSE_DEVICE_RESIDENT:
343 name = "device_resident";
344 goto print_remap;
345 case OMP_CLAUSE_USE_DEVICE:
346 name = "use_device";
347 goto print_remap;
348 case OMP_CLAUSE_TO_DECLARE:
349 name = "to";
350 goto print_remap;
351 case OMP_CLAUSE_LINK:
352 name = "link";
353 goto print_remap;
354 print_remap:
355 pp_string (pp, name);
356 pp_left_paren (pp);
357 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
358 spc, flags, false);
359 pp_right_paren (pp);
360 break;
362 case OMP_CLAUSE_REDUCTION:
363 pp_string (pp, "reduction(");
364 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
366 pp_string (pp,
367 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
368 pp_colon (pp);
370 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
371 spc, flags, false);
372 pp_right_paren (pp);
373 break;
375 case OMP_CLAUSE_IF:
376 pp_string (pp, "if(");
377 switch (OMP_CLAUSE_IF_MODIFIER (clause))
379 case ERROR_MARK: break;
380 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
381 case OMP_TASK: pp_string (pp, "task:"); break;
382 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
383 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
384 case OMP_TARGET: pp_string (pp, "target:"); break;
385 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
386 case OMP_TARGET_ENTER_DATA:
387 pp_string (pp, "target enter data:"); break;
388 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
389 default: gcc_unreachable ();
391 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
392 spc, flags, false);
393 pp_right_paren (pp);
394 break;
396 case OMP_CLAUSE_NUM_THREADS:
397 pp_string (pp, "num_threads(");
398 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
399 spc, flags, false);
400 pp_right_paren (pp);
401 break;
403 case OMP_CLAUSE__CILK_FOR_COUNT_:
404 pp_string (pp, "_Cilk_for_count_(");
405 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
406 spc, flags, false);
407 pp_right_paren (pp);
408 break;
410 case OMP_CLAUSE_NOWAIT:
411 pp_string (pp, "nowait");
412 break;
413 case OMP_CLAUSE_ORDERED:
414 pp_string (pp, "ordered");
415 if (OMP_CLAUSE_ORDERED_EXPR (clause))
417 pp_left_paren (pp);
418 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
419 spc, flags, false);
420 pp_right_paren (pp);
422 break;
424 case OMP_CLAUSE_DEFAULT:
425 pp_string (pp, "default(");
426 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
428 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
429 break;
430 case OMP_CLAUSE_DEFAULT_SHARED:
431 pp_string (pp, "shared");
432 break;
433 case OMP_CLAUSE_DEFAULT_NONE:
434 pp_string (pp, "none");
435 break;
436 case OMP_CLAUSE_DEFAULT_PRIVATE:
437 pp_string (pp, "private");
438 break;
439 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
440 pp_string (pp, "firstprivate");
441 break;
442 default:
443 gcc_unreachable ();
445 pp_right_paren (pp);
446 break;
448 case OMP_CLAUSE_SCHEDULE:
449 pp_string (pp, "schedule(");
450 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
451 pp_string (pp, "simd:");
452 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
454 case OMP_CLAUSE_SCHEDULE_STATIC:
455 pp_string (pp, "static");
456 break;
457 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
458 pp_string (pp, "dynamic");
459 break;
460 case OMP_CLAUSE_SCHEDULE_GUIDED:
461 pp_string (pp, "guided");
462 break;
463 case OMP_CLAUSE_SCHEDULE_RUNTIME:
464 pp_string (pp, "runtime");
465 break;
466 case OMP_CLAUSE_SCHEDULE_AUTO:
467 pp_string (pp, "auto");
468 break;
469 case OMP_CLAUSE_SCHEDULE_CILKFOR:
470 pp_string (pp, "cilk-for grain");
471 break;
472 default:
473 gcc_unreachable ();
475 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
477 pp_comma (pp);
478 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
479 spc, flags, false);
481 pp_right_paren (pp);
482 break;
484 case OMP_CLAUSE_UNTIED:
485 pp_string (pp, "untied");
486 break;
488 case OMP_CLAUSE_COLLAPSE:
489 pp_string (pp, "collapse(");
490 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
491 spc, flags, false);
492 pp_right_paren (pp);
493 break;
495 case OMP_CLAUSE_FINAL:
496 pp_string (pp, "final(");
497 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
498 spc, flags, false);
499 pp_right_paren (pp);
500 break;
502 case OMP_CLAUSE_MERGEABLE:
503 pp_string (pp, "mergeable");
504 break;
506 case OMP_CLAUSE_LINEAR:
507 pp_string (pp, "linear(");
508 switch (OMP_CLAUSE_LINEAR_KIND (clause))
510 case OMP_CLAUSE_LINEAR_DEFAULT:
511 break;
512 case OMP_CLAUSE_LINEAR_REF:
513 pp_string (pp, "ref(");
514 break;
515 case OMP_CLAUSE_LINEAR_VAL:
516 pp_string (pp, "val(");
517 break;
518 case OMP_CLAUSE_LINEAR_UVAL:
519 pp_string (pp, "uval(");
520 break;
521 default:
522 gcc_unreachable ();
524 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
525 spc, flags, false);
526 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
527 pp_right_paren (pp);
528 pp_colon (pp);
529 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
530 spc, flags, false);
531 pp_right_paren (pp);
532 break;
534 case OMP_CLAUSE_ALIGNED:
535 pp_string (pp, "aligned(");
536 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
537 spc, flags, false);
538 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
540 pp_colon (pp);
541 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
542 spc, flags, false);
544 pp_right_paren (pp);
545 break;
547 case OMP_CLAUSE_DEPEND:
548 pp_string (pp, "depend(");
549 switch (OMP_CLAUSE_DEPEND_KIND (clause))
551 case OMP_CLAUSE_DEPEND_IN:
552 pp_string (pp, "in");
553 break;
554 case OMP_CLAUSE_DEPEND_OUT:
555 pp_string (pp, "out");
556 break;
557 case OMP_CLAUSE_DEPEND_INOUT:
558 pp_string (pp, "inout");
559 break;
560 case OMP_CLAUSE_DEPEND_SOURCE:
561 pp_string (pp, "source)");
562 return;
563 case OMP_CLAUSE_DEPEND_SINK:
564 pp_string (pp, "sink:");
565 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
566 if (TREE_CODE (t) == TREE_LIST)
568 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
569 if (TREE_PURPOSE (t) != integer_zero_node)
571 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
572 pp_minus (pp);
573 else
574 pp_plus (pp);
575 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
576 false);
578 if (TREE_CHAIN (t))
579 pp_comma (pp);
581 else
582 gcc_unreachable ();
583 pp_right_paren (pp);
584 return;
585 default:
586 gcc_unreachable ();
588 pp_colon (pp);
589 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
590 spc, flags, false);
591 pp_right_paren (pp);
592 break;
594 case OMP_CLAUSE_MAP:
595 pp_string (pp, "map(");
596 switch (OMP_CLAUSE_MAP_KIND (clause))
598 case GOMP_MAP_ALLOC:
599 case GOMP_MAP_POINTER:
600 pp_string (pp, "alloc");
601 break;
602 case GOMP_MAP_TO:
603 case GOMP_MAP_TO_PSET:
604 pp_string (pp, "to");
605 break;
606 case GOMP_MAP_FROM:
607 pp_string (pp, "from");
608 break;
609 case GOMP_MAP_TOFROM:
610 pp_string (pp, "tofrom");
611 break;
612 case GOMP_MAP_FORCE_ALLOC:
613 pp_string (pp, "force_alloc");
614 break;
615 case GOMP_MAP_FORCE_TO:
616 pp_string (pp, "force_to");
617 break;
618 case GOMP_MAP_FORCE_FROM:
619 pp_string (pp, "force_from");
620 break;
621 case GOMP_MAP_FORCE_TOFROM:
622 pp_string (pp, "force_tofrom");
623 break;
624 case GOMP_MAP_FORCE_PRESENT:
625 pp_string (pp, "force_present");
626 break;
627 case GOMP_MAP_FORCE_DEALLOC:
628 pp_string (pp, "delete");
629 break;
630 case GOMP_MAP_FORCE_DEVICEPTR:
631 pp_string (pp, "force_deviceptr");
632 break;
633 case GOMP_MAP_ALWAYS_TO:
634 pp_string (pp, "always,to");
635 break;
636 case GOMP_MAP_ALWAYS_FROM:
637 pp_string (pp, "always,from");
638 break;
639 case GOMP_MAP_ALWAYS_TOFROM:
640 pp_string (pp, "always,tofrom");
641 break;
642 case GOMP_MAP_RELEASE:
643 pp_string (pp, "release");
644 break;
645 case GOMP_MAP_FIRSTPRIVATE_POINTER:
646 pp_string (pp, "firstprivate");
647 break;
648 case GOMP_MAP_STRUCT:
649 pp_string (pp, "struct");
650 break;
651 default:
652 gcc_unreachable ();
654 pp_colon (pp);
655 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
656 spc, flags, false);
657 print_clause_size:
658 if (OMP_CLAUSE_SIZE (clause))
660 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
661 && (OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER
662 || OMP_CLAUSE_MAP_KIND (clause)
663 == GOMP_MAP_FIRSTPRIVATE_POINTER))
664 pp_string (pp, " [pointer assign, bias: ");
665 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
666 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET)
667 pp_string (pp, " [pointer set, len: ");
668 else
669 pp_string (pp, " [len: ");
670 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
671 spc, flags, false);
672 pp_right_bracket (pp);
674 pp_right_paren (pp);
675 break;
677 case OMP_CLAUSE_FROM:
678 pp_string (pp, "from(");
679 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
680 spc, flags, false);
681 goto print_clause_size;
683 case OMP_CLAUSE_TO:
684 pp_string (pp, "to(");
685 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
686 spc, flags, false);
687 goto print_clause_size;
689 case OMP_CLAUSE__CACHE_:
690 pp_string (pp, "(");
691 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
692 spc, flags, false);
693 goto print_clause_size;
695 case OMP_CLAUSE_NUM_TEAMS:
696 pp_string (pp, "num_teams(");
697 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
698 spc, flags, false);
699 pp_right_paren (pp);
700 break;
702 case OMP_CLAUSE_THREAD_LIMIT:
703 pp_string (pp, "thread_limit(");
704 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
705 spc, flags, false);
706 pp_right_paren (pp);
707 break;
709 case OMP_CLAUSE_DEVICE:
710 pp_string (pp, "device(");
711 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
712 spc, flags, false);
713 pp_right_paren (pp);
714 break;
716 case OMP_CLAUSE_DIST_SCHEDULE:
717 pp_string (pp, "dist_schedule(static");
718 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
720 pp_comma (pp);
721 dump_generic_node (pp,
722 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
723 spc, flags, false);
725 pp_right_paren (pp);
726 break;
728 case OMP_CLAUSE_PROC_BIND:
729 pp_string (pp, "proc_bind(");
730 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
732 case OMP_CLAUSE_PROC_BIND_MASTER:
733 pp_string (pp, "master");
734 break;
735 case OMP_CLAUSE_PROC_BIND_CLOSE:
736 pp_string (pp, "close");
737 break;
738 case OMP_CLAUSE_PROC_BIND_SPREAD:
739 pp_string (pp, "spread");
740 break;
741 default:
742 gcc_unreachable ();
744 pp_right_paren (pp);
745 break;
747 case OMP_CLAUSE_SAFELEN:
748 pp_string (pp, "safelen(");
749 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
750 spc, flags, false);
751 pp_right_paren (pp);
752 break;
754 case OMP_CLAUSE_SIMDLEN:
755 pp_string (pp, "simdlen(");
756 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
757 spc, flags, false);
758 pp_right_paren (pp);
759 break;
761 case OMP_CLAUSE_PRIORITY:
762 pp_string (pp, "priority(");
763 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
764 spc, flags, false);
765 pp_right_paren (pp);
766 break;
768 case OMP_CLAUSE_GRAINSIZE:
769 pp_string (pp, "grainsize(");
770 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
771 spc, flags, false);
772 pp_right_paren (pp);
773 break;
775 case OMP_CLAUSE_NUM_TASKS:
776 pp_string (pp, "num_tasks(");
777 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
778 spc, flags, false);
779 pp_right_paren (pp);
780 break;
782 case OMP_CLAUSE_HINT:
783 pp_string (pp, "hint(");
784 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
785 spc, flags, false);
786 pp_right_paren (pp);
787 break;
789 case OMP_CLAUSE_DEFAULTMAP:
790 pp_string (pp, "defaultmap(tofrom:scalar)");
791 break;
793 case OMP_CLAUSE__SIMDUID_:
794 pp_string (pp, "_simduid_(");
795 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
796 spc, flags, false);
797 pp_right_paren (pp);
798 break;
800 case OMP_CLAUSE_GANG:
801 pp_string (pp, "gang");
802 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
804 pp_string (pp, "(num: ");
805 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
806 spc, flags, false);
808 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
810 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
811 pp_left_paren (pp);
812 else
813 pp_space (pp);
814 pp_string (pp, "static:");
815 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
816 == integer_minus_one_node)
817 pp_character (pp, '*');
818 else
819 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
820 spc, flags, false);
822 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
823 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
824 pp_right_paren (pp);
825 break;
827 case OMP_CLAUSE_ASYNC:
828 pp_string (pp, "async");
829 if (OMP_CLAUSE_ASYNC_EXPR (clause))
831 pp_character(pp, '(');
832 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
833 spc, flags, false);
834 pp_character(pp, ')');
836 break;
838 case OMP_CLAUSE_AUTO:
839 case OMP_CLAUSE_SEQ:
840 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
841 break;
843 case OMP_CLAUSE_WAIT:
844 pp_string (pp, "wait(");
845 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
846 spc, flags, false);
847 pp_character(pp, ')');
848 break;
850 case OMP_CLAUSE_WORKER:
851 pp_string (pp, "worker");
852 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
854 pp_left_paren (pp);
855 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
856 spc, flags, false);
857 pp_right_paren (pp);
859 break;
861 case OMP_CLAUSE_VECTOR:
862 pp_string (pp, "vector");
863 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
865 pp_left_paren (pp);
866 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
867 spc, flags, false);
868 pp_right_paren (pp);
870 break;
872 case OMP_CLAUSE_NUM_GANGS:
873 pp_string (pp, "num_gangs(");
874 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
875 spc, flags, false);
876 pp_character (pp, ')');
877 break;
879 case OMP_CLAUSE_NUM_WORKERS:
880 pp_string (pp, "num_workers(");
881 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
882 spc, flags, false);
883 pp_character (pp, ')');
884 break;
886 case OMP_CLAUSE_VECTOR_LENGTH:
887 pp_string (pp, "vector_length(");
888 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
889 spc, flags, false);
890 pp_character (pp, ')');
891 break;
893 case OMP_CLAUSE_INBRANCH:
894 pp_string (pp, "inbranch");
895 break;
896 case OMP_CLAUSE_NOTINBRANCH:
897 pp_string (pp, "notinbranch");
898 break;
899 case OMP_CLAUSE_FOR:
900 pp_string (pp, "for");
901 break;
902 case OMP_CLAUSE_PARALLEL:
903 pp_string (pp, "parallel");
904 break;
905 case OMP_CLAUSE_SECTIONS:
906 pp_string (pp, "sections");
907 break;
908 case OMP_CLAUSE_TASKGROUP:
909 pp_string (pp, "taskgroup");
910 break;
911 case OMP_CLAUSE_NOGROUP:
912 pp_string (pp, "nogroup");
913 break;
914 case OMP_CLAUSE_THREADS:
915 pp_string (pp, "threads");
916 break;
917 case OMP_CLAUSE_SIMD:
918 pp_string (pp, "simd");
919 break;
920 case OMP_CLAUSE_INDEPENDENT:
921 pp_string (pp, "independent");
922 break;
924 default:
925 /* Should never happen. */
926 dump_generic_node (pp, clause, spc, flags, false);
927 break;
932 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
933 dump_generic_node. */
935 void
936 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
938 if (clause == NULL)
939 return;
941 pp_space (pp);
942 while (1)
944 dump_omp_clause (pp, clause, spc, flags);
945 clause = OMP_CLAUSE_CHAIN (clause);
946 if (clause == NULL)
947 return;
948 pp_space (pp);
953 /* Dump location LOC to PP. */
955 void
956 dump_location (pretty_printer *pp, location_t loc)
958 expanded_location xloc = expand_location (loc);
960 pp_left_bracket (pp);
961 if (xloc.file)
963 pp_string (pp, xloc.file);
964 pp_string (pp, ":");
966 pp_decimal_int (pp, xloc.line);
967 pp_colon (pp);
968 pp_decimal_int (pp, xloc.column);
969 pp_string (pp, "] ");
973 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
974 dump_generic_node. */
976 static void
977 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
979 tree t;
981 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
983 if (flags & TDF_ADDRESS)
984 pp_printf (pp, "[%p] ", (void *) block);
986 if (BLOCK_ABSTRACT (block))
987 pp_string (pp, "[abstract] ");
989 if (TREE_ASM_WRITTEN (block))
990 pp_string (pp, "[written] ");
992 if (flags & TDF_SLIM)
993 return;
995 if (BLOCK_SOURCE_LOCATION (block))
996 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
998 newline_and_indent (pp, spc + 2);
1000 if (BLOCK_SUPERCONTEXT (block))
1002 pp_string (pp, "SUPERCONTEXT: ");
1003 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1004 flags | TDF_SLIM, false);
1005 newline_and_indent (pp, spc + 2);
1008 if (BLOCK_SUBBLOCKS (block))
1010 pp_string (pp, "SUBBLOCKS: ");
1011 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1013 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1014 pp_space (pp);
1016 newline_and_indent (pp, spc + 2);
1019 if (BLOCK_CHAIN (block))
1021 pp_string (pp, "SIBLINGS: ");
1022 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1024 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1025 pp_space (pp);
1027 newline_and_indent (pp, spc + 2);
1030 if (BLOCK_VARS (block))
1032 pp_string (pp, "VARS: ");
1033 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1035 dump_generic_node (pp, t, 0, flags, false);
1036 pp_space (pp);
1038 newline_and_indent (pp, spc + 2);
1041 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1043 unsigned i;
1044 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1046 pp_string (pp, "NONLOCALIZED_VARS: ");
1047 FOR_EACH_VEC_ELT (*nlv, i, t)
1049 dump_generic_node (pp, t, 0, flags, false);
1050 pp_space (pp);
1052 newline_and_indent (pp, spc + 2);
1055 if (BLOCK_ABSTRACT_ORIGIN (block))
1057 pp_string (pp, "ABSTRACT_ORIGIN: ");
1058 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1059 flags | TDF_SLIM, false);
1060 newline_and_indent (pp, spc + 2);
1063 if (BLOCK_FRAGMENT_ORIGIN (block))
1065 pp_string (pp, "FRAGMENT_ORIGIN: ");
1066 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1067 flags | TDF_SLIM, false);
1068 newline_and_indent (pp, spc + 2);
1071 if (BLOCK_FRAGMENT_CHAIN (block))
1073 pp_string (pp, "FRAGMENT_CHAIN: ");
1074 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1076 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1077 pp_space (pp);
1079 newline_and_indent (pp, spc + 2);
1084 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1085 indent. FLAGS specifies details to show in the dump (see TDF_* in
1086 dumpfile.h). If IS_STMT is true, the object printed is considered
1087 to be a statement and it is terminated by ';' if appropriate. */
1090 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
1091 bool is_stmt)
1093 tree type;
1094 tree op0, op1;
1095 const char *str;
1096 bool is_expr;
1097 enum tree_code code;
1099 if (node == NULL_TREE)
1100 return spc;
1102 is_expr = EXPR_P (node);
1104 if (is_stmt && (flags & TDF_STMTADDR))
1105 pp_printf (pp, "<&%p> ", (void *)node);
1107 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1108 dump_location (pp, EXPR_LOCATION (node));
1110 code = TREE_CODE (node);
1111 switch (code)
1113 case ERROR_MARK:
1114 pp_string (pp, "<<< error >>>");
1115 break;
1117 case IDENTIFIER_NODE:
1118 pp_tree_identifier (pp, node);
1119 break;
1121 case TREE_LIST:
1122 while (node && node != error_mark_node)
1124 if (TREE_PURPOSE (node))
1126 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1127 pp_space (pp);
1129 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1130 node = TREE_CHAIN (node);
1131 if (node && TREE_CODE (node) == TREE_LIST)
1133 pp_comma (pp);
1134 pp_space (pp);
1137 break;
1139 case TREE_BINFO:
1140 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1141 break;
1143 case TREE_VEC:
1145 size_t i;
1146 if (TREE_VEC_LENGTH (node) > 0)
1148 size_t len = TREE_VEC_LENGTH (node);
1149 for (i = 0; i < len - 1; i++)
1151 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1152 false);
1153 pp_comma (pp);
1154 pp_space (pp);
1156 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1157 flags, false);
1160 break;
1162 case VOID_TYPE:
1163 case POINTER_BOUNDS_TYPE:
1164 case INTEGER_TYPE:
1165 case REAL_TYPE:
1166 case FIXED_POINT_TYPE:
1167 case COMPLEX_TYPE:
1168 case VECTOR_TYPE:
1169 case ENUMERAL_TYPE:
1170 case BOOLEAN_TYPE:
1172 unsigned int quals = TYPE_QUALS (node);
1173 enum tree_code_class tclass;
1175 if (quals & TYPE_QUAL_ATOMIC)
1176 pp_string (pp, "atomic ");
1177 if (quals & TYPE_QUAL_CONST)
1178 pp_string (pp, "const ");
1179 else if (quals & TYPE_QUAL_VOLATILE)
1180 pp_string (pp, "volatile ");
1181 else if (quals & TYPE_QUAL_RESTRICT)
1182 pp_string (pp, "restrict ");
1184 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1186 pp_string (pp, "<address-space-");
1187 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1188 pp_string (pp, "> ");
1191 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1193 if (tclass == tcc_declaration)
1195 if (DECL_NAME (node))
1196 dump_decl_name (pp, node, flags);
1197 else
1198 pp_string (pp, "<unnamed type decl>");
1200 else if (tclass == tcc_type)
1202 if (TYPE_NAME (node))
1204 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1205 pp_tree_identifier (pp, TYPE_NAME (node));
1206 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1207 && DECL_NAME (TYPE_NAME (node)))
1208 dump_decl_name (pp, TYPE_NAME (node), flags);
1209 else
1210 pp_string (pp, "<unnamed type>");
1212 else if (TREE_CODE (node) == VECTOR_TYPE)
1214 pp_string (pp, "vector");
1215 pp_left_paren (pp);
1216 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1217 pp_string (pp, ") ");
1218 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1220 else if (TREE_CODE (node) == INTEGER_TYPE)
1222 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1223 pp_string (pp, (TYPE_UNSIGNED (node)
1224 ? "unsigned char"
1225 : "signed char"));
1226 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1227 pp_string (pp, (TYPE_UNSIGNED (node)
1228 ? "unsigned short"
1229 : "signed short"));
1230 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1231 pp_string (pp, (TYPE_UNSIGNED (node)
1232 ? "unsigned int"
1233 : "signed int"));
1234 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1235 pp_string (pp, (TYPE_UNSIGNED (node)
1236 ? "unsigned long"
1237 : "signed long"));
1238 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1239 pp_string (pp, (TYPE_UNSIGNED (node)
1240 ? "unsigned long long"
1241 : "signed long long"));
1242 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1243 && exact_log2 (TYPE_PRECISION (node)) != -1)
1245 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1246 pp_decimal_int (pp, TYPE_PRECISION (node));
1247 pp_string (pp, "_t");
1249 else
1251 pp_string (pp, (TYPE_UNSIGNED (node)
1252 ? "<unnamed-unsigned:"
1253 : "<unnamed-signed:"));
1254 pp_decimal_int (pp, TYPE_PRECISION (node));
1255 pp_greater (pp);
1258 else if (TREE_CODE (node) == COMPLEX_TYPE)
1260 pp_string (pp, "__complex__ ");
1261 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1263 else if (TREE_CODE (node) == REAL_TYPE)
1265 pp_string (pp, "<float:");
1266 pp_decimal_int (pp, TYPE_PRECISION (node));
1267 pp_greater (pp);
1269 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1271 pp_string (pp, "<fixed-point-");
1272 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1273 pp_decimal_int (pp, TYPE_PRECISION (node));
1274 pp_greater (pp);
1276 else if (TREE_CODE (node) == VOID_TYPE)
1277 pp_string (pp, "void");
1278 else
1279 pp_string (pp, "<unnamed type>");
1281 break;
1284 case POINTER_TYPE:
1285 case REFERENCE_TYPE:
1286 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1288 if (TREE_TYPE (node) == NULL)
1290 pp_string (pp, str);
1291 pp_string (pp, "<null type>");
1293 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1295 tree fnode = TREE_TYPE (node);
1297 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1298 pp_space (pp);
1299 pp_left_paren (pp);
1300 pp_string (pp, str);
1301 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1302 dump_decl_name (pp, TYPE_NAME (node), flags);
1303 else if (flags & TDF_NOUID)
1304 pp_printf (pp, "<Txxxx>");
1305 else
1306 pp_printf (pp, "<T%x>", TYPE_UID (node));
1308 pp_right_paren (pp);
1309 dump_function_declaration (pp, fnode, spc, flags);
1311 else
1313 unsigned int quals = TYPE_QUALS (node);
1315 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1316 pp_space (pp);
1317 pp_string (pp, str);
1319 if (quals & TYPE_QUAL_CONST)
1320 pp_string (pp, " const");
1321 if (quals & TYPE_QUAL_VOLATILE)
1322 pp_string (pp, " volatile");
1323 if (quals & TYPE_QUAL_RESTRICT)
1324 pp_string (pp, " restrict");
1326 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1328 pp_string (pp, " <address-space-");
1329 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1330 pp_greater (pp);
1333 if (TYPE_REF_CAN_ALIAS_ALL (node))
1334 pp_string (pp, " {ref-all}");
1336 break;
1338 case OFFSET_TYPE:
1339 NIY;
1340 break;
1342 case MEM_REF:
1344 if (integer_zerop (TREE_OPERAND (node, 1))
1345 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1346 infer them and MEM_ATTR caching will share MEM_REFs
1347 with differently-typed op0s. */
1348 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1349 /* Released SSA_NAMES have no TREE_TYPE. */
1350 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1351 /* Same pointer types, but ignoring POINTER_TYPE vs.
1352 REFERENCE_TYPE. */
1353 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1354 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1355 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1356 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1357 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1358 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1359 /* Same value types ignoring qualifiers. */
1360 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1361 == TYPE_MAIN_VARIANT
1362 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1363 && (!(flags & TDF_ALIAS)
1364 || MR_DEPENDENCE_CLIQUE (node) == 0))
1366 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1368 pp_star (pp);
1369 dump_generic_node (pp, TREE_OPERAND (node, 0),
1370 spc, flags, false);
1372 else
1373 dump_generic_node (pp,
1374 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1375 spc, flags, false);
1377 else
1379 tree ptype;
1381 pp_string (pp, "MEM[");
1382 pp_left_paren (pp);
1383 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1384 dump_generic_node (pp, ptype,
1385 spc, flags | TDF_SLIM, false);
1386 pp_right_paren (pp);
1387 dump_generic_node (pp, TREE_OPERAND (node, 0),
1388 spc, flags, false);
1389 if (!integer_zerop (TREE_OPERAND (node, 1)))
1391 pp_string (pp, " + ");
1392 dump_generic_node (pp, TREE_OPERAND (node, 1),
1393 spc, flags, false);
1395 if ((flags & TDF_ALIAS)
1396 && MR_DEPENDENCE_CLIQUE (node) != 0)
1398 pp_string (pp, " clique ");
1399 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1400 pp_string (pp, " base ");
1401 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1403 pp_right_bracket (pp);
1405 break;
1408 case TARGET_MEM_REF:
1410 const char *sep = "";
1411 tree tmp;
1413 pp_string (pp, "MEM[");
1415 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1417 pp_string (pp, sep);
1418 sep = ", ";
1419 pp_string (pp, "symbol: ");
1420 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1421 spc, flags, false);
1423 else
1425 pp_string (pp, sep);
1426 sep = ", ";
1427 pp_string (pp, "base: ");
1428 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1430 tmp = TMR_INDEX2 (node);
1431 if (tmp)
1433 pp_string (pp, sep);
1434 sep = ", ";
1435 pp_string (pp, "base: ");
1436 dump_generic_node (pp, tmp, spc, flags, false);
1438 tmp = TMR_INDEX (node);
1439 if (tmp)
1441 pp_string (pp, sep);
1442 sep = ", ";
1443 pp_string (pp, "index: ");
1444 dump_generic_node (pp, tmp, spc, flags, false);
1446 tmp = TMR_STEP (node);
1447 if (tmp)
1449 pp_string (pp, sep);
1450 sep = ", ";
1451 pp_string (pp, "step: ");
1452 dump_generic_node (pp, tmp, spc, flags, false);
1454 tmp = TMR_OFFSET (node);
1455 if (tmp)
1457 pp_string (pp, sep);
1458 sep = ", ";
1459 pp_string (pp, "offset: ");
1460 dump_generic_node (pp, tmp, spc, flags, false);
1462 pp_right_bracket (pp);
1464 break;
1466 case ARRAY_TYPE:
1468 tree tmp;
1470 /* Print the innermost component type. */
1471 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1472 tmp = TREE_TYPE (tmp))
1474 dump_generic_node (pp, tmp, spc, flags, false);
1476 /* Print the dimensions. */
1477 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1478 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1479 break;
1482 case RECORD_TYPE:
1483 case UNION_TYPE:
1484 case QUAL_UNION_TYPE:
1486 unsigned int quals = TYPE_QUALS (node);
1488 if (quals & TYPE_QUAL_ATOMIC)
1489 pp_string (pp, "atomic ");
1490 if (quals & TYPE_QUAL_CONST)
1491 pp_string (pp, "const ");
1492 if (quals & TYPE_QUAL_VOLATILE)
1493 pp_string (pp, "volatile ");
1495 /* Print the name of the structure. */
1496 if (TREE_CODE (node) == RECORD_TYPE)
1497 pp_string (pp, "struct ");
1498 else if (TREE_CODE (node) == UNION_TYPE)
1499 pp_string (pp, "union ");
1501 if (TYPE_NAME (node))
1502 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1503 else if (!(flags & TDF_SLIM))
1504 /* FIXME: If we eliminate the 'else' above and attempt
1505 to show the fields for named types, we may get stuck
1506 following a cycle of pointers to structs. The alleged
1507 self-reference check in print_struct_decl will not detect
1508 cycles involving more than one pointer or struct type. */
1509 print_struct_decl (pp, node, spc, flags);
1510 break;
1513 case LANG_TYPE:
1514 NIY;
1515 break;
1517 case INTEGER_CST:
1518 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1520 /* In the case of a pointer, one may want to divide by the
1521 size of the pointed-to type. Unfortunately, this not
1522 straightforward. The C front-end maps expressions
1524 (int *) 5
1525 int *p; (p + 5)
1527 in such a way that the two INTEGER_CST nodes for "5" have
1528 different values but identical types. In the latter
1529 case, the 5 is multiplied by sizeof (int) in c-common.c
1530 (pointer_int_sum) to convert it to a byte address, and
1531 yet the type of the node is left unchanged. Argh. What
1532 is consistent though is that the number value corresponds
1533 to bytes (UNITS) offset.
1535 NB: Neither of the following divisors can be trivially
1536 used to recover the original literal:
1538 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1539 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1540 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1541 pp_string (pp, "B"); /* pseudo-unit */
1543 else if (tree_fits_shwi_p (node))
1544 pp_wide_integer (pp, tree_to_shwi (node));
1545 else if (tree_fits_uhwi_p (node))
1546 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1547 else
1549 wide_int val = node;
1551 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1553 pp_minus (pp);
1554 val = -val;
1556 print_hex (val, pp_buffer (pp)->digit_buffer);
1557 pp_string (pp, pp_buffer (pp)->digit_buffer);
1559 if (TREE_OVERFLOW (node))
1560 pp_string (pp, "(OVF)");
1561 break;
1563 case REAL_CST:
1564 /* Code copied from print_node. */
1566 REAL_VALUE_TYPE d;
1567 if (TREE_OVERFLOW (node))
1568 pp_string (pp, " overflow");
1570 d = TREE_REAL_CST (node);
1571 if (REAL_VALUE_ISINF (d))
1572 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1573 else if (REAL_VALUE_ISNAN (d))
1574 pp_string (pp, " Nan");
1575 else
1577 char string[100];
1578 real_to_decimal (string, &d, sizeof (string), 0, 1);
1579 pp_string (pp, string);
1581 break;
1584 case FIXED_CST:
1586 char string[100];
1587 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1588 pp_string (pp, string);
1589 break;
1592 case COMPLEX_CST:
1593 pp_string (pp, "__complex__ (");
1594 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1595 pp_string (pp, ", ");
1596 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1597 pp_right_paren (pp);
1598 break;
1600 case STRING_CST:
1601 pp_string (pp, "\"");
1602 pretty_print_string (pp, TREE_STRING_POINTER (node));
1603 pp_string (pp, "\"");
1604 break;
1606 case VECTOR_CST:
1608 unsigned i;
1609 pp_string (pp, "{ ");
1610 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1612 if (i != 0)
1613 pp_string (pp, ", ");
1614 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1615 spc, flags, false);
1617 pp_string (pp, " }");
1619 break;
1621 case FUNCTION_TYPE:
1622 case METHOD_TYPE:
1623 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1624 pp_space (pp);
1625 if (TREE_CODE (node) == METHOD_TYPE)
1627 if (TYPE_METHOD_BASETYPE (node))
1628 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1629 flags);
1630 else
1631 pp_string (pp, "<null method basetype>");
1632 pp_colon_colon (pp);
1634 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1635 dump_decl_name (pp, TYPE_NAME (node), flags);
1636 else if (flags & TDF_NOUID)
1637 pp_printf (pp, "<Txxxx>");
1638 else
1639 pp_printf (pp, "<T%x>", TYPE_UID (node));
1640 dump_function_declaration (pp, node, spc, flags);
1641 break;
1643 case FUNCTION_DECL:
1644 case CONST_DECL:
1645 dump_decl_name (pp, node, flags);
1646 break;
1648 case LABEL_DECL:
1649 if (DECL_NAME (node))
1650 dump_decl_name (pp, node, flags);
1651 else if (LABEL_DECL_UID (node) != -1)
1652 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1653 else
1655 if (flags & TDF_NOUID)
1656 pp_string (pp, "<D.xxxx>");
1657 else
1658 pp_printf (pp, "<D.%u>", DECL_UID (node));
1660 break;
1662 case TYPE_DECL:
1663 if (DECL_IS_BUILTIN (node))
1665 /* Don't print the declaration of built-in types. */
1666 break;
1668 if (DECL_NAME (node))
1669 dump_decl_name (pp, node, flags);
1670 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1672 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1673 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1674 && TYPE_METHODS (TREE_TYPE (node)))
1676 /* The type is a c++ class: all structures have at least
1677 4 methods. */
1678 pp_string (pp, "class ");
1679 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1681 else
1683 pp_string (pp,
1684 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1685 ? "union" : "struct "));
1686 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1689 else
1690 pp_string (pp, "<anon>");
1691 break;
1693 case VAR_DECL:
1694 case PARM_DECL:
1695 case FIELD_DECL:
1696 case DEBUG_EXPR_DECL:
1697 case NAMESPACE_DECL:
1698 case NAMELIST_DECL:
1699 dump_decl_name (pp, node, flags);
1700 break;
1702 case RESULT_DECL:
1703 pp_string (pp, "<retval>");
1704 break;
1706 case COMPONENT_REF:
1707 op0 = TREE_OPERAND (node, 0);
1708 str = ".";
1709 if (op0
1710 && (TREE_CODE (op0) == INDIRECT_REF
1711 || (TREE_CODE (op0) == MEM_REF
1712 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1713 && integer_zerop (TREE_OPERAND (op0, 1))
1714 /* Dump the types of INTEGER_CSTs explicitly, for we
1715 can't infer them and MEM_ATTR caching will share
1716 MEM_REFs with differently-typed op0s. */
1717 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1718 /* Released SSA_NAMES have no TREE_TYPE. */
1719 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1720 /* Same pointer types, but ignoring POINTER_TYPE vs.
1721 REFERENCE_TYPE. */
1722 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1723 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1724 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1725 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1726 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1727 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1728 /* Same value types ignoring qualifiers. */
1729 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1730 == TYPE_MAIN_VARIANT
1731 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1732 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1734 op0 = TREE_OPERAND (op0, 0);
1735 str = "->";
1737 if (op_prio (op0) < op_prio (node))
1738 pp_left_paren (pp);
1739 dump_generic_node (pp, op0, spc, flags, false);
1740 if (op_prio (op0) < op_prio (node))
1741 pp_right_paren (pp);
1742 pp_string (pp, str);
1743 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1744 op0 = component_ref_field_offset (node);
1745 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1747 pp_string (pp, "{off: ");
1748 dump_generic_node (pp, op0, spc, flags, false);
1749 pp_right_brace (pp);
1751 break;
1753 case BIT_FIELD_REF:
1754 pp_string (pp, "BIT_FIELD_REF <");
1755 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1756 pp_string (pp, ", ");
1757 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1758 pp_string (pp, ", ");
1759 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1760 pp_greater (pp);
1761 break;
1763 case ARRAY_REF:
1764 case ARRAY_RANGE_REF:
1765 op0 = TREE_OPERAND (node, 0);
1766 if (op_prio (op0) < op_prio (node))
1767 pp_left_paren (pp);
1768 dump_generic_node (pp, op0, spc, flags, false);
1769 if (op_prio (op0) < op_prio (node))
1770 pp_right_paren (pp);
1771 pp_left_bracket (pp);
1772 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1773 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1774 pp_string (pp, " ...");
1775 pp_right_bracket (pp);
1777 op0 = array_ref_low_bound (node);
1778 op1 = array_ref_element_size (node);
1780 if (!integer_zerop (op0)
1781 || TREE_OPERAND (node, 2)
1782 || TREE_OPERAND (node, 3))
1784 pp_string (pp, "{lb: ");
1785 dump_generic_node (pp, op0, spc, flags, false);
1786 pp_string (pp, " sz: ");
1787 dump_generic_node (pp, op1, spc, flags, false);
1788 pp_right_brace (pp);
1790 break;
1792 case CONSTRUCTOR:
1794 unsigned HOST_WIDE_INT ix;
1795 tree field, val;
1796 bool is_struct_init = false;
1797 bool is_array_init = false;
1798 widest_int curidx;
1799 pp_left_brace (pp);
1800 if (TREE_CLOBBER_P (node))
1801 pp_string (pp, "CLOBBER");
1802 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1803 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1804 is_struct_init = true;
1805 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1806 && TYPE_DOMAIN (TREE_TYPE (node))
1807 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1808 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1809 == INTEGER_CST)
1811 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1812 is_array_init = true;
1813 curidx = wi::to_widest (minv);
1815 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1817 if (field)
1819 if (is_struct_init)
1821 pp_dot (pp);
1822 dump_generic_node (pp, field, spc, flags, false);
1823 pp_equal (pp);
1825 else if (is_array_init
1826 && (TREE_CODE (field) != INTEGER_CST
1827 || curidx != wi::to_widest (field)))
1829 pp_left_bracket (pp);
1830 if (TREE_CODE (field) == RANGE_EXPR)
1832 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1833 flags, false);
1834 pp_string (pp, " ... ");
1835 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1836 flags, false);
1837 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1838 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1840 else
1841 dump_generic_node (pp, field, spc, flags, false);
1842 if (TREE_CODE (field) == INTEGER_CST)
1843 curidx = wi::to_widest (field);
1844 pp_string (pp, "]=");
1847 if (is_array_init)
1848 curidx += 1;
1849 if (val && TREE_CODE (val) == ADDR_EXPR)
1850 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1851 val = TREE_OPERAND (val, 0);
1852 if (val && TREE_CODE (val) == FUNCTION_DECL)
1853 dump_decl_name (pp, val, flags);
1854 else
1855 dump_generic_node (pp, val, spc, flags, false);
1856 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1858 pp_comma (pp);
1859 pp_space (pp);
1862 pp_right_brace (pp);
1864 break;
1866 case COMPOUND_EXPR:
1868 tree *tp;
1869 if (flags & TDF_SLIM)
1871 pp_string (pp, "<COMPOUND_EXPR>");
1872 break;
1875 dump_generic_node (pp, TREE_OPERAND (node, 0),
1876 spc, flags, !(flags & TDF_SLIM));
1877 if (flags & TDF_SLIM)
1878 newline_and_indent (pp, spc);
1879 else
1881 pp_comma (pp);
1882 pp_space (pp);
1885 for (tp = &TREE_OPERAND (node, 1);
1886 TREE_CODE (*tp) == COMPOUND_EXPR;
1887 tp = &TREE_OPERAND (*tp, 1))
1889 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1890 spc, flags, !(flags & TDF_SLIM));
1891 if (flags & TDF_SLIM)
1892 newline_and_indent (pp, spc);
1893 else
1895 pp_comma (pp);
1896 pp_space (pp);
1900 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1902 break;
1904 case STATEMENT_LIST:
1906 tree_stmt_iterator si;
1907 bool first = true;
1909 if (flags & TDF_SLIM)
1911 pp_string (pp, "<STATEMENT_LIST>");
1912 break;
1915 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1917 if (!first)
1918 newline_and_indent (pp, spc);
1919 else
1920 first = false;
1921 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1924 break;
1926 case MODIFY_EXPR:
1927 case INIT_EXPR:
1928 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1929 false);
1930 pp_space (pp);
1931 pp_equal (pp);
1932 pp_space (pp);
1933 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1934 false);
1935 break;
1937 case TARGET_EXPR:
1938 pp_string (pp, "TARGET_EXPR <");
1939 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1940 pp_comma (pp);
1941 pp_space (pp);
1942 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1943 pp_greater (pp);
1944 break;
1946 case DECL_EXPR:
1947 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1948 is_stmt = false;
1949 break;
1951 case COND_EXPR:
1952 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1954 pp_string (pp, "if (");
1955 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1956 pp_right_paren (pp);
1957 /* The lowered cond_exprs should always be printed in full. */
1958 if (COND_EXPR_THEN (node)
1959 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1960 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1961 && COND_EXPR_ELSE (node)
1962 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1963 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1965 pp_space (pp);
1966 dump_generic_node (pp, COND_EXPR_THEN (node),
1967 0, flags, true);
1968 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1970 pp_string (pp, " else ");
1971 dump_generic_node (pp, COND_EXPR_ELSE (node),
1972 0, flags, true);
1975 else if (!(flags & TDF_SLIM))
1977 /* Output COND_EXPR_THEN. */
1978 if (COND_EXPR_THEN (node))
1980 newline_and_indent (pp, spc+2);
1981 pp_left_brace (pp);
1982 newline_and_indent (pp, spc+4);
1983 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
1984 flags, true);
1985 newline_and_indent (pp, spc+2);
1986 pp_right_brace (pp);
1989 /* Output COND_EXPR_ELSE. */
1990 if (COND_EXPR_ELSE (node)
1991 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1993 newline_and_indent (pp, spc);
1994 pp_string (pp, "else");
1995 newline_and_indent (pp, spc+2);
1996 pp_left_brace (pp);
1997 newline_and_indent (pp, spc+4);
1998 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
1999 flags, true);
2000 newline_and_indent (pp, spc+2);
2001 pp_right_brace (pp);
2004 is_expr = false;
2006 else
2008 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2009 pp_space (pp);
2010 pp_question (pp);
2011 pp_space (pp);
2012 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2013 pp_space (pp);
2014 pp_colon (pp);
2015 pp_space (pp);
2016 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2018 break;
2020 case BIND_EXPR:
2021 pp_left_brace (pp);
2022 if (!(flags & TDF_SLIM))
2024 if (BIND_EXPR_VARS (node))
2026 pp_newline (pp);
2028 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2030 print_declaration (pp, op0, spc+2, flags);
2031 pp_newline (pp);
2035 newline_and_indent (pp, spc+2);
2036 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2037 newline_and_indent (pp, spc);
2038 pp_right_brace (pp);
2040 is_expr = false;
2041 break;
2043 case CALL_EXPR:
2044 if (CALL_EXPR_FN (node) != NULL_TREE)
2045 print_call_name (pp, CALL_EXPR_FN (node), flags);
2046 else
2047 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2049 /* Print parameters. */
2050 pp_space (pp);
2051 pp_left_paren (pp);
2053 tree arg;
2054 call_expr_arg_iterator iter;
2055 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2057 dump_generic_node (pp, arg, spc, flags, false);
2058 if (more_call_expr_args_p (&iter))
2060 pp_comma (pp);
2061 pp_space (pp);
2065 if (CALL_EXPR_VA_ARG_PACK (node))
2067 if (call_expr_nargs (node) > 0)
2069 pp_comma (pp);
2070 pp_space (pp);
2072 pp_string (pp, "__builtin_va_arg_pack ()");
2074 pp_right_paren (pp);
2076 op1 = CALL_EXPR_STATIC_CHAIN (node);
2077 if (op1)
2079 pp_string (pp, " [static-chain: ");
2080 dump_generic_node (pp, op1, spc, flags, false);
2081 pp_right_bracket (pp);
2084 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2085 pp_string (pp, " [return slot optimization]");
2086 if (CALL_EXPR_TAILCALL (node))
2087 pp_string (pp, " [tail call]");
2088 break;
2090 case WITH_CLEANUP_EXPR:
2091 NIY;
2092 break;
2094 case CLEANUP_POINT_EXPR:
2095 pp_string (pp, "<<cleanup_point ");
2096 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2097 pp_string (pp, ">>");
2098 break;
2100 case PLACEHOLDER_EXPR:
2101 pp_string (pp, "<PLACEHOLDER_EXPR ");
2102 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2103 pp_greater (pp);
2104 break;
2106 /* Binary arithmetic and logic expressions. */
2107 case WIDEN_SUM_EXPR:
2108 case WIDEN_MULT_EXPR:
2109 case MULT_EXPR:
2110 case MULT_HIGHPART_EXPR:
2111 case PLUS_EXPR:
2112 case POINTER_PLUS_EXPR:
2113 case MINUS_EXPR:
2114 case TRUNC_DIV_EXPR:
2115 case CEIL_DIV_EXPR:
2116 case FLOOR_DIV_EXPR:
2117 case ROUND_DIV_EXPR:
2118 case TRUNC_MOD_EXPR:
2119 case CEIL_MOD_EXPR:
2120 case FLOOR_MOD_EXPR:
2121 case ROUND_MOD_EXPR:
2122 case RDIV_EXPR:
2123 case EXACT_DIV_EXPR:
2124 case LSHIFT_EXPR:
2125 case RSHIFT_EXPR:
2126 case LROTATE_EXPR:
2127 case RROTATE_EXPR:
2128 case WIDEN_LSHIFT_EXPR:
2129 case BIT_IOR_EXPR:
2130 case BIT_XOR_EXPR:
2131 case BIT_AND_EXPR:
2132 case TRUTH_ANDIF_EXPR:
2133 case TRUTH_ORIF_EXPR:
2134 case TRUTH_AND_EXPR:
2135 case TRUTH_OR_EXPR:
2136 case TRUTH_XOR_EXPR:
2137 case LT_EXPR:
2138 case LE_EXPR:
2139 case GT_EXPR:
2140 case GE_EXPR:
2141 case EQ_EXPR:
2142 case NE_EXPR:
2143 case UNLT_EXPR:
2144 case UNLE_EXPR:
2145 case UNGT_EXPR:
2146 case UNGE_EXPR:
2147 case UNEQ_EXPR:
2148 case LTGT_EXPR:
2149 case ORDERED_EXPR:
2150 case UNORDERED_EXPR:
2152 const char *op = op_symbol (node);
2153 op0 = TREE_OPERAND (node, 0);
2154 op1 = TREE_OPERAND (node, 1);
2156 /* When the operands are expressions with less priority,
2157 keep semantics of the tree representation. */
2158 if (op_prio (op0) <= op_prio (node))
2160 pp_left_paren (pp);
2161 dump_generic_node (pp, op0, spc, flags, false);
2162 pp_right_paren (pp);
2164 else
2165 dump_generic_node (pp, op0, spc, flags, false);
2167 pp_space (pp);
2168 pp_string (pp, op);
2169 pp_space (pp);
2171 /* When the operands are expressions with less priority,
2172 keep semantics of the tree representation. */
2173 if (op_prio (op1) <= op_prio (node))
2175 pp_left_paren (pp);
2176 dump_generic_node (pp, op1, spc, flags, false);
2177 pp_right_paren (pp);
2179 else
2180 dump_generic_node (pp, op1, spc, flags, false);
2182 break;
2184 /* Unary arithmetic and logic expressions. */
2185 case NEGATE_EXPR:
2186 case BIT_NOT_EXPR:
2187 case TRUTH_NOT_EXPR:
2188 case ADDR_EXPR:
2189 case PREDECREMENT_EXPR:
2190 case PREINCREMENT_EXPR:
2191 case INDIRECT_REF:
2192 if (TREE_CODE (node) == ADDR_EXPR
2193 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2194 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2195 ; /* Do not output '&' for strings and function pointers. */
2196 else
2197 pp_string (pp, op_symbol (node));
2199 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2201 pp_left_paren (pp);
2202 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2203 pp_right_paren (pp);
2205 else
2206 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2207 break;
2209 case POSTDECREMENT_EXPR:
2210 case POSTINCREMENT_EXPR:
2211 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2213 pp_left_paren (pp);
2214 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2215 pp_right_paren (pp);
2217 else
2218 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2219 pp_string (pp, op_symbol (node));
2220 break;
2222 case MIN_EXPR:
2223 pp_string (pp, "MIN_EXPR <");
2224 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2225 pp_string (pp, ", ");
2226 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2227 pp_greater (pp);
2228 break;
2230 case MAX_EXPR:
2231 pp_string (pp, "MAX_EXPR <");
2232 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2233 pp_string (pp, ", ");
2234 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2235 pp_greater (pp);
2236 break;
2238 case ABS_EXPR:
2239 pp_string (pp, "ABS_EXPR <");
2240 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2241 pp_greater (pp);
2242 break;
2244 case RANGE_EXPR:
2245 NIY;
2246 break;
2248 case ADDR_SPACE_CONVERT_EXPR:
2249 case FIXED_CONVERT_EXPR:
2250 case FIX_TRUNC_EXPR:
2251 case FLOAT_EXPR:
2252 CASE_CONVERT:
2253 type = TREE_TYPE (node);
2254 op0 = TREE_OPERAND (node, 0);
2255 if (type != TREE_TYPE (op0))
2257 pp_left_paren (pp);
2258 dump_generic_node (pp, type, spc, flags, false);
2259 pp_string (pp, ") ");
2261 if (op_prio (op0) < op_prio (node))
2262 pp_left_paren (pp);
2263 dump_generic_node (pp, op0, spc, flags, false);
2264 if (op_prio (op0) < op_prio (node))
2265 pp_right_paren (pp);
2266 break;
2268 case VIEW_CONVERT_EXPR:
2269 pp_string (pp, "VIEW_CONVERT_EXPR<");
2270 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2271 pp_string (pp, ">(");
2272 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2273 pp_right_paren (pp);
2274 break;
2276 case PAREN_EXPR:
2277 pp_string (pp, "((");
2278 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2279 pp_string (pp, "))");
2280 break;
2282 case NON_LVALUE_EXPR:
2283 pp_string (pp, "NON_LVALUE_EXPR <");
2284 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2285 pp_greater (pp);
2286 break;
2288 case SAVE_EXPR:
2289 pp_string (pp, "SAVE_EXPR <");
2290 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2291 pp_greater (pp);
2292 break;
2294 case COMPLEX_EXPR:
2295 pp_string (pp, "COMPLEX_EXPR <");
2296 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2297 pp_string (pp, ", ");
2298 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2299 pp_greater (pp);
2300 break;
2302 case CONJ_EXPR:
2303 pp_string (pp, "CONJ_EXPR <");
2304 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2305 pp_greater (pp);
2306 break;
2308 case REALPART_EXPR:
2309 pp_string (pp, "REALPART_EXPR <");
2310 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2311 pp_greater (pp);
2312 break;
2314 case IMAGPART_EXPR:
2315 pp_string (pp, "IMAGPART_EXPR <");
2316 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2317 pp_greater (pp);
2318 break;
2320 case VA_ARG_EXPR:
2321 pp_string (pp, "VA_ARG_EXPR <");
2322 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2323 pp_greater (pp);
2324 break;
2326 case TRY_FINALLY_EXPR:
2327 case TRY_CATCH_EXPR:
2328 pp_string (pp, "try");
2329 newline_and_indent (pp, spc+2);
2330 pp_left_brace (pp);
2331 newline_and_indent (pp, spc+4);
2332 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2333 newline_and_indent (pp, spc+2);
2334 pp_right_brace (pp);
2335 newline_and_indent (pp, spc);
2336 pp_string (pp,
2337 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2338 newline_and_indent (pp, spc+2);
2339 pp_left_brace (pp);
2340 newline_and_indent (pp, spc+4);
2341 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2342 newline_and_indent (pp, spc+2);
2343 pp_right_brace (pp);
2344 is_expr = false;
2345 break;
2347 case CATCH_EXPR:
2348 pp_string (pp, "catch (");
2349 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2350 pp_right_paren (pp);
2351 newline_and_indent (pp, spc+2);
2352 pp_left_brace (pp);
2353 newline_and_indent (pp, spc+4);
2354 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2355 newline_and_indent (pp, spc+2);
2356 pp_right_brace (pp);
2357 is_expr = false;
2358 break;
2360 case EH_FILTER_EXPR:
2361 pp_string (pp, "<<<eh_filter (");
2362 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2363 pp_string (pp, ")>>>");
2364 newline_and_indent (pp, spc+2);
2365 pp_left_brace (pp);
2366 newline_and_indent (pp, spc+4);
2367 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2368 newline_and_indent (pp, spc+2);
2369 pp_right_brace (pp);
2370 is_expr = false;
2371 break;
2373 case LABEL_EXPR:
2374 op0 = TREE_OPERAND (node, 0);
2375 /* If this is for break or continue, don't bother printing it. */
2376 if (DECL_NAME (op0))
2378 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2379 if (strcmp (name, "break") == 0
2380 || strcmp (name, "continue") == 0)
2381 break;
2383 dump_generic_node (pp, op0, spc, flags, false);
2384 pp_colon (pp);
2385 if (DECL_NONLOCAL (op0))
2386 pp_string (pp, " [non-local]");
2387 break;
2389 case LOOP_EXPR:
2390 pp_string (pp, "while (1)");
2391 if (!(flags & TDF_SLIM))
2393 newline_and_indent (pp, spc+2);
2394 pp_left_brace (pp);
2395 newline_and_indent (pp, spc+4);
2396 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2397 newline_and_indent (pp, spc+2);
2398 pp_right_brace (pp);
2400 is_expr = false;
2401 break;
2403 case PREDICT_EXPR:
2404 pp_string (pp, "// predicted ");
2405 if (PREDICT_EXPR_OUTCOME (node))
2406 pp_string (pp, "likely by ");
2407 else
2408 pp_string (pp, "unlikely by ");
2409 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2410 pp_string (pp, " predictor.");
2411 break;
2413 case ANNOTATE_EXPR:
2414 pp_string (pp, "ANNOTATE_EXPR <");
2415 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2416 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2418 case annot_expr_ivdep_kind:
2419 pp_string (pp, ", ivdep");
2420 break;
2421 case annot_expr_no_vector_kind:
2422 pp_string (pp, ", no-vector");
2423 break;
2424 case annot_expr_vector_kind:
2425 pp_string (pp, ", vector");
2426 break;
2427 default:
2428 gcc_unreachable ();
2430 pp_greater (pp);
2431 break;
2433 case RETURN_EXPR:
2434 pp_string (pp, "return");
2435 op0 = TREE_OPERAND (node, 0);
2436 if (op0)
2438 pp_space (pp);
2439 if (TREE_CODE (op0) == MODIFY_EXPR)
2440 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2441 spc, flags, false);
2442 else
2443 dump_generic_node (pp, op0, spc, flags, false);
2445 break;
2447 case EXIT_EXPR:
2448 pp_string (pp, "if (");
2449 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2450 pp_string (pp, ") break");
2451 break;
2453 case SWITCH_EXPR:
2454 pp_string (pp, "switch (");
2455 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2456 pp_right_paren (pp);
2457 if (!(flags & TDF_SLIM))
2459 newline_and_indent (pp, spc+2);
2460 pp_left_brace (pp);
2461 if (SWITCH_BODY (node))
2463 newline_and_indent (pp, spc+4);
2464 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2465 true);
2467 else
2469 tree vec = SWITCH_LABELS (node);
2470 size_t i, n = TREE_VEC_LENGTH (vec);
2471 for (i = 0; i < n; ++i)
2473 tree elt = TREE_VEC_ELT (vec, i);
2474 newline_and_indent (pp, spc+4);
2475 if (elt)
2477 dump_generic_node (pp, elt, spc+4, flags, false);
2478 pp_string (pp, " goto ");
2479 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2480 flags, true);
2481 pp_semicolon (pp);
2483 else
2484 pp_string (pp, "case ???: goto ???;");
2487 newline_and_indent (pp, spc+2);
2488 pp_right_brace (pp);
2490 is_expr = false;
2491 break;
2493 case GOTO_EXPR:
2494 op0 = GOTO_DESTINATION (node);
2495 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2497 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2498 if (strcmp (name, "break") == 0
2499 || strcmp (name, "continue") == 0)
2501 pp_string (pp, name);
2502 break;
2505 pp_string (pp, "goto ");
2506 dump_generic_node (pp, op0, spc, flags, false);
2507 break;
2509 case ASM_EXPR:
2510 pp_string (pp, "__asm__");
2511 if (ASM_VOLATILE_P (node))
2512 pp_string (pp, " __volatile__");
2513 pp_left_paren (pp);
2514 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2515 pp_colon (pp);
2516 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2517 pp_colon (pp);
2518 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2519 if (ASM_CLOBBERS (node))
2521 pp_colon (pp);
2522 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2524 pp_right_paren (pp);
2525 break;
2527 case CASE_LABEL_EXPR:
2528 if (CASE_LOW (node) && CASE_HIGH (node))
2530 pp_string (pp, "case ");
2531 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2532 pp_string (pp, " ... ");
2533 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2535 else if (CASE_LOW (node))
2537 pp_string (pp, "case ");
2538 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2540 else
2541 pp_string (pp, "default");
2542 pp_colon (pp);
2543 break;
2545 case OBJ_TYPE_REF:
2546 pp_string (pp, "OBJ_TYPE_REF(");
2547 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2548 pp_semicolon (pp);
2549 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2551 pp_string (pp, "(");
2552 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2553 pp_string (pp, ")");
2555 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2556 pp_arrow (pp);
2557 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2558 pp_right_paren (pp);
2559 break;
2561 case SSA_NAME:
2562 if (SSA_NAME_IDENTIFIER (node))
2563 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2564 spc, flags, false);
2565 pp_underscore (pp);
2566 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2567 if (SSA_NAME_IS_DEFAULT_DEF (node))
2568 pp_string (pp, "(D)");
2569 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2570 pp_string (pp, "(ab)");
2571 break;
2573 case WITH_SIZE_EXPR:
2574 pp_string (pp, "WITH_SIZE_EXPR <");
2575 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2576 pp_string (pp, ", ");
2577 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2578 pp_greater (pp);
2579 break;
2581 case ASSERT_EXPR:
2582 pp_string (pp, "ASSERT_EXPR <");
2583 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2584 pp_string (pp, ", ");
2585 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2586 pp_greater (pp);
2587 break;
2589 case SCEV_KNOWN:
2590 pp_string (pp, "scev_known");
2591 break;
2593 case SCEV_NOT_KNOWN:
2594 pp_string (pp, "scev_not_known");
2595 break;
2597 case POLYNOMIAL_CHREC:
2598 pp_left_brace (pp);
2599 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2600 pp_string (pp, ", +, ");
2601 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2602 pp_string (pp, "}_");
2603 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2604 is_stmt = false;
2605 break;
2607 case REALIGN_LOAD_EXPR:
2608 pp_string (pp, "REALIGN_LOAD <");
2609 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2610 pp_string (pp, ", ");
2611 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2612 pp_string (pp, ", ");
2613 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2614 pp_greater (pp);
2615 break;
2617 case VEC_COND_EXPR:
2618 pp_string (pp, " VEC_COND_EXPR < ");
2619 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2620 pp_string (pp, " , ");
2621 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2622 pp_string (pp, " , ");
2623 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2624 pp_string (pp, " > ");
2625 break;
2627 case VEC_PERM_EXPR:
2628 pp_string (pp, " VEC_PERM_EXPR < ");
2629 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2630 pp_string (pp, " , ");
2631 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2632 pp_string (pp, " , ");
2633 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2634 pp_string (pp, " > ");
2635 break;
2637 case DOT_PROD_EXPR:
2638 pp_string (pp, " DOT_PROD_EXPR < ");
2639 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2640 pp_string (pp, ", ");
2641 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2642 pp_string (pp, ", ");
2643 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2644 pp_string (pp, " > ");
2645 break;
2647 case WIDEN_MULT_PLUS_EXPR:
2648 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2649 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2650 pp_string (pp, ", ");
2651 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2652 pp_string (pp, ", ");
2653 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2654 pp_string (pp, " > ");
2655 break;
2657 case WIDEN_MULT_MINUS_EXPR:
2658 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2659 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2660 pp_string (pp, ", ");
2661 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2662 pp_string (pp, ", ");
2663 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2664 pp_string (pp, " > ");
2665 break;
2667 case FMA_EXPR:
2668 pp_string (pp, " FMA_EXPR < ");
2669 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2670 pp_string (pp, ", ");
2671 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2672 pp_string (pp, ", ");
2673 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2674 pp_string (pp, " > ");
2675 break;
2677 case OACC_PARALLEL:
2678 pp_string (pp, "#pragma acc parallel");
2679 dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags);
2680 goto dump_omp_body;
2682 case OACC_KERNELS:
2683 pp_string (pp, "#pragma acc kernels");
2684 dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags);
2685 goto dump_omp_body;
2687 case OACC_DATA:
2688 pp_string (pp, "#pragma acc data");
2689 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2690 goto dump_omp_body;
2692 case OACC_HOST_DATA:
2693 pp_string (pp, "#pragma acc host_data");
2694 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2695 goto dump_omp_body;
2697 case OACC_DECLARE:
2698 pp_string (pp, "#pragma acc declare");
2699 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2700 break;
2702 case OACC_UPDATE:
2703 pp_string (pp, "#pragma acc update");
2704 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2705 break;
2707 case OACC_ENTER_DATA:
2708 pp_string (pp, "#pragma acc enter data");
2709 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2710 break;
2712 case OACC_EXIT_DATA:
2713 pp_string (pp, "#pragma acc exit data");
2714 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2715 break;
2717 case OACC_CACHE:
2718 pp_string (pp, "#pragma acc cache");
2719 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2720 break;
2722 case OMP_PARALLEL:
2723 pp_string (pp, "#pragma omp parallel");
2724 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2726 dump_omp_body:
2727 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2729 newline_and_indent (pp, spc + 2);
2730 pp_left_brace (pp);
2731 newline_and_indent (pp, spc + 4);
2732 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2733 newline_and_indent (pp, spc + 2);
2734 pp_right_brace (pp);
2736 is_expr = false;
2737 break;
2739 case OMP_TASK:
2740 pp_string (pp, "#pragma omp task");
2741 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2742 goto dump_omp_body;
2744 case OMP_FOR:
2745 pp_string (pp, "#pragma omp for");
2746 goto dump_omp_loop;
2748 case OMP_SIMD:
2749 pp_string (pp, "#pragma omp simd");
2750 goto dump_omp_loop;
2752 case CILK_SIMD:
2753 pp_string (pp, "#pragma simd");
2754 goto dump_omp_loop;
2756 case CILK_FOR:
2757 /* This label points one line after dumping the clauses.
2758 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2759 parameters are printed out. */
2760 goto dump_omp_loop_cilk_for;
2762 case OMP_DISTRIBUTE:
2763 pp_string (pp, "#pragma omp distribute");
2764 goto dump_omp_loop;
2766 case OMP_TASKLOOP:
2767 pp_string (pp, "#pragma omp taskloop");
2768 goto dump_omp_loop;
2770 case OACC_LOOP:
2771 pp_string (pp, "#pragma acc loop");
2772 goto dump_omp_loop;
2774 case OMP_TEAMS:
2775 pp_string (pp, "#pragma omp teams");
2776 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2777 goto dump_omp_body;
2779 case OMP_TARGET_DATA:
2780 pp_string (pp, "#pragma omp target data");
2781 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2782 goto dump_omp_body;
2784 case OMP_TARGET_ENTER_DATA:
2785 pp_string (pp, "#pragma omp target enter data");
2786 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2787 is_expr = false;
2788 break;
2790 case OMP_TARGET_EXIT_DATA:
2791 pp_string (pp, "#pragma omp target exit data");
2792 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2793 is_expr = false;
2794 break;
2796 case OMP_TARGET:
2797 pp_string (pp, "#pragma omp target");
2798 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2799 goto dump_omp_body;
2801 case OMP_TARGET_UPDATE:
2802 pp_string (pp, "#pragma omp target update");
2803 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2804 is_expr = false;
2805 break;
2807 dump_omp_loop:
2808 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2810 dump_omp_loop_cilk_for:
2811 if (!(flags & TDF_SLIM))
2813 int i;
2815 if (OMP_FOR_PRE_BODY (node))
2817 if (TREE_CODE (node) == CILK_FOR)
2818 pp_string (pp, " ");
2819 else
2820 newline_and_indent (pp, spc + 2);
2821 pp_left_brace (pp);
2822 spc += 4;
2823 newline_and_indent (pp, spc);
2824 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2825 spc, flags, false);
2827 if (OMP_FOR_INIT (node))
2829 spc -= 2;
2830 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2832 spc += 2;
2833 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2834 newline_and_indent (pp, spc);
2835 if (TREE_CODE (node) == CILK_FOR)
2836 pp_string (pp, "_Cilk_for (");
2837 else
2838 pp_string (pp, "for (");
2839 dump_generic_node (pp,
2840 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2841 spc, flags, false);
2842 pp_string (pp, "; ");
2843 dump_generic_node (pp,
2844 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2845 spc, flags, false);
2846 pp_string (pp, "; ");
2847 dump_generic_node (pp,
2848 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2849 spc, flags, false);
2850 pp_right_paren (pp);
2852 if (TREE_CODE (node) == CILK_FOR)
2853 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2855 if (OMP_FOR_BODY (node))
2857 newline_and_indent (pp, spc + 2);
2858 pp_left_brace (pp);
2859 newline_and_indent (pp, spc + 4);
2860 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2861 false);
2862 newline_and_indent (pp, spc + 2);
2863 pp_right_brace (pp);
2865 if (OMP_FOR_INIT (node))
2866 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2867 if (OMP_FOR_PRE_BODY (node))
2869 spc -= 4;
2870 newline_and_indent (pp, spc + 2);
2871 pp_right_brace (pp);
2874 is_expr = false;
2875 break;
2877 case OMP_SECTIONS:
2878 pp_string (pp, "#pragma omp sections");
2879 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2880 goto dump_omp_body;
2882 case OMP_SECTION:
2883 pp_string (pp, "#pragma omp section");
2884 goto dump_omp_body;
2886 case OMP_MASTER:
2887 pp_string (pp, "#pragma omp master");
2888 goto dump_omp_body;
2890 case OMP_TASKGROUP:
2891 pp_string (pp, "#pragma omp taskgroup");
2892 goto dump_omp_body;
2894 case OMP_ORDERED:
2895 pp_string (pp, "#pragma omp ordered");
2896 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
2897 goto dump_omp_body;
2899 case OMP_CRITICAL:
2900 pp_string (pp, "#pragma omp critical");
2901 if (OMP_CRITICAL_NAME (node))
2903 pp_space (pp);
2904 pp_left_paren (pp);
2905 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2906 flags, false);
2907 pp_right_paren (pp);
2909 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
2910 goto dump_omp_body;
2912 case OMP_ATOMIC:
2913 pp_string (pp, "#pragma omp atomic");
2914 if (OMP_ATOMIC_SEQ_CST (node))
2915 pp_string (pp, " seq_cst");
2916 newline_and_indent (pp, spc + 2);
2917 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2918 pp_space (pp);
2919 pp_equal (pp);
2920 pp_space (pp);
2921 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2922 break;
2924 case OMP_ATOMIC_READ:
2925 pp_string (pp, "#pragma omp atomic read");
2926 if (OMP_ATOMIC_SEQ_CST (node))
2927 pp_string (pp, " seq_cst");
2928 newline_and_indent (pp, spc + 2);
2929 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2930 pp_space (pp);
2931 break;
2933 case OMP_ATOMIC_CAPTURE_OLD:
2934 case OMP_ATOMIC_CAPTURE_NEW:
2935 pp_string (pp, "#pragma omp atomic capture");
2936 if (OMP_ATOMIC_SEQ_CST (node))
2937 pp_string (pp, " seq_cst");
2938 newline_and_indent (pp, spc + 2);
2939 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2940 pp_space (pp);
2941 pp_equal (pp);
2942 pp_space (pp);
2943 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2944 break;
2946 case OMP_SINGLE:
2947 pp_string (pp, "#pragma omp single");
2948 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2949 goto dump_omp_body;
2951 case OMP_CLAUSE:
2952 dump_omp_clause (pp, node, spc, flags);
2953 is_expr = false;
2954 break;
2956 case TRANSACTION_EXPR:
2957 if (TRANSACTION_EXPR_OUTER (node))
2958 pp_string (pp, "__transaction_atomic [[outer]]");
2959 else if (TRANSACTION_EXPR_RELAXED (node))
2960 pp_string (pp, "__transaction_relaxed");
2961 else
2962 pp_string (pp, "__transaction_atomic");
2963 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2965 newline_and_indent (pp, spc);
2966 pp_left_brace (pp);
2967 newline_and_indent (pp, spc + 2);
2968 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
2969 spc + 2, flags, false);
2970 newline_and_indent (pp, spc);
2971 pp_right_brace (pp);
2973 is_expr = false;
2974 break;
2976 case REDUC_MAX_EXPR:
2977 pp_string (pp, " REDUC_MAX_EXPR < ");
2978 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2979 pp_string (pp, " > ");
2980 break;
2982 case REDUC_MIN_EXPR:
2983 pp_string (pp, " REDUC_MIN_EXPR < ");
2984 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2985 pp_string (pp, " > ");
2986 break;
2988 case REDUC_PLUS_EXPR:
2989 pp_string (pp, " REDUC_PLUS_EXPR < ");
2990 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2991 pp_string (pp, " > ");
2992 break;
2994 case VEC_WIDEN_MULT_HI_EXPR:
2995 case VEC_WIDEN_MULT_LO_EXPR:
2996 case VEC_WIDEN_MULT_EVEN_EXPR:
2997 case VEC_WIDEN_MULT_ODD_EXPR:
2998 case VEC_WIDEN_LSHIFT_HI_EXPR:
2999 case VEC_WIDEN_LSHIFT_LO_EXPR:
3000 pp_space (pp);
3001 for (str = get_tree_code_name (code); *str; str++)
3002 pp_character (pp, TOUPPER (*str));
3003 pp_string (pp, " < ");
3004 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3005 pp_string (pp, ", ");
3006 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3007 pp_string (pp, " > ");
3008 break;
3010 case VEC_UNPACK_HI_EXPR:
3011 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3012 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3013 pp_string (pp, " > ");
3014 break;
3016 case VEC_UNPACK_LO_EXPR:
3017 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3018 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3019 pp_string (pp, " > ");
3020 break;
3022 case VEC_UNPACK_FLOAT_HI_EXPR:
3023 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3024 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3025 pp_string (pp, " > ");
3026 break;
3028 case VEC_UNPACK_FLOAT_LO_EXPR:
3029 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3030 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3031 pp_string (pp, " > ");
3032 break;
3034 case VEC_PACK_TRUNC_EXPR:
3035 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3036 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3037 pp_string (pp, ", ");
3038 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3039 pp_string (pp, " > ");
3040 break;
3042 case VEC_PACK_SAT_EXPR:
3043 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3044 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3045 pp_string (pp, ", ");
3046 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3047 pp_string (pp, " > ");
3048 break;
3050 case VEC_PACK_FIX_TRUNC_EXPR:
3051 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3052 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3053 pp_string (pp, ", ");
3054 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3055 pp_string (pp, " > ");
3056 break;
3058 case BLOCK:
3059 dump_block_node (pp, node, spc, flags);
3060 break;
3062 case CILK_SPAWN_STMT:
3063 pp_string (pp, "_Cilk_spawn ");
3064 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3065 break;
3067 case CILK_SYNC_STMT:
3068 pp_string (pp, "_Cilk_sync");
3069 break;
3071 default:
3072 NIY;
3075 if (is_stmt && is_expr)
3076 pp_semicolon (pp);
3078 return spc;
3081 /* Print the declaration of a variable. */
3083 void
3084 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
3086 INDENT (spc);
3088 if (TREE_CODE(t) == NAMELIST_DECL)
3090 pp_string(pp, "namelist ");
3091 dump_decl_name (pp, t, flags);
3092 pp_semicolon (pp);
3093 return;
3096 if (TREE_CODE (t) == TYPE_DECL)
3097 pp_string (pp, "typedef ");
3099 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3100 pp_string (pp, "register ");
3102 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3103 pp_string (pp, "extern ");
3104 else if (TREE_STATIC (t))
3105 pp_string (pp, "static ");
3107 /* Print the type and name. */
3108 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3110 tree tmp;
3112 /* Print array's type. */
3113 tmp = TREE_TYPE (t);
3114 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3115 tmp = TREE_TYPE (tmp);
3116 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3118 /* Print variable's name. */
3119 pp_space (pp);
3120 dump_generic_node (pp, t, spc, flags, false);
3122 /* Print the dimensions. */
3123 tmp = TREE_TYPE (t);
3124 while (TREE_CODE (tmp) == ARRAY_TYPE)
3126 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3127 tmp = TREE_TYPE (tmp);
3130 else if (TREE_CODE (t) == FUNCTION_DECL)
3132 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3133 pp_space (pp);
3134 dump_decl_name (pp, t, flags);
3135 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3137 else
3139 /* Print type declaration. */
3140 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3142 /* Print variable's name. */
3143 pp_space (pp);
3144 dump_generic_node (pp, t, spc, flags, false);
3147 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3149 pp_string (pp, " __asm__ ");
3150 pp_left_paren (pp);
3151 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3152 pp_right_paren (pp);
3155 /* The initial value of a function serves to determine whether the function
3156 is declared or defined. So the following does not apply to function
3157 nodes. */
3158 if (TREE_CODE (t) != FUNCTION_DECL)
3160 /* Print the initial value. */
3161 if (DECL_INITIAL (t))
3163 pp_space (pp);
3164 pp_equal (pp);
3165 pp_space (pp);
3166 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3170 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3172 pp_string (pp, " [value-expr: ");
3173 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3174 pp_right_bracket (pp);
3177 pp_semicolon (pp);
3181 /* Prints a structure: name, fields, and methods.
3182 FIXME: Still incomplete. */
3184 static void
3185 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3187 /* Print the name of the structure. */
3188 if (TYPE_NAME (node))
3190 INDENT (spc);
3191 if (TREE_CODE (node) == RECORD_TYPE)
3192 pp_string (pp, "struct ");
3193 else if ((TREE_CODE (node) == UNION_TYPE
3194 || TREE_CODE (node) == QUAL_UNION_TYPE))
3195 pp_string (pp, "union ");
3197 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3200 /* Print the contents of the structure. */
3201 pp_newline (pp);
3202 INDENT (spc);
3203 pp_left_brace (pp);
3204 pp_newline (pp);
3206 /* Print the fields of the structure. */
3208 tree tmp;
3209 tmp = TYPE_FIELDS (node);
3210 while (tmp)
3212 /* Avoid to print recursively the structure. */
3213 /* FIXME : Not implemented correctly...,
3214 what about the case when we have a cycle in the contain graph? ...
3215 Maybe this could be solved by looking at the scope in which the
3216 structure was declared. */
3217 if (TREE_TYPE (tmp) != node
3218 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3219 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3221 print_declaration (pp, tmp, spc+2, flags);
3222 pp_newline (pp);
3224 tmp = DECL_CHAIN (tmp);
3227 INDENT (spc);
3228 pp_right_brace (pp);
3231 /* Return the priority of the operator CODE.
3233 From lowest to highest precedence with either left-to-right (L-R)
3234 or right-to-left (R-L) associativity]:
3236 1 [L-R] ,
3237 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3238 3 [R-L] ?:
3239 4 [L-R] ||
3240 5 [L-R] &&
3241 6 [L-R] |
3242 7 [L-R] ^
3243 8 [L-R] &
3244 9 [L-R] == !=
3245 10 [L-R] < <= > >=
3246 11 [L-R] << >>
3247 12 [L-R] + -
3248 13 [L-R] * / %
3249 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3250 15 [L-R] fn() [] -> .
3252 unary +, - and * have higher precedence than the corresponding binary
3253 operators. */
3256 op_code_prio (enum tree_code code)
3258 switch (code)
3260 case TREE_LIST:
3261 case COMPOUND_EXPR:
3262 case BIND_EXPR:
3263 return 1;
3265 case MODIFY_EXPR:
3266 case INIT_EXPR:
3267 return 2;
3269 case COND_EXPR:
3270 return 3;
3272 case TRUTH_OR_EXPR:
3273 case TRUTH_ORIF_EXPR:
3274 return 4;
3276 case TRUTH_AND_EXPR:
3277 case TRUTH_ANDIF_EXPR:
3278 return 5;
3280 case BIT_IOR_EXPR:
3281 return 6;
3283 case BIT_XOR_EXPR:
3284 case TRUTH_XOR_EXPR:
3285 return 7;
3287 case BIT_AND_EXPR:
3288 return 8;
3290 case EQ_EXPR:
3291 case NE_EXPR:
3292 return 9;
3294 case UNLT_EXPR:
3295 case UNLE_EXPR:
3296 case UNGT_EXPR:
3297 case UNGE_EXPR:
3298 case UNEQ_EXPR:
3299 case LTGT_EXPR:
3300 case ORDERED_EXPR:
3301 case UNORDERED_EXPR:
3302 case LT_EXPR:
3303 case LE_EXPR:
3304 case GT_EXPR:
3305 case GE_EXPR:
3306 return 10;
3308 case LSHIFT_EXPR:
3309 case RSHIFT_EXPR:
3310 case LROTATE_EXPR:
3311 case RROTATE_EXPR:
3312 case VEC_WIDEN_LSHIFT_HI_EXPR:
3313 case VEC_WIDEN_LSHIFT_LO_EXPR:
3314 case WIDEN_LSHIFT_EXPR:
3315 return 11;
3317 case WIDEN_SUM_EXPR:
3318 case PLUS_EXPR:
3319 case POINTER_PLUS_EXPR:
3320 case MINUS_EXPR:
3321 return 12;
3323 case VEC_WIDEN_MULT_HI_EXPR:
3324 case VEC_WIDEN_MULT_LO_EXPR:
3325 case WIDEN_MULT_EXPR:
3326 case DOT_PROD_EXPR:
3327 case WIDEN_MULT_PLUS_EXPR:
3328 case WIDEN_MULT_MINUS_EXPR:
3329 case MULT_EXPR:
3330 case MULT_HIGHPART_EXPR:
3331 case TRUNC_DIV_EXPR:
3332 case CEIL_DIV_EXPR:
3333 case FLOOR_DIV_EXPR:
3334 case ROUND_DIV_EXPR:
3335 case RDIV_EXPR:
3336 case EXACT_DIV_EXPR:
3337 case TRUNC_MOD_EXPR:
3338 case CEIL_MOD_EXPR:
3339 case FLOOR_MOD_EXPR:
3340 case ROUND_MOD_EXPR:
3341 case FMA_EXPR:
3342 return 13;
3344 case TRUTH_NOT_EXPR:
3345 case BIT_NOT_EXPR:
3346 case POSTINCREMENT_EXPR:
3347 case POSTDECREMENT_EXPR:
3348 case PREINCREMENT_EXPR:
3349 case PREDECREMENT_EXPR:
3350 case NEGATE_EXPR:
3351 case INDIRECT_REF:
3352 case ADDR_EXPR:
3353 case FLOAT_EXPR:
3354 CASE_CONVERT:
3355 case FIX_TRUNC_EXPR:
3356 case TARGET_EXPR:
3357 return 14;
3359 case CALL_EXPR:
3360 case ARRAY_REF:
3361 case ARRAY_RANGE_REF:
3362 case COMPONENT_REF:
3363 return 15;
3365 /* Special expressions. */
3366 case MIN_EXPR:
3367 case MAX_EXPR:
3368 case ABS_EXPR:
3369 case REALPART_EXPR:
3370 case IMAGPART_EXPR:
3371 case REDUC_MAX_EXPR:
3372 case REDUC_MIN_EXPR:
3373 case REDUC_PLUS_EXPR:
3374 case VEC_UNPACK_HI_EXPR:
3375 case VEC_UNPACK_LO_EXPR:
3376 case VEC_UNPACK_FLOAT_HI_EXPR:
3377 case VEC_UNPACK_FLOAT_LO_EXPR:
3378 case VEC_PACK_TRUNC_EXPR:
3379 case VEC_PACK_SAT_EXPR:
3380 return 16;
3382 default:
3383 /* Return an arbitrarily high precedence to avoid surrounding single
3384 VAR_DECLs in ()s. */
3385 return 9999;
3389 /* Return the priority of the operator OP. */
3392 op_prio (const_tree op)
3394 enum tree_code code;
3396 if (op == NULL)
3397 return 9999;
3399 code = TREE_CODE (op);
3400 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3401 return op_prio (TREE_OPERAND (op, 0));
3403 return op_code_prio (code);
3406 /* Return the symbol associated with operator CODE. */
3408 const char *
3409 op_symbol_code (enum tree_code code)
3411 switch (code)
3413 case MODIFY_EXPR:
3414 return "=";
3416 case TRUTH_OR_EXPR:
3417 case TRUTH_ORIF_EXPR:
3418 return "||";
3420 case TRUTH_AND_EXPR:
3421 case TRUTH_ANDIF_EXPR:
3422 return "&&";
3424 case BIT_IOR_EXPR:
3425 return "|";
3427 case TRUTH_XOR_EXPR:
3428 case BIT_XOR_EXPR:
3429 return "^";
3431 case ADDR_EXPR:
3432 case BIT_AND_EXPR:
3433 return "&";
3435 case ORDERED_EXPR:
3436 return "ord";
3437 case UNORDERED_EXPR:
3438 return "unord";
3440 case EQ_EXPR:
3441 return "==";
3442 case UNEQ_EXPR:
3443 return "u==";
3445 case NE_EXPR:
3446 return "!=";
3448 case LT_EXPR:
3449 return "<";
3450 case UNLT_EXPR:
3451 return "u<";
3453 case LE_EXPR:
3454 return "<=";
3455 case UNLE_EXPR:
3456 return "u<=";
3458 case GT_EXPR:
3459 return ">";
3460 case UNGT_EXPR:
3461 return "u>";
3463 case GE_EXPR:
3464 return ">=";
3465 case UNGE_EXPR:
3466 return "u>=";
3468 case LTGT_EXPR:
3469 return "<>";
3471 case LSHIFT_EXPR:
3472 return "<<";
3474 case RSHIFT_EXPR:
3475 return ">>";
3477 case LROTATE_EXPR:
3478 return "r<<";
3480 case RROTATE_EXPR:
3481 return "r>>";
3483 case WIDEN_LSHIFT_EXPR:
3484 return "w<<";
3486 case POINTER_PLUS_EXPR:
3487 return "+";
3489 case PLUS_EXPR:
3490 return "+";
3492 case REDUC_PLUS_EXPR:
3493 return "r+";
3495 case WIDEN_SUM_EXPR:
3496 return "w+";
3498 case WIDEN_MULT_EXPR:
3499 return "w*";
3501 case MULT_HIGHPART_EXPR:
3502 return "h*";
3504 case NEGATE_EXPR:
3505 case MINUS_EXPR:
3506 return "-";
3508 case BIT_NOT_EXPR:
3509 return "~";
3511 case TRUTH_NOT_EXPR:
3512 return "!";
3514 case MULT_EXPR:
3515 case INDIRECT_REF:
3516 return "*";
3518 case TRUNC_DIV_EXPR:
3519 case RDIV_EXPR:
3520 return "/";
3522 case CEIL_DIV_EXPR:
3523 return "/[cl]";
3525 case FLOOR_DIV_EXPR:
3526 return "/[fl]";
3528 case ROUND_DIV_EXPR:
3529 return "/[rd]";
3531 case EXACT_DIV_EXPR:
3532 return "/[ex]";
3534 case TRUNC_MOD_EXPR:
3535 return "%";
3537 case CEIL_MOD_EXPR:
3538 return "%[cl]";
3540 case FLOOR_MOD_EXPR:
3541 return "%[fl]";
3543 case ROUND_MOD_EXPR:
3544 return "%[rd]";
3546 case PREDECREMENT_EXPR:
3547 return " --";
3549 case PREINCREMENT_EXPR:
3550 return " ++";
3552 case POSTDECREMENT_EXPR:
3553 return "-- ";
3555 case POSTINCREMENT_EXPR:
3556 return "++ ";
3558 case MAX_EXPR:
3559 return "max";
3561 case MIN_EXPR:
3562 return "min";
3564 default:
3565 return "<<< ??? >>>";
3569 /* Return the symbol associated with operator OP. */
3571 static const char *
3572 op_symbol (const_tree op)
3574 return op_symbol_code (TREE_CODE (op));
3577 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3578 the gimple_call_fn of a GIMPLE_CALL. */
3580 void
3581 print_call_name (pretty_printer *pp, tree node, int flags)
3583 tree op0 = node;
3585 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3586 op0 = TREE_OPERAND (op0, 0);
3588 again:
3589 switch (TREE_CODE (op0))
3591 case VAR_DECL:
3592 case PARM_DECL:
3593 case FUNCTION_DECL:
3594 dump_function_name (pp, op0, flags);
3595 break;
3597 case ADDR_EXPR:
3598 case INDIRECT_REF:
3599 CASE_CONVERT:
3600 op0 = TREE_OPERAND (op0, 0);
3601 goto again;
3603 case COND_EXPR:
3604 pp_left_paren (pp);
3605 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3606 pp_string (pp, ") ? ");
3607 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3608 pp_string (pp, " : ");
3609 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3610 break;
3612 case ARRAY_REF:
3613 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3614 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3615 else
3616 dump_generic_node (pp, op0, 0, flags, false);
3617 break;
3619 case MEM_REF:
3620 if (integer_zerop (TREE_OPERAND (op0, 1)))
3622 op0 = TREE_OPERAND (op0, 0);
3623 goto again;
3625 /* Fallthru. */
3626 case COMPONENT_REF:
3627 case SSA_NAME:
3628 case OBJ_TYPE_REF:
3629 dump_generic_node (pp, op0, 0, flags, false);
3630 break;
3632 default:
3633 NIY;
3637 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3639 static void
3640 pretty_print_string (pretty_printer *pp, const char *str)
3642 if (str == NULL)
3643 return;
3645 while (*str)
3647 switch (str[0])
3649 case '\b':
3650 pp_string (pp, "\\b");
3651 break;
3653 case '\f':
3654 pp_string (pp, "\\f");
3655 break;
3657 case '\n':
3658 pp_string (pp, "\\n");
3659 break;
3661 case '\r':
3662 pp_string (pp, "\\r");
3663 break;
3665 case '\t':
3666 pp_string (pp, "\\t");
3667 break;
3669 case '\v':
3670 pp_string (pp, "\\v");
3671 break;
3673 case '\\':
3674 pp_string (pp, "\\\\");
3675 break;
3677 case '\"':
3678 pp_string (pp, "\\\"");
3679 break;
3681 case '\'':
3682 pp_string (pp, "\\'");
3683 break;
3685 /* No need to handle \0; the loop terminates on \0. */
3687 case '\1':
3688 pp_string (pp, "\\1");
3689 break;
3691 case '\2':
3692 pp_string (pp, "\\2");
3693 break;
3695 case '\3':
3696 pp_string (pp, "\\3");
3697 break;
3699 case '\4':
3700 pp_string (pp, "\\4");
3701 break;
3703 case '\5':
3704 pp_string (pp, "\\5");
3705 break;
3707 case '\6':
3708 pp_string (pp, "\\6");
3709 break;
3711 case '\7':
3712 pp_string (pp, "\\7");
3713 break;
3715 default:
3716 pp_character (pp, str[0]);
3717 break;
3719 str++;
3723 static void
3724 maybe_init_pretty_print (FILE *file)
3726 if (!tree_pp)
3728 tree_pp = new pretty_printer ();
3729 pp_needs_newline (tree_pp) = true;
3730 pp_translate_identifiers (tree_pp) = false;
3733 tree_pp->buffer->stream = file;
3736 static void
3737 newline_and_indent (pretty_printer *pp, int spc)
3739 pp_newline (pp);
3740 INDENT (spc);
3743 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3744 it can also be used in front ends.
3745 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3748 void
3749 percent_K_format (text_info *text)
3751 tree t = va_arg (*text->args_ptr, tree), block;
3752 text->set_location (0, EXPR_LOCATION (t));
3753 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3754 block = TREE_BLOCK (t);
3755 *pp_ti_abstract_origin (text) = NULL;
3757 if (in_lto_p)
3759 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3760 representing the outermost block of an inlined function.
3761 So walk the BLOCK tree until we hit such a scope. */
3762 while (block
3763 && TREE_CODE (block) == BLOCK)
3765 if (inlined_function_outer_scope_p (block))
3767 *pp_ti_abstract_origin (text) = block;
3768 break;
3770 block = BLOCK_SUPERCONTEXT (block);
3772 return;
3775 while (block
3776 && TREE_CODE (block) == BLOCK
3777 && BLOCK_ABSTRACT_ORIGIN (block))
3779 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3781 while (TREE_CODE (ao) == BLOCK
3782 && BLOCK_ABSTRACT_ORIGIN (ao)
3783 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3784 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3786 if (TREE_CODE (ao) == FUNCTION_DECL)
3788 *pp_ti_abstract_origin (text) = block;
3789 break;
3791 block = BLOCK_SUPERCONTEXT (block);
3795 /* Print the identifier ID to PRETTY-PRINTER. */
3797 void
3798 pp_tree_identifier (pretty_printer *pp, tree id)
3800 if (pp_translate_identifiers (pp))
3802 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3803 pp_append_text (pp, text, text + strlen (text));
3805 else
3806 pp_append_text (pp, IDENTIFIER_POINTER (id),
3807 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3810 /* A helper function that is used to dump function information before the
3811 function dump. */
3813 void
3814 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3816 const char *dname, *aname;
3817 struct cgraph_node *node = cgraph_node::get (fdecl);
3818 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3820 dname = lang_hooks.decl_printable_name (fdecl, 2);
3822 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3823 aname = (IDENTIFIER_POINTER
3824 (DECL_ASSEMBLER_NAME (fdecl)));
3825 else
3826 aname = "<unset-asm-name>";
3828 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3829 dname, aname, fun->funcdef_no);
3830 if (!(flags & TDF_NOUID))
3831 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3832 if (node)
3834 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3835 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3836 node->frequency == NODE_FREQUENCY_HOT
3837 ? " (hot)"
3838 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3839 ? " (unlikely executed)"
3840 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3841 ? " (executed once)"
3842 : "");
3844 else
3845 fprintf (dump_file, ")\n\n");
3848 /* Dump double_int D to pretty_printer PP. UNS is true
3849 if D is unsigned and false otherwise. */
3850 void
3851 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3853 if (d.fits_shwi ())
3854 pp_wide_integer (pp, d.low);
3855 else if (d.fits_uhwi ())
3856 pp_unsigned_wide_integer (pp, d.low);
3857 else
3859 unsigned HOST_WIDE_INT low = d.low;
3860 HOST_WIDE_INT high = d.high;
3861 if (!uns && d.is_negative ())
3863 pp_minus (pp);
3864 high = ~high + !low;
3865 low = -low;
3867 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3868 systems? */
3869 sprintf (pp_buffer (pp)->digit_buffer,
3870 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3871 (unsigned HOST_WIDE_INT) high, low);
3872 pp_string (pp, pp_buffer (pp)->digit_buffer);