PR libstdc++/67078
[official-gcc.git] / gcc / tree-pretty-print.c
blob7cd1fe75ab886de07e0e2744e6efb15503882a2a
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__LOOPTEMP_:
334 name = "_looptemp_";
335 goto print_remap;
336 case OMP_CLAUSE_DEVICE_RESIDENT:
337 name = "device_resident";
338 goto print_remap;
339 case OMP_CLAUSE_USE_DEVICE:
340 name = "use_device";
341 goto print_remap;
342 print_remap:
343 pp_string (pp, name);
344 pp_left_paren (pp);
345 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
346 spc, flags, false);
347 pp_right_paren (pp);
348 break;
350 case OMP_CLAUSE_REDUCTION:
351 pp_string (pp, "reduction(");
352 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
354 pp_string (pp,
355 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
356 pp_colon (pp);
358 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
359 spc, flags, false);
360 pp_right_paren (pp);
361 break;
363 case OMP_CLAUSE_IF:
364 pp_string (pp, "if(");
365 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
366 spc, flags, false);
367 pp_right_paren (pp);
368 break;
370 case OMP_CLAUSE_NUM_THREADS:
371 pp_string (pp, "num_threads(");
372 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
373 spc, flags, false);
374 pp_right_paren (pp);
375 break;
377 case OMP_CLAUSE__CILK_FOR_COUNT_:
378 pp_string (pp, "_Cilk_for_count_(");
379 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
380 spc, flags, false);
381 pp_right_paren (pp);
382 break;
384 case OMP_CLAUSE_NOWAIT:
385 pp_string (pp, "nowait");
386 break;
387 case OMP_CLAUSE_ORDERED:
388 pp_string (pp, "ordered");
389 break;
391 case OMP_CLAUSE_DEFAULT:
392 pp_string (pp, "default(");
393 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
395 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
396 break;
397 case OMP_CLAUSE_DEFAULT_SHARED:
398 pp_string (pp, "shared");
399 break;
400 case OMP_CLAUSE_DEFAULT_NONE:
401 pp_string (pp, "none");
402 break;
403 case OMP_CLAUSE_DEFAULT_PRIVATE:
404 pp_string (pp, "private");
405 break;
406 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
407 pp_string (pp, "firstprivate");
408 break;
409 default:
410 gcc_unreachable ();
412 pp_right_paren (pp);
413 break;
415 case OMP_CLAUSE_SCHEDULE:
416 pp_string (pp, "schedule(");
417 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
419 case OMP_CLAUSE_SCHEDULE_STATIC:
420 pp_string (pp, "static");
421 break;
422 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
423 pp_string (pp, "dynamic");
424 break;
425 case OMP_CLAUSE_SCHEDULE_GUIDED:
426 pp_string (pp, "guided");
427 break;
428 case OMP_CLAUSE_SCHEDULE_RUNTIME:
429 pp_string (pp, "runtime");
430 break;
431 case OMP_CLAUSE_SCHEDULE_AUTO:
432 pp_string (pp, "auto");
433 break;
434 case OMP_CLAUSE_SCHEDULE_CILKFOR:
435 pp_string (pp, "cilk-for grain");
436 break;
437 default:
438 gcc_unreachable ();
440 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
442 pp_comma (pp);
443 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
444 spc, flags, false);
446 pp_right_paren (pp);
447 break;
449 case OMP_CLAUSE_UNTIED:
450 pp_string (pp, "untied");
451 break;
453 case OMP_CLAUSE_COLLAPSE:
454 pp_string (pp, "collapse(");
455 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
456 spc, flags, false);
457 pp_right_paren (pp);
458 break;
460 case OMP_CLAUSE_FINAL:
461 pp_string (pp, "final(");
462 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
463 spc, flags, false);
464 pp_right_paren (pp);
465 break;
467 case OMP_CLAUSE_MERGEABLE:
468 pp_string (pp, "mergeable");
469 break;
471 case OMP_CLAUSE_LINEAR:
472 pp_string (pp, "linear(");
473 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
474 spc, flags, false);
475 pp_colon (pp);
476 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
477 spc, flags, false);
478 pp_right_paren (pp);
479 break;
481 case OMP_CLAUSE_ALIGNED:
482 pp_string (pp, "aligned(");
483 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
484 spc, flags, false);
485 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
487 pp_colon (pp);
488 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
489 spc, flags, false);
491 pp_right_paren (pp);
492 break;
494 case OMP_CLAUSE_DEPEND:
495 pp_string (pp, "depend(");
496 switch (OMP_CLAUSE_DEPEND_KIND (clause))
498 case OMP_CLAUSE_DEPEND_IN:
499 pp_string (pp, "in");
500 break;
501 case OMP_CLAUSE_DEPEND_OUT:
502 pp_string (pp, "out");
503 break;
504 case OMP_CLAUSE_DEPEND_INOUT:
505 pp_string (pp, "inout");
506 break;
507 default:
508 gcc_unreachable ();
510 pp_colon (pp);
511 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
512 spc, flags, false);
513 pp_right_paren (pp);
514 break;
516 case OMP_CLAUSE_MAP:
517 pp_string (pp, "map(");
518 switch (OMP_CLAUSE_MAP_KIND (clause))
520 case GOMP_MAP_ALLOC:
521 case GOMP_MAP_POINTER:
522 pp_string (pp, "alloc");
523 break;
524 case GOMP_MAP_TO:
525 case GOMP_MAP_TO_PSET:
526 pp_string (pp, "to");
527 break;
528 case GOMP_MAP_FROM:
529 pp_string (pp, "from");
530 break;
531 case GOMP_MAP_TOFROM:
532 pp_string (pp, "tofrom");
533 break;
534 case GOMP_MAP_FORCE_ALLOC:
535 pp_string (pp, "force_alloc");
536 break;
537 case GOMP_MAP_FORCE_TO:
538 pp_string (pp, "force_to");
539 break;
540 case GOMP_MAP_FORCE_FROM:
541 pp_string (pp, "force_from");
542 break;
543 case GOMP_MAP_FORCE_TOFROM:
544 pp_string (pp, "force_tofrom");
545 break;
546 case GOMP_MAP_FORCE_PRESENT:
547 pp_string (pp, "force_present");
548 break;
549 case GOMP_MAP_FORCE_DEALLOC:
550 pp_string (pp, "force_dealloc");
551 break;
552 case GOMP_MAP_FORCE_DEVICEPTR:
553 pp_string (pp, "force_deviceptr");
554 break;
555 default:
556 gcc_unreachable ();
558 pp_colon (pp);
559 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
560 spc, flags, false);
561 print_clause_size:
562 if (OMP_CLAUSE_SIZE (clause))
564 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
565 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER)
566 pp_string (pp, " [pointer assign, bias: ");
567 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
568 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET)
569 pp_string (pp, " [pointer set, len: ");
570 else
571 pp_string (pp, " [len: ");
572 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
573 spc, flags, false);
574 pp_right_bracket (pp);
576 pp_right_paren (pp);
577 break;
579 case OMP_CLAUSE_FROM:
580 pp_string (pp, "from(");
581 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
582 spc, flags, false);
583 goto print_clause_size;
585 case OMP_CLAUSE_TO:
586 pp_string (pp, "to(");
587 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
588 spc, flags, false);
589 goto print_clause_size;
591 case OMP_CLAUSE__CACHE_:
592 pp_string (pp, "(");
593 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
594 spc, flags, false);
595 goto print_clause_size;
597 case OMP_CLAUSE_NUM_TEAMS:
598 pp_string (pp, "num_teams(");
599 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
600 spc, flags, false);
601 pp_right_paren (pp);
602 break;
604 case OMP_CLAUSE_THREAD_LIMIT:
605 pp_string (pp, "thread_limit(");
606 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
607 spc, flags, false);
608 pp_right_paren (pp);
609 break;
611 case OMP_CLAUSE_DEVICE:
612 pp_string (pp, "device(");
613 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
614 spc, flags, false);
615 pp_right_paren (pp);
616 break;
618 case OMP_CLAUSE_DIST_SCHEDULE:
619 pp_string (pp, "dist_schedule(static");
620 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
622 pp_comma (pp);
623 dump_generic_node (pp,
624 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
625 spc, flags, false);
627 pp_right_paren (pp);
628 break;
630 case OMP_CLAUSE_PROC_BIND:
631 pp_string (pp, "proc_bind(");
632 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
634 case OMP_CLAUSE_PROC_BIND_MASTER:
635 pp_string (pp, "master");
636 break;
637 case OMP_CLAUSE_PROC_BIND_CLOSE:
638 pp_string (pp, "close");
639 break;
640 case OMP_CLAUSE_PROC_BIND_SPREAD:
641 pp_string (pp, "spread");
642 break;
643 default:
644 gcc_unreachable ();
646 pp_right_paren (pp);
647 break;
649 case OMP_CLAUSE_SAFELEN:
650 pp_string (pp, "safelen(");
651 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
652 spc, flags, false);
653 pp_right_paren (pp);
654 break;
656 case OMP_CLAUSE_SIMDLEN:
657 pp_string (pp, "simdlen(");
658 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
659 spc, flags, false);
660 pp_right_paren (pp);
661 break;
663 case OMP_CLAUSE__SIMDUID_:
664 pp_string (pp, "_simduid_(");
665 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
666 spc, flags, false);
667 pp_right_paren (pp);
668 break;
670 case OMP_CLAUSE_GANG:
671 pp_string (pp, "gang");
672 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
674 pp_string (pp, "(num: ");
675 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
676 spc, flags, false);
678 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
680 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
681 pp_left_paren (pp);
682 else
683 pp_space (pp);
684 pp_string (pp, "static:");
685 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
686 == integer_minus_one_node)
687 pp_character (pp, '*');
688 else
689 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
690 spc, flags, false);
692 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
693 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
694 pp_right_paren (pp);
695 break;
697 case OMP_CLAUSE_ASYNC:
698 pp_string (pp, "async");
699 if (OMP_CLAUSE_ASYNC_EXPR (clause))
701 pp_character(pp, '(');
702 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
703 spc, flags, false);
704 pp_character(pp, ')');
706 break;
708 case OMP_CLAUSE_AUTO:
709 case OMP_CLAUSE_SEQ:
710 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
711 break;
713 case OMP_CLAUSE_WAIT:
714 pp_string (pp, "wait(");
715 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
716 spc, flags, false);
717 pp_character(pp, ')');
718 break;
720 case OMP_CLAUSE_WORKER:
721 pp_string (pp, "worker");
722 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
724 pp_left_paren (pp);
725 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
726 spc, flags, false);
727 pp_right_paren (pp);
729 break;
731 case OMP_CLAUSE_VECTOR:
732 pp_string (pp, "vector");
733 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
735 pp_left_paren (pp);
736 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
737 spc, flags, false);
738 pp_right_paren (pp);
740 break;
742 case OMP_CLAUSE_NUM_GANGS:
743 pp_string (pp, "num_gangs(");
744 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
745 spc, flags, false);
746 pp_character (pp, ')');
747 break;
749 case OMP_CLAUSE_NUM_WORKERS:
750 pp_string (pp, "num_workers(");
751 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
752 spc, flags, false);
753 pp_character (pp, ')');
754 break;
756 case OMP_CLAUSE_VECTOR_LENGTH:
757 pp_string (pp, "vector_length(");
758 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
759 spc, flags, false);
760 pp_character (pp, ')');
761 break;
763 case OMP_CLAUSE_INBRANCH:
764 pp_string (pp, "inbranch");
765 break;
766 case OMP_CLAUSE_NOTINBRANCH:
767 pp_string (pp, "notinbranch");
768 break;
769 case OMP_CLAUSE_FOR:
770 pp_string (pp, "for");
771 break;
772 case OMP_CLAUSE_PARALLEL:
773 pp_string (pp, "parallel");
774 break;
775 case OMP_CLAUSE_SECTIONS:
776 pp_string (pp, "sections");
777 break;
778 case OMP_CLAUSE_TASKGROUP:
779 pp_string (pp, "taskgroup");
780 break;
781 case OMP_CLAUSE_INDEPENDENT:
782 pp_string (pp, "independent");
783 break;
785 default:
786 /* Should never happen. */
787 dump_generic_node (pp, clause, spc, flags, false);
788 break;
793 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
794 dump_generic_node. */
796 void
797 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
799 if (clause == NULL)
800 return;
802 pp_space (pp);
803 while (1)
805 dump_omp_clause (pp, clause, spc, flags);
806 clause = OMP_CLAUSE_CHAIN (clause);
807 if (clause == NULL)
808 return;
809 pp_space (pp);
814 /* Dump location LOC to PP. */
816 void
817 dump_location (pretty_printer *pp, location_t loc)
819 expanded_location xloc = expand_location (loc);
821 pp_left_bracket (pp);
822 if (xloc.file)
824 pp_string (pp, xloc.file);
825 pp_string (pp, ":");
827 pp_decimal_int (pp, xloc.line);
828 pp_colon (pp);
829 pp_decimal_int (pp, xloc.column);
830 pp_string (pp, "] ");
834 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
835 dump_generic_node. */
837 static void
838 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
840 tree t;
842 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
844 if (flags & TDF_ADDRESS)
845 pp_printf (pp, "[%p] ", (void *) block);
847 if (BLOCK_ABSTRACT (block))
848 pp_string (pp, "[abstract] ");
850 if (TREE_ASM_WRITTEN (block))
851 pp_string (pp, "[written] ");
853 if (flags & TDF_SLIM)
854 return;
856 if (BLOCK_SOURCE_LOCATION (block))
857 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
859 newline_and_indent (pp, spc + 2);
861 if (BLOCK_SUPERCONTEXT (block))
863 pp_string (pp, "SUPERCONTEXT: ");
864 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
865 flags | TDF_SLIM, false);
866 newline_and_indent (pp, spc + 2);
869 if (BLOCK_SUBBLOCKS (block))
871 pp_string (pp, "SUBBLOCKS: ");
872 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
874 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
875 pp_space (pp);
877 newline_and_indent (pp, spc + 2);
880 if (BLOCK_CHAIN (block))
882 pp_string (pp, "SIBLINGS: ");
883 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
885 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
886 pp_space (pp);
888 newline_and_indent (pp, spc + 2);
891 if (BLOCK_VARS (block))
893 pp_string (pp, "VARS: ");
894 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
896 dump_generic_node (pp, t, 0, flags, false);
897 pp_space (pp);
899 newline_and_indent (pp, spc + 2);
902 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
904 unsigned i;
905 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
907 pp_string (pp, "NONLOCALIZED_VARS: ");
908 FOR_EACH_VEC_ELT (*nlv, i, t)
910 dump_generic_node (pp, t, 0, flags, false);
911 pp_space (pp);
913 newline_and_indent (pp, spc + 2);
916 if (BLOCK_ABSTRACT_ORIGIN (block))
918 pp_string (pp, "ABSTRACT_ORIGIN: ");
919 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
920 flags | TDF_SLIM, false);
921 newline_and_indent (pp, spc + 2);
924 if (BLOCK_FRAGMENT_ORIGIN (block))
926 pp_string (pp, "FRAGMENT_ORIGIN: ");
927 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
928 flags | TDF_SLIM, false);
929 newline_and_indent (pp, spc + 2);
932 if (BLOCK_FRAGMENT_CHAIN (block))
934 pp_string (pp, "FRAGMENT_CHAIN: ");
935 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
937 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
938 pp_space (pp);
940 newline_and_indent (pp, spc + 2);
945 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
946 indent. FLAGS specifies details to show in the dump (see TDF_* in
947 dumpfile.h). If IS_STMT is true, the object printed is considered
948 to be a statement and it is terminated by ';' if appropriate. */
951 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
952 bool is_stmt)
954 tree type;
955 tree op0, op1;
956 const char *str;
957 bool is_expr;
958 enum tree_code code;
960 if (node == NULL_TREE)
961 return spc;
963 is_expr = EXPR_P (node);
965 if (is_stmt && (flags & TDF_STMTADDR))
966 pp_printf (pp, "<&%p> ", (void *)node);
968 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
969 dump_location (pp, EXPR_LOCATION (node));
971 code = TREE_CODE (node);
972 switch (code)
974 case ERROR_MARK:
975 pp_string (pp, "<<< error >>>");
976 break;
978 case IDENTIFIER_NODE:
979 pp_tree_identifier (pp, node);
980 break;
982 case TREE_LIST:
983 while (node && node != error_mark_node)
985 if (TREE_PURPOSE (node))
987 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
988 pp_space (pp);
990 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
991 node = TREE_CHAIN (node);
992 if (node && TREE_CODE (node) == TREE_LIST)
994 pp_comma (pp);
995 pp_space (pp);
998 break;
1000 case TREE_BINFO:
1001 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1002 break;
1004 case TREE_VEC:
1006 size_t i;
1007 if (TREE_VEC_LENGTH (node) > 0)
1009 size_t len = TREE_VEC_LENGTH (node);
1010 for (i = 0; i < len - 1; i++)
1012 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1013 false);
1014 pp_comma (pp);
1015 pp_space (pp);
1017 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1018 flags, false);
1021 break;
1023 case VOID_TYPE:
1024 case POINTER_BOUNDS_TYPE:
1025 case INTEGER_TYPE:
1026 case REAL_TYPE:
1027 case FIXED_POINT_TYPE:
1028 case COMPLEX_TYPE:
1029 case VECTOR_TYPE:
1030 case ENUMERAL_TYPE:
1031 case BOOLEAN_TYPE:
1033 unsigned int quals = TYPE_QUALS (node);
1034 enum tree_code_class tclass;
1036 if (quals & TYPE_QUAL_ATOMIC)
1037 pp_string (pp, "atomic ");
1038 if (quals & TYPE_QUAL_CONST)
1039 pp_string (pp, "const ");
1040 else if (quals & TYPE_QUAL_VOLATILE)
1041 pp_string (pp, "volatile ");
1042 else if (quals & TYPE_QUAL_RESTRICT)
1043 pp_string (pp, "restrict ");
1045 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1047 pp_string (pp, "<address-space-");
1048 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1049 pp_string (pp, "> ");
1052 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1054 if (tclass == tcc_declaration)
1056 if (DECL_NAME (node))
1057 dump_decl_name (pp, node, flags);
1058 else
1059 pp_string (pp, "<unnamed type decl>");
1061 else if (tclass == tcc_type)
1063 if (TYPE_NAME (node))
1065 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1066 pp_tree_identifier (pp, TYPE_NAME (node));
1067 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1068 && DECL_NAME (TYPE_NAME (node)))
1069 dump_decl_name (pp, TYPE_NAME (node), flags);
1070 else
1071 pp_string (pp, "<unnamed type>");
1073 else if (TREE_CODE (node) == VECTOR_TYPE)
1075 pp_string (pp, "vector");
1076 pp_left_paren (pp);
1077 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1078 pp_string (pp, ") ");
1079 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1081 else if (TREE_CODE (node) == INTEGER_TYPE)
1083 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1084 pp_string (pp, (TYPE_UNSIGNED (node)
1085 ? "unsigned char"
1086 : "signed char"));
1087 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1088 pp_string (pp, (TYPE_UNSIGNED (node)
1089 ? "unsigned short"
1090 : "signed short"));
1091 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1092 pp_string (pp, (TYPE_UNSIGNED (node)
1093 ? "unsigned int"
1094 : "signed int"));
1095 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1096 pp_string (pp, (TYPE_UNSIGNED (node)
1097 ? "unsigned long"
1098 : "signed long"));
1099 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1100 pp_string (pp, (TYPE_UNSIGNED (node)
1101 ? "unsigned long long"
1102 : "signed long long"));
1103 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1104 && exact_log2 (TYPE_PRECISION (node)) != -1)
1106 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1107 pp_decimal_int (pp, TYPE_PRECISION (node));
1108 pp_string (pp, "_t");
1110 else
1112 pp_string (pp, (TYPE_UNSIGNED (node)
1113 ? "<unnamed-unsigned:"
1114 : "<unnamed-signed:"));
1115 pp_decimal_int (pp, TYPE_PRECISION (node));
1116 pp_greater (pp);
1119 else if (TREE_CODE (node) == COMPLEX_TYPE)
1121 pp_string (pp, "__complex__ ");
1122 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1124 else if (TREE_CODE (node) == REAL_TYPE)
1126 pp_string (pp, "<float:");
1127 pp_decimal_int (pp, TYPE_PRECISION (node));
1128 pp_greater (pp);
1130 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1132 pp_string (pp, "<fixed-point-");
1133 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1134 pp_decimal_int (pp, TYPE_PRECISION (node));
1135 pp_greater (pp);
1137 else if (TREE_CODE (node) == VOID_TYPE)
1138 pp_string (pp, "void");
1139 else
1140 pp_string (pp, "<unnamed type>");
1142 break;
1145 case POINTER_TYPE:
1146 case REFERENCE_TYPE:
1147 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1149 if (TREE_TYPE (node) == NULL)
1151 pp_string (pp, str);
1152 pp_string (pp, "<null type>");
1154 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1156 tree fnode = TREE_TYPE (node);
1158 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1159 pp_space (pp);
1160 pp_left_paren (pp);
1161 pp_string (pp, str);
1162 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1163 dump_decl_name (pp, TYPE_NAME (node), flags);
1164 else if (flags & TDF_NOUID)
1165 pp_printf (pp, "<Txxxx>");
1166 else
1167 pp_printf (pp, "<T%x>", TYPE_UID (node));
1169 pp_right_paren (pp);
1170 dump_function_declaration (pp, fnode, spc, flags);
1172 else
1174 unsigned int quals = TYPE_QUALS (node);
1176 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1177 pp_space (pp);
1178 pp_string (pp, str);
1180 if (quals & TYPE_QUAL_CONST)
1181 pp_string (pp, " const");
1182 if (quals & TYPE_QUAL_VOLATILE)
1183 pp_string (pp, " volatile");
1184 if (quals & TYPE_QUAL_RESTRICT)
1185 pp_string (pp, " restrict");
1187 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1189 pp_string (pp, " <address-space-");
1190 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1191 pp_greater (pp);
1194 if (TYPE_REF_CAN_ALIAS_ALL (node))
1195 pp_string (pp, " {ref-all}");
1197 break;
1199 case OFFSET_TYPE:
1200 NIY;
1201 break;
1203 case MEM_REF:
1205 if (integer_zerop (TREE_OPERAND (node, 1))
1206 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1207 infer them and MEM_ATTR caching will share MEM_REFs
1208 with differently-typed op0s. */
1209 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1210 /* Released SSA_NAMES have no TREE_TYPE. */
1211 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1212 /* Same pointer types, but ignoring POINTER_TYPE vs.
1213 REFERENCE_TYPE. */
1214 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1215 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1216 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1217 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1218 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1219 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1220 /* Same value types ignoring qualifiers. */
1221 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1222 == TYPE_MAIN_VARIANT
1223 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1224 && (!(flags & TDF_ALIAS)
1225 || MR_DEPENDENCE_CLIQUE (node) == 0))
1227 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1229 pp_star (pp);
1230 dump_generic_node (pp, TREE_OPERAND (node, 0),
1231 spc, flags, false);
1233 else
1234 dump_generic_node (pp,
1235 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1236 spc, flags, false);
1238 else
1240 tree ptype;
1242 pp_string (pp, "MEM[");
1243 pp_left_paren (pp);
1244 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1245 dump_generic_node (pp, ptype,
1246 spc, flags | TDF_SLIM, false);
1247 pp_right_paren (pp);
1248 dump_generic_node (pp, TREE_OPERAND (node, 0),
1249 spc, flags, false);
1250 if (!integer_zerop (TREE_OPERAND (node, 1)))
1252 pp_string (pp, " + ");
1253 dump_generic_node (pp, TREE_OPERAND (node, 1),
1254 spc, flags, false);
1256 if ((flags & TDF_ALIAS)
1257 && MR_DEPENDENCE_CLIQUE (node) != 0)
1259 pp_string (pp, " clique ");
1260 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1261 pp_string (pp, " base ");
1262 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1264 pp_right_bracket (pp);
1266 break;
1269 case TARGET_MEM_REF:
1271 const char *sep = "";
1272 tree tmp;
1274 pp_string (pp, "MEM[");
1276 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1278 pp_string (pp, sep);
1279 sep = ", ";
1280 pp_string (pp, "symbol: ");
1281 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1282 spc, flags, false);
1284 else
1286 pp_string (pp, sep);
1287 sep = ", ";
1288 pp_string (pp, "base: ");
1289 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1291 tmp = TMR_INDEX2 (node);
1292 if (tmp)
1294 pp_string (pp, sep);
1295 sep = ", ";
1296 pp_string (pp, "base: ");
1297 dump_generic_node (pp, tmp, spc, flags, false);
1299 tmp = TMR_INDEX (node);
1300 if (tmp)
1302 pp_string (pp, sep);
1303 sep = ", ";
1304 pp_string (pp, "index: ");
1305 dump_generic_node (pp, tmp, spc, flags, false);
1307 tmp = TMR_STEP (node);
1308 if (tmp)
1310 pp_string (pp, sep);
1311 sep = ", ";
1312 pp_string (pp, "step: ");
1313 dump_generic_node (pp, tmp, spc, flags, false);
1315 tmp = TMR_OFFSET (node);
1316 if (tmp)
1318 pp_string (pp, sep);
1319 sep = ", ";
1320 pp_string (pp, "offset: ");
1321 dump_generic_node (pp, tmp, spc, flags, false);
1323 pp_right_bracket (pp);
1325 break;
1327 case ARRAY_TYPE:
1329 tree tmp;
1331 /* Print the innermost component type. */
1332 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1333 tmp = TREE_TYPE (tmp))
1335 dump_generic_node (pp, tmp, spc, flags, false);
1337 /* Print the dimensions. */
1338 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1339 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1340 break;
1343 case RECORD_TYPE:
1344 case UNION_TYPE:
1345 case QUAL_UNION_TYPE:
1347 unsigned int quals = TYPE_QUALS (node);
1349 if (quals & TYPE_QUAL_ATOMIC)
1350 pp_string (pp, "atomic ");
1351 if (quals & TYPE_QUAL_CONST)
1352 pp_string (pp, "const ");
1353 if (quals & TYPE_QUAL_VOLATILE)
1354 pp_string (pp, "volatile ");
1356 /* Print the name of the structure. */
1357 if (TREE_CODE (node) == RECORD_TYPE)
1358 pp_string (pp, "struct ");
1359 else if (TREE_CODE (node) == UNION_TYPE)
1360 pp_string (pp, "union ");
1362 if (TYPE_NAME (node))
1363 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1364 else if (!(flags & TDF_SLIM))
1365 /* FIXME: If we eliminate the 'else' above and attempt
1366 to show the fields for named types, we may get stuck
1367 following a cycle of pointers to structs. The alleged
1368 self-reference check in print_struct_decl will not detect
1369 cycles involving more than one pointer or struct type. */
1370 print_struct_decl (pp, node, spc, flags);
1371 break;
1374 case LANG_TYPE:
1375 NIY;
1376 break;
1378 case INTEGER_CST:
1379 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1381 /* In the case of a pointer, one may want to divide by the
1382 size of the pointed-to type. Unfortunately, this not
1383 straightforward. The C front-end maps expressions
1385 (int *) 5
1386 int *p; (p + 5)
1388 in such a way that the two INTEGER_CST nodes for "5" have
1389 different values but identical types. In the latter
1390 case, the 5 is multiplied by sizeof (int) in c-common.c
1391 (pointer_int_sum) to convert it to a byte address, and
1392 yet the type of the node is left unchanged. Argh. What
1393 is consistent though is that the number value corresponds
1394 to bytes (UNITS) offset.
1396 NB: Neither of the following divisors can be trivially
1397 used to recover the original literal:
1399 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1400 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1401 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1402 pp_string (pp, "B"); /* pseudo-unit */
1404 else if (tree_fits_shwi_p (node))
1405 pp_wide_integer (pp, tree_to_shwi (node));
1406 else if (tree_fits_uhwi_p (node))
1407 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1408 else
1410 wide_int val = node;
1412 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1414 pp_minus (pp);
1415 val = -val;
1417 print_hex (val, pp_buffer (pp)->digit_buffer);
1418 pp_string (pp, pp_buffer (pp)->digit_buffer);
1420 if (TREE_OVERFLOW (node))
1421 pp_string (pp, "(OVF)");
1422 break;
1424 case REAL_CST:
1425 /* Code copied from print_node. */
1427 REAL_VALUE_TYPE d;
1428 if (TREE_OVERFLOW (node))
1429 pp_string (pp, " overflow");
1431 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1432 d = TREE_REAL_CST (node);
1433 if (REAL_VALUE_ISINF (d))
1434 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1435 else if (REAL_VALUE_ISNAN (d))
1436 pp_string (pp, " Nan");
1437 else
1439 char string[100];
1440 real_to_decimal (string, &d, sizeof (string), 0, 1);
1441 pp_string (pp, string);
1443 #else
1445 HOST_WIDE_INT i;
1446 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1447 pp_string (pp, "0x");
1448 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1449 output_formatted_integer (pp, "%02x", *p++);
1451 #endif
1452 break;
1455 case FIXED_CST:
1457 char string[100];
1458 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1459 pp_string (pp, string);
1460 break;
1463 case COMPLEX_CST:
1464 pp_string (pp, "__complex__ (");
1465 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1466 pp_string (pp, ", ");
1467 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1468 pp_right_paren (pp);
1469 break;
1471 case STRING_CST:
1472 pp_string (pp, "\"");
1473 pretty_print_string (pp, TREE_STRING_POINTER (node));
1474 pp_string (pp, "\"");
1475 break;
1477 case VECTOR_CST:
1479 unsigned i;
1480 pp_string (pp, "{ ");
1481 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1483 if (i != 0)
1484 pp_string (pp, ", ");
1485 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1486 spc, flags, false);
1488 pp_string (pp, " }");
1490 break;
1492 case FUNCTION_TYPE:
1493 case METHOD_TYPE:
1494 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1495 pp_space (pp);
1496 if (TREE_CODE (node) == METHOD_TYPE)
1498 if (TYPE_METHOD_BASETYPE (node))
1499 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1500 flags);
1501 else
1502 pp_string (pp, "<null method basetype>");
1503 pp_colon_colon (pp);
1505 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1506 dump_decl_name (pp, TYPE_NAME (node), flags);
1507 else if (flags & TDF_NOUID)
1508 pp_printf (pp, "<Txxxx>");
1509 else
1510 pp_printf (pp, "<T%x>", TYPE_UID (node));
1511 dump_function_declaration (pp, node, spc, flags);
1512 break;
1514 case FUNCTION_DECL:
1515 case CONST_DECL:
1516 dump_decl_name (pp, node, flags);
1517 break;
1519 case LABEL_DECL:
1520 if (DECL_NAME (node))
1521 dump_decl_name (pp, node, flags);
1522 else if (LABEL_DECL_UID (node) != -1)
1523 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1524 else
1526 if (flags & TDF_NOUID)
1527 pp_string (pp, "<D.xxxx>");
1528 else
1529 pp_printf (pp, "<D.%u>", DECL_UID (node));
1531 break;
1533 case TYPE_DECL:
1534 if (DECL_IS_BUILTIN (node))
1536 /* Don't print the declaration of built-in types. */
1537 break;
1539 if (DECL_NAME (node))
1540 dump_decl_name (pp, node, flags);
1541 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1543 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1544 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1545 && TYPE_METHODS (TREE_TYPE (node)))
1547 /* The type is a c++ class: all structures have at least
1548 4 methods. */
1549 pp_string (pp, "class ");
1550 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1552 else
1554 pp_string (pp,
1555 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1556 ? "union" : "struct "));
1557 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1560 else
1561 pp_string (pp, "<anon>");
1562 break;
1564 case VAR_DECL:
1565 case PARM_DECL:
1566 case FIELD_DECL:
1567 case DEBUG_EXPR_DECL:
1568 case NAMESPACE_DECL:
1569 case NAMELIST_DECL:
1570 dump_decl_name (pp, node, flags);
1571 break;
1573 case RESULT_DECL:
1574 pp_string (pp, "<retval>");
1575 break;
1577 case COMPONENT_REF:
1578 op0 = TREE_OPERAND (node, 0);
1579 str = ".";
1580 if (op0
1581 && (TREE_CODE (op0) == INDIRECT_REF
1582 || (TREE_CODE (op0) == MEM_REF
1583 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1584 && integer_zerop (TREE_OPERAND (op0, 1))
1585 /* Dump the types of INTEGER_CSTs explicitly, for we
1586 can't infer them and MEM_ATTR caching will share
1587 MEM_REFs with differently-typed op0s. */
1588 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1589 /* Released SSA_NAMES have no TREE_TYPE. */
1590 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1591 /* Same pointer types, but ignoring POINTER_TYPE vs.
1592 REFERENCE_TYPE. */
1593 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1594 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1595 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1596 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1597 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1598 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1599 /* Same value types ignoring qualifiers. */
1600 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1601 == TYPE_MAIN_VARIANT
1602 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1603 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1605 op0 = TREE_OPERAND (op0, 0);
1606 str = "->";
1608 if (op_prio (op0) < op_prio (node))
1609 pp_left_paren (pp);
1610 dump_generic_node (pp, op0, spc, flags, false);
1611 if (op_prio (op0) < op_prio (node))
1612 pp_right_paren (pp);
1613 pp_string (pp, str);
1614 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1615 op0 = component_ref_field_offset (node);
1616 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1618 pp_string (pp, "{off: ");
1619 dump_generic_node (pp, op0, spc, flags, false);
1620 pp_right_brace (pp);
1622 break;
1624 case BIT_FIELD_REF:
1625 pp_string (pp, "BIT_FIELD_REF <");
1626 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1627 pp_string (pp, ", ");
1628 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1629 pp_string (pp, ", ");
1630 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1631 pp_greater (pp);
1632 break;
1634 case ARRAY_REF:
1635 case ARRAY_RANGE_REF:
1636 op0 = TREE_OPERAND (node, 0);
1637 if (op_prio (op0) < op_prio (node))
1638 pp_left_paren (pp);
1639 dump_generic_node (pp, op0, spc, flags, false);
1640 if (op_prio (op0) < op_prio (node))
1641 pp_right_paren (pp);
1642 pp_left_bracket (pp);
1643 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1644 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1645 pp_string (pp, " ...");
1646 pp_right_bracket (pp);
1648 op0 = array_ref_low_bound (node);
1649 op1 = array_ref_element_size (node);
1651 if (!integer_zerop (op0)
1652 || TREE_OPERAND (node, 2)
1653 || TREE_OPERAND (node, 3))
1655 pp_string (pp, "{lb: ");
1656 dump_generic_node (pp, op0, spc, flags, false);
1657 pp_string (pp, " sz: ");
1658 dump_generic_node (pp, op1, spc, flags, false);
1659 pp_right_brace (pp);
1661 break;
1663 case CONSTRUCTOR:
1665 unsigned HOST_WIDE_INT ix;
1666 tree field, val;
1667 bool is_struct_init = false;
1668 bool is_array_init = false;
1669 widest_int curidx;
1670 pp_left_brace (pp);
1671 if (TREE_CLOBBER_P (node))
1672 pp_string (pp, "CLOBBER");
1673 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1674 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1675 is_struct_init = true;
1676 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1677 && TYPE_DOMAIN (TREE_TYPE (node))
1678 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1679 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1680 == INTEGER_CST)
1682 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1683 is_array_init = true;
1684 curidx = wi::to_widest (minv);
1686 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1688 if (field)
1690 if (is_struct_init)
1692 pp_dot (pp);
1693 dump_generic_node (pp, field, spc, flags, false);
1694 pp_equal (pp);
1696 else if (is_array_init
1697 && (TREE_CODE (field) != INTEGER_CST
1698 || curidx != wi::to_widest (field)))
1700 pp_left_bracket (pp);
1701 if (TREE_CODE (field) == RANGE_EXPR)
1703 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1704 flags, false);
1705 pp_string (pp, " ... ");
1706 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1707 flags, false);
1708 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1709 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1711 else
1712 dump_generic_node (pp, field, spc, flags, false);
1713 if (TREE_CODE (field) == INTEGER_CST)
1714 curidx = wi::to_widest (field);
1715 pp_string (pp, "]=");
1718 if (is_array_init)
1719 curidx += 1;
1720 if (val && TREE_CODE (val) == ADDR_EXPR)
1721 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1722 val = TREE_OPERAND (val, 0);
1723 if (val && TREE_CODE (val) == FUNCTION_DECL)
1724 dump_decl_name (pp, val, flags);
1725 else
1726 dump_generic_node (pp, val, spc, flags, false);
1727 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1729 pp_comma (pp);
1730 pp_space (pp);
1733 pp_right_brace (pp);
1735 break;
1737 case COMPOUND_EXPR:
1739 tree *tp;
1740 if (flags & TDF_SLIM)
1742 pp_string (pp, "<COMPOUND_EXPR>");
1743 break;
1746 dump_generic_node (pp, TREE_OPERAND (node, 0),
1747 spc, flags, !(flags & TDF_SLIM));
1748 if (flags & TDF_SLIM)
1749 newline_and_indent (pp, spc);
1750 else
1752 pp_comma (pp);
1753 pp_space (pp);
1756 for (tp = &TREE_OPERAND (node, 1);
1757 TREE_CODE (*tp) == COMPOUND_EXPR;
1758 tp = &TREE_OPERAND (*tp, 1))
1760 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1761 spc, flags, !(flags & TDF_SLIM));
1762 if (flags & TDF_SLIM)
1763 newline_and_indent (pp, spc);
1764 else
1766 pp_comma (pp);
1767 pp_space (pp);
1771 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1773 break;
1775 case STATEMENT_LIST:
1777 tree_stmt_iterator si;
1778 bool first = true;
1780 if (flags & TDF_SLIM)
1782 pp_string (pp, "<STATEMENT_LIST>");
1783 break;
1786 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1788 if (!first)
1789 newline_and_indent (pp, spc);
1790 else
1791 first = false;
1792 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1795 break;
1797 case MODIFY_EXPR:
1798 case INIT_EXPR:
1799 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1800 false);
1801 pp_space (pp);
1802 pp_equal (pp);
1803 pp_space (pp);
1804 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1805 false);
1806 break;
1808 case TARGET_EXPR:
1809 pp_string (pp, "TARGET_EXPR <");
1810 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1811 pp_comma (pp);
1812 pp_space (pp);
1813 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1814 pp_greater (pp);
1815 break;
1817 case DECL_EXPR:
1818 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1819 is_stmt = false;
1820 break;
1822 case COND_EXPR:
1823 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1825 pp_string (pp, "if (");
1826 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1827 pp_right_paren (pp);
1828 /* The lowered cond_exprs should always be printed in full. */
1829 if (COND_EXPR_THEN (node)
1830 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1831 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1832 && COND_EXPR_ELSE (node)
1833 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1834 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1836 pp_space (pp);
1837 dump_generic_node (pp, COND_EXPR_THEN (node),
1838 0, flags, true);
1839 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1841 pp_string (pp, " else ");
1842 dump_generic_node (pp, COND_EXPR_ELSE (node),
1843 0, flags, true);
1846 else if (!(flags & TDF_SLIM))
1848 /* Output COND_EXPR_THEN. */
1849 if (COND_EXPR_THEN (node))
1851 newline_and_indent (pp, spc+2);
1852 pp_left_brace (pp);
1853 newline_and_indent (pp, spc+4);
1854 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
1855 flags, true);
1856 newline_and_indent (pp, spc+2);
1857 pp_right_brace (pp);
1860 /* Output COND_EXPR_ELSE. */
1861 if (COND_EXPR_ELSE (node)
1862 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1864 newline_and_indent (pp, spc);
1865 pp_string (pp, "else");
1866 newline_and_indent (pp, spc+2);
1867 pp_left_brace (pp);
1868 newline_and_indent (pp, spc+4);
1869 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
1870 flags, true);
1871 newline_and_indent (pp, spc+2);
1872 pp_right_brace (pp);
1875 is_expr = false;
1877 else
1879 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1880 pp_space (pp);
1881 pp_question (pp);
1882 pp_space (pp);
1883 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1884 pp_space (pp);
1885 pp_colon (pp);
1886 pp_space (pp);
1887 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1889 break;
1891 case BIND_EXPR:
1892 pp_left_brace (pp);
1893 if (!(flags & TDF_SLIM))
1895 if (BIND_EXPR_VARS (node))
1897 pp_newline (pp);
1899 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1901 print_declaration (pp, op0, spc+2, flags);
1902 pp_newline (pp);
1906 newline_and_indent (pp, spc+2);
1907 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
1908 newline_and_indent (pp, spc);
1909 pp_right_brace (pp);
1911 is_expr = false;
1912 break;
1914 case CALL_EXPR:
1915 if (CALL_EXPR_FN (node) != NULL_TREE)
1916 print_call_name (pp, CALL_EXPR_FN (node), flags);
1917 else
1918 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
1920 /* Print parameters. */
1921 pp_space (pp);
1922 pp_left_paren (pp);
1924 tree arg;
1925 call_expr_arg_iterator iter;
1926 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1928 dump_generic_node (pp, arg, spc, flags, false);
1929 if (more_call_expr_args_p (&iter))
1931 pp_comma (pp);
1932 pp_space (pp);
1936 if (CALL_EXPR_VA_ARG_PACK (node))
1938 if (call_expr_nargs (node) > 0)
1940 pp_comma (pp);
1941 pp_space (pp);
1943 pp_string (pp, "__builtin_va_arg_pack ()");
1945 pp_right_paren (pp);
1947 op1 = CALL_EXPR_STATIC_CHAIN (node);
1948 if (op1)
1950 pp_string (pp, " [static-chain: ");
1951 dump_generic_node (pp, op1, spc, flags, false);
1952 pp_right_bracket (pp);
1955 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1956 pp_string (pp, " [return slot optimization]");
1957 if (CALL_EXPR_TAILCALL (node))
1958 pp_string (pp, " [tail call]");
1959 break;
1961 case WITH_CLEANUP_EXPR:
1962 NIY;
1963 break;
1965 case CLEANUP_POINT_EXPR:
1966 pp_string (pp, "<<cleanup_point ");
1967 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1968 pp_string (pp, ">>");
1969 break;
1971 case PLACEHOLDER_EXPR:
1972 pp_string (pp, "<PLACEHOLDER_EXPR ");
1973 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1974 pp_greater (pp);
1975 break;
1977 /* Binary arithmetic and logic expressions. */
1978 case WIDEN_SUM_EXPR:
1979 case WIDEN_MULT_EXPR:
1980 case MULT_EXPR:
1981 case MULT_HIGHPART_EXPR:
1982 case PLUS_EXPR:
1983 case POINTER_PLUS_EXPR:
1984 case MINUS_EXPR:
1985 case TRUNC_DIV_EXPR:
1986 case CEIL_DIV_EXPR:
1987 case FLOOR_DIV_EXPR:
1988 case ROUND_DIV_EXPR:
1989 case TRUNC_MOD_EXPR:
1990 case CEIL_MOD_EXPR:
1991 case FLOOR_MOD_EXPR:
1992 case ROUND_MOD_EXPR:
1993 case RDIV_EXPR:
1994 case EXACT_DIV_EXPR:
1995 case LSHIFT_EXPR:
1996 case RSHIFT_EXPR:
1997 case LROTATE_EXPR:
1998 case RROTATE_EXPR:
1999 case WIDEN_LSHIFT_EXPR:
2000 case BIT_IOR_EXPR:
2001 case BIT_XOR_EXPR:
2002 case BIT_AND_EXPR:
2003 case TRUTH_ANDIF_EXPR:
2004 case TRUTH_ORIF_EXPR:
2005 case TRUTH_AND_EXPR:
2006 case TRUTH_OR_EXPR:
2007 case TRUTH_XOR_EXPR:
2008 case LT_EXPR:
2009 case LE_EXPR:
2010 case GT_EXPR:
2011 case GE_EXPR:
2012 case EQ_EXPR:
2013 case NE_EXPR:
2014 case UNLT_EXPR:
2015 case UNLE_EXPR:
2016 case UNGT_EXPR:
2017 case UNGE_EXPR:
2018 case UNEQ_EXPR:
2019 case LTGT_EXPR:
2020 case ORDERED_EXPR:
2021 case UNORDERED_EXPR:
2023 const char *op = op_symbol (node);
2024 op0 = TREE_OPERAND (node, 0);
2025 op1 = TREE_OPERAND (node, 1);
2027 /* When the operands are expressions with less priority,
2028 keep semantics of the tree representation. */
2029 if (op_prio (op0) <= op_prio (node))
2031 pp_left_paren (pp);
2032 dump_generic_node (pp, op0, spc, flags, false);
2033 pp_right_paren (pp);
2035 else
2036 dump_generic_node (pp, op0, spc, flags, false);
2038 pp_space (pp);
2039 pp_string (pp, op);
2040 pp_space (pp);
2042 /* When the operands are expressions with less priority,
2043 keep semantics of the tree representation. */
2044 if (op_prio (op1) <= op_prio (node))
2046 pp_left_paren (pp);
2047 dump_generic_node (pp, op1, spc, flags, false);
2048 pp_right_paren (pp);
2050 else
2051 dump_generic_node (pp, op1, spc, flags, false);
2053 break;
2055 /* Unary arithmetic and logic expressions. */
2056 case NEGATE_EXPR:
2057 case BIT_NOT_EXPR:
2058 case TRUTH_NOT_EXPR:
2059 case ADDR_EXPR:
2060 case PREDECREMENT_EXPR:
2061 case PREINCREMENT_EXPR:
2062 case INDIRECT_REF:
2063 if (TREE_CODE (node) == ADDR_EXPR
2064 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2065 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2066 ; /* Do not output '&' for strings and function pointers. */
2067 else
2068 pp_string (pp, op_symbol (node));
2070 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2072 pp_left_paren (pp);
2073 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2074 pp_right_paren (pp);
2076 else
2077 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2078 break;
2080 case POSTDECREMENT_EXPR:
2081 case POSTINCREMENT_EXPR:
2082 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2084 pp_left_paren (pp);
2085 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2086 pp_right_paren (pp);
2088 else
2089 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2090 pp_string (pp, op_symbol (node));
2091 break;
2093 case MIN_EXPR:
2094 pp_string (pp, "MIN_EXPR <");
2095 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2096 pp_string (pp, ", ");
2097 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2098 pp_greater (pp);
2099 break;
2101 case MAX_EXPR:
2102 pp_string (pp, "MAX_EXPR <");
2103 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2104 pp_string (pp, ", ");
2105 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2106 pp_greater (pp);
2107 break;
2109 case ABS_EXPR:
2110 pp_string (pp, "ABS_EXPR <");
2111 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2112 pp_greater (pp);
2113 break;
2115 case RANGE_EXPR:
2116 NIY;
2117 break;
2119 case ADDR_SPACE_CONVERT_EXPR:
2120 case FIXED_CONVERT_EXPR:
2121 case FIX_TRUNC_EXPR:
2122 case FLOAT_EXPR:
2123 CASE_CONVERT:
2124 type = TREE_TYPE (node);
2125 op0 = TREE_OPERAND (node, 0);
2126 if (type != TREE_TYPE (op0))
2128 pp_left_paren (pp);
2129 dump_generic_node (pp, type, spc, flags, false);
2130 pp_string (pp, ") ");
2132 if (op_prio (op0) < op_prio (node))
2133 pp_left_paren (pp);
2134 dump_generic_node (pp, op0, spc, flags, false);
2135 if (op_prio (op0) < op_prio (node))
2136 pp_right_paren (pp);
2137 break;
2139 case VIEW_CONVERT_EXPR:
2140 pp_string (pp, "VIEW_CONVERT_EXPR<");
2141 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2142 pp_string (pp, ">(");
2143 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2144 pp_right_paren (pp);
2145 break;
2147 case PAREN_EXPR:
2148 pp_string (pp, "((");
2149 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2150 pp_string (pp, "))");
2151 break;
2153 case NON_LVALUE_EXPR:
2154 pp_string (pp, "NON_LVALUE_EXPR <");
2155 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2156 pp_greater (pp);
2157 break;
2159 case SAVE_EXPR:
2160 pp_string (pp, "SAVE_EXPR <");
2161 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2162 pp_greater (pp);
2163 break;
2165 case COMPLEX_EXPR:
2166 pp_string (pp, "COMPLEX_EXPR <");
2167 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2168 pp_string (pp, ", ");
2169 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2170 pp_greater (pp);
2171 break;
2173 case CONJ_EXPR:
2174 pp_string (pp, "CONJ_EXPR <");
2175 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2176 pp_greater (pp);
2177 break;
2179 case REALPART_EXPR:
2180 pp_string (pp, "REALPART_EXPR <");
2181 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2182 pp_greater (pp);
2183 break;
2185 case IMAGPART_EXPR:
2186 pp_string (pp, "IMAGPART_EXPR <");
2187 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2188 pp_greater (pp);
2189 break;
2191 case VA_ARG_EXPR:
2192 pp_string (pp, "VA_ARG_EXPR <");
2193 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2194 pp_greater (pp);
2195 break;
2197 case TRY_FINALLY_EXPR:
2198 case TRY_CATCH_EXPR:
2199 pp_string (pp, "try");
2200 newline_and_indent (pp, spc+2);
2201 pp_left_brace (pp);
2202 newline_and_indent (pp, spc+4);
2203 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2204 newline_and_indent (pp, spc+2);
2205 pp_right_brace (pp);
2206 newline_and_indent (pp, spc);
2207 pp_string (pp,
2208 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2209 newline_and_indent (pp, spc+2);
2210 pp_left_brace (pp);
2211 newline_and_indent (pp, spc+4);
2212 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2213 newline_and_indent (pp, spc+2);
2214 pp_right_brace (pp);
2215 is_expr = false;
2216 break;
2218 case CATCH_EXPR:
2219 pp_string (pp, "catch (");
2220 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2221 pp_right_paren (pp);
2222 newline_and_indent (pp, spc+2);
2223 pp_left_brace (pp);
2224 newline_and_indent (pp, spc+4);
2225 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2226 newline_and_indent (pp, spc+2);
2227 pp_right_brace (pp);
2228 is_expr = false;
2229 break;
2231 case EH_FILTER_EXPR:
2232 pp_string (pp, "<<<eh_filter (");
2233 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2234 pp_string (pp, ")>>>");
2235 newline_and_indent (pp, spc+2);
2236 pp_left_brace (pp);
2237 newline_and_indent (pp, spc+4);
2238 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2239 newline_and_indent (pp, spc+2);
2240 pp_right_brace (pp);
2241 is_expr = false;
2242 break;
2244 case LABEL_EXPR:
2245 op0 = TREE_OPERAND (node, 0);
2246 /* If this is for break or continue, don't bother printing it. */
2247 if (DECL_NAME (op0))
2249 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2250 if (strcmp (name, "break") == 0
2251 || strcmp (name, "continue") == 0)
2252 break;
2254 dump_generic_node (pp, op0, spc, flags, false);
2255 pp_colon (pp);
2256 if (DECL_NONLOCAL (op0))
2257 pp_string (pp, " [non-local]");
2258 break;
2260 case LOOP_EXPR:
2261 pp_string (pp, "while (1)");
2262 if (!(flags & TDF_SLIM))
2264 newline_and_indent (pp, spc+2);
2265 pp_left_brace (pp);
2266 newline_and_indent (pp, spc+4);
2267 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2268 newline_and_indent (pp, spc+2);
2269 pp_right_brace (pp);
2271 is_expr = false;
2272 break;
2274 case PREDICT_EXPR:
2275 pp_string (pp, "// predicted ");
2276 if (PREDICT_EXPR_OUTCOME (node))
2277 pp_string (pp, "likely by ");
2278 else
2279 pp_string (pp, "unlikely by ");
2280 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2281 pp_string (pp, " predictor.");
2282 break;
2284 case ANNOTATE_EXPR:
2285 pp_string (pp, "ANNOTATE_EXPR <");
2286 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2287 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2289 case annot_expr_ivdep_kind:
2290 pp_string (pp, ", ivdep");
2291 break;
2292 case annot_expr_no_vector_kind:
2293 pp_string (pp, ", no-vector");
2294 break;
2295 case annot_expr_vector_kind:
2296 pp_string (pp, ", vector");
2297 break;
2298 default:
2299 gcc_unreachable ();
2301 pp_greater (pp);
2302 break;
2304 case RETURN_EXPR:
2305 pp_string (pp, "return");
2306 op0 = TREE_OPERAND (node, 0);
2307 if (op0)
2309 pp_space (pp);
2310 if (TREE_CODE (op0) == MODIFY_EXPR)
2311 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2312 spc, flags, false);
2313 else
2314 dump_generic_node (pp, op0, spc, flags, false);
2316 break;
2318 case EXIT_EXPR:
2319 pp_string (pp, "if (");
2320 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2321 pp_string (pp, ") break");
2322 break;
2324 case SWITCH_EXPR:
2325 pp_string (pp, "switch (");
2326 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2327 pp_right_paren (pp);
2328 if (!(flags & TDF_SLIM))
2330 newline_and_indent (pp, spc+2);
2331 pp_left_brace (pp);
2332 if (SWITCH_BODY (node))
2334 newline_and_indent (pp, spc+4);
2335 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2336 true);
2338 else
2340 tree vec = SWITCH_LABELS (node);
2341 size_t i, n = TREE_VEC_LENGTH (vec);
2342 for (i = 0; i < n; ++i)
2344 tree elt = TREE_VEC_ELT (vec, i);
2345 newline_and_indent (pp, spc+4);
2346 if (elt)
2348 dump_generic_node (pp, elt, spc+4, flags, false);
2349 pp_string (pp, " goto ");
2350 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2351 flags, true);
2352 pp_semicolon (pp);
2354 else
2355 pp_string (pp, "case ???: goto ???;");
2358 newline_and_indent (pp, spc+2);
2359 pp_right_brace (pp);
2361 is_expr = false;
2362 break;
2364 case GOTO_EXPR:
2365 op0 = GOTO_DESTINATION (node);
2366 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2368 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2369 if (strcmp (name, "break") == 0
2370 || strcmp (name, "continue") == 0)
2372 pp_string (pp, name);
2373 break;
2376 pp_string (pp, "goto ");
2377 dump_generic_node (pp, op0, spc, flags, false);
2378 break;
2380 case ASM_EXPR:
2381 pp_string (pp, "__asm__");
2382 if (ASM_VOLATILE_P (node))
2383 pp_string (pp, " __volatile__");
2384 pp_left_paren (pp);
2385 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2386 pp_colon (pp);
2387 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2388 pp_colon (pp);
2389 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2390 if (ASM_CLOBBERS (node))
2392 pp_colon (pp);
2393 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2395 pp_right_paren (pp);
2396 break;
2398 case CASE_LABEL_EXPR:
2399 if (CASE_LOW (node) && CASE_HIGH (node))
2401 pp_string (pp, "case ");
2402 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2403 pp_string (pp, " ... ");
2404 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2406 else if (CASE_LOW (node))
2408 pp_string (pp, "case ");
2409 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2411 else
2412 pp_string (pp, "default");
2413 pp_colon (pp);
2414 break;
2416 case OBJ_TYPE_REF:
2417 pp_string (pp, "OBJ_TYPE_REF(");
2418 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2419 pp_semicolon (pp);
2420 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2422 pp_string (pp, "(");
2423 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2424 pp_string (pp, ")");
2426 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2427 pp_arrow (pp);
2428 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2429 pp_right_paren (pp);
2430 break;
2432 case SSA_NAME:
2433 if (SSA_NAME_IDENTIFIER (node))
2434 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2435 spc, flags, false);
2436 pp_underscore (pp);
2437 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2438 if (SSA_NAME_IS_DEFAULT_DEF (node))
2439 pp_string (pp, "(D)");
2440 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2441 pp_string (pp, "(ab)");
2442 break;
2444 case WITH_SIZE_EXPR:
2445 pp_string (pp, "WITH_SIZE_EXPR <");
2446 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2447 pp_string (pp, ", ");
2448 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2449 pp_greater (pp);
2450 break;
2452 case ASSERT_EXPR:
2453 pp_string (pp, "ASSERT_EXPR <");
2454 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2455 pp_string (pp, ", ");
2456 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2457 pp_greater (pp);
2458 break;
2460 case SCEV_KNOWN:
2461 pp_string (pp, "scev_known");
2462 break;
2464 case SCEV_NOT_KNOWN:
2465 pp_string (pp, "scev_not_known");
2466 break;
2468 case POLYNOMIAL_CHREC:
2469 pp_left_brace (pp);
2470 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2471 pp_string (pp, ", +, ");
2472 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2473 pp_string (pp, "}_");
2474 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2475 is_stmt = false;
2476 break;
2478 case REALIGN_LOAD_EXPR:
2479 pp_string (pp, "REALIGN_LOAD <");
2480 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2481 pp_string (pp, ", ");
2482 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2483 pp_string (pp, ", ");
2484 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2485 pp_greater (pp);
2486 break;
2488 case VEC_COND_EXPR:
2489 pp_string (pp, " VEC_COND_EXPR < ");
2490 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2491 pp_string (pp, " , ");
2492 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2493 pp_string (pp, " , ");
2494 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2495 pp_string (pp, " > ");
2496 break;
2498 case VEC_PERM_EXPR:
2499 pp_string (pp, " VEC_PERM_EXPR < ");
2500 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2501 pp_string (pp, " , ");
2502 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2503 pp_string (pp, " , ");
2504 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2505 pp_string (pp, " > ");
2506 break;
2508 case DOT_PROD_EXPR:
2509 pp_string (pp, " DOT_PROD_EXPR < ");
2510 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2511 pp_string (pp, ", ");
2512 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2513 pp_string (pp, ", ");
2514 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2515 pp_string (pp, " > ");
2516 break;
2518 case WIDEN_MULT_PLUS_EXPR:
2519 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2520 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2521 pp_string (pp, ", ");
2522 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2523 pp_string (pp, ", ");
2524 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2525 pp_string (pp, " > ");
2526 break;
2528 case WIDEN_MULT_MINUS_EXPR:
2529 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2530 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2531 pp_string (pp, ", ");
2532 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2533 pp_string (pp, ", ");
2534 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2535 pp_string (pp, " > ");
2536 break;
2538 case FMA_EXPR:
2539 pp_string (pp, " FMA_EXPR < ");
2540 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2541 pp_string (pp, ", ");
2542 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2543 pp_string (pp, ", ");
2544 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2545 pp_string (pp, " > ");
2546 break;
2548 case OACC_PARALLEL:
2549 pp_string (pp, "#pragma acc parallel");
2550 dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags);
2551 goto dump_omp_body;
2553 case OACC_KERNELS:
2554 pp_string (pp, "#pragma acc kernels");
2555 dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags);
2556 goto dump_omp_body;
2558 case OACC_DATA:
2559 pp_string (pp, "#pragma acc data");
2560 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2561 goto dump_omp_body;
2563 case OACC_HOST_DATA:
2564 pp_string (pp, "#pragma acc host_data");
2565 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2566 goto dump_omp_body;
2568 case OACC_DECLARE:
2569 pp_string (pp, "#pragma acc declare");
2570 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2571 break;
2573 case OACC_UPDATE:
2574 pp_string (pp, "#pragma acc update");
2575 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2576 break;
2578 case OACC_ENTER_DATA:
2579 pp_string (pp, "#pragma acc enter data");
2580 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2581 break;
2583 case OACC_EXIT_DATA:
2584 pp_string (pp, "#pragma acc exit data");
2585 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2586 break;
2588 case OACC_CACHE:
2589 pp_string (pp, "#pragma acc cache");
2590 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2591 break;
2593 case OMP_PARALLEL:
2594 pp_string (pp, "#pragma omp parallel");
2595 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2597 dump_omp_body:
2598 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2600 newline_and_indent (pp, spc + 2);
2601 pp_left_brace (pp);
2602 newline_and_indent (pp, spc + 4);
2603 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2604 newline_and_indent (pp, spc + 2);
2605 pp_right_brace (pp);
2607 is_expr = false;
2608 break;
2610 case OMP_TASK:
2611 pp_string (pp, "#pragma omp task");
2612 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2613 goto dump_omp_body;
2615 case OMP_FOR:
2616 pp_string (pp, "#pragma omp for");
2617 goto dump_omp_loop;
2619 case OMP_SIMD:
2620 pp_string (pp, "#pragma omp simd");
2621 goto dump_omp_loop;
2623 case CILK_SIMD:
2624 pp_string (pp, "#pragma simd");
2625 goto dump_omp_loop;
2627 case CILK_FOR:
2628 /* This label points one line after dumping the clauses.
2629 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2630 parameters are printed out. */
2631 goto dump_omp_loop_cilk_for;
2633 case OMP_DISTRIBUTE:
2634 pp_string (pp, "#pragma omp distribute");
2635 goto dump_omp_loop;
2637 case OACC_LOOP:
2638 pp_string (pp, "#pragma acc loop");
2639 goto dump_omp_loop;
2641 case OMP_TEAMS:
2642 pp_string (pp, "#pragma omp teams");
2643 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2644 goto dump_omp_body;
2646 case OMP_TARGET_DATA:
2647 pp_string (pp, "#pragma omp target data");
2648 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2649 goto dump_omp_body;
2651 case OMP_TARGET:
2652 pp_string (pp, "#pragma omp target");
2653 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2654 goto dump_omp_body;
2656 case OMP_TARGET_UPDATE:
2657 pp_string (pp, "#pragma omp target update");
2658 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2659 is_expr = false;
2660 break;
2662 dump_omp_loop:
2663 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2665 dump_omp_loop_cilk_for:
2666 if (!(flags & TDF_SLIM))
2668 int i;
2670 if (OMP_FOR_PRE_BODY (node))
2672 if (TREE_CODE (node) == CILK_FOR)
2673 pp_string (pp, " ");
2674 else
2675 newline_and_indent (pp, spc + 2);
2676 pp_left_brace (pp);
2677 spc += 4;
2678 newline_and_indent (pp, spc);
2679 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2680 spc, flags, false);
2682 if (OMP_FOR_INIT (node))
2684 spc -= 2;
2685 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2687 spc += 2;
2688 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2689 newline_and_indent (pp, spc);
2690 if (TREE_CODE (node) == CILK_FOR)
2691 pp_string (pp, "_Cilk_for (");
2692 else
2693 pp_string (pp, "for (");
2694 dump_generic_node (pp,
2695 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2696 spc, flags, false);
2697 pp_string (pp, "; ");
2698 dump_generic_node (pp,
2699 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2700 spc, flags, false);
2701 pp_string (pp, "; ");
2702 dump_generic_node (pp,
2703 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2704 spc, flags, false);
2705 pp_right_paren (pp);
2707 if (TREE_CODE (node) == CILK_FOR)
2708 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2710 if (OMP_FOR_BODY (node))
2712 newline_and_indent (pp, spc + 2);
2713 pp_left_brace (pp);
2714 newline_and_indent (pp, spc + 4);
2715 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2716 false);
2717 newline_and_indent (pp, spc + 2);
2718 pp_right_brace (pp);
2720 if (OMP_FOR_INIT (node))
2721 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2722 if (OMP_FOR_PRE_BODY (node))
2724 spc -= 4;
2725 newline_and_indent (pp, spc + 2);
2726 pp_right_brace (pp);
2729 is_expr = false;
2730 break;
2732 case OMP_SECTIONS:
2733 pp_string (pp, "#pragma omp sections");
2734 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2735 goto dump_omp_body;
2737 case OMP_SECTION:
2738 pp_string (pp, "#pragma omp section");
2739 goto dump_omp_body;
2741 case OMP_MASTER:
2742 pp_string (pp, "#pragma omp master");
2743 goto dump_omp_body;
2745 case OMP_TASKGROUP:
2746 pp_string (pp, "#pragma omp taskgroup");
2747 goto dump_omp_body;
2749 case OMP_ORDERED:
2750 pp_string (pp, "#pragma omp ordered");
2751 goto dump_omp_body;
2753 case OMP_CRITICAL:
2754 pp_string (pp, "#pragma omp critical");
2755 if (OMP_CRITICAL_NAME (node))
2757 pp_space (pp);
2758 pp_left_paren (pp);
2759 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2760 flags, false);
2761 pp_right_paren (pp);
2763 goto dump_omp_body;
2765 case OMP_ATOMIC:
2766 pp_string (pp, "#pragma omp atomic");
2767 if (OMP_ATOMIC_SEQ_CST (node))
2768 pp_string (pp, " seq_cst");
2769 newline_and_indent (pp, spc + 2);
2770 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2771 pp_space (pp);
2772 pp_equal (pp);
2773 pp_space (pp);
2774 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2775 break;
2777 case OMP_ATOMIC_READ:
2778 pp_string (pp, "#pragma omp atomic read");
2779 if (OMP_ATOMIC_SEQ_CST (node))
2780 pp_string (pp, " seq_cst");
2781 newline_and_indent (pp, spc + 2);
2782 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2783 pp_space (pp);
2784 break;
2786 case OMP_ATOMIC_CAPTURE_OLD:
2787 case OMP_ATOMIC_CAPTURE_NEW:
2788 pp_string (pp, "#pragma omp atomic capture");
2789 if (OMP_ATOMIC_SEQ_CST (node))
2790 pp_string (pp, " seq_cst");
2791 newline_and_indent (pp, spc + 2);
2792 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2793 pp_space (pp);
2794 pp_equal (pp);
2795 pp_space (pp);
2796 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2797 break;
2799 case OMP_SINGLE:
2800 pp_string (pp, "#pragma omp single");
2801 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2802 goto dump_omp_body;
2804 case OMP_CLAUSE:
2805 dump_omp_clause (pp, node, spc, flags);
2806 is_expr = false;
2807 break;
2809 case TRANSACTION_EXPR:
2810 if (TRANSACTION_EXPR_OUTER (node))
2811 pp_string (pp, "__transaction_atomic [[outer]]");
2812 else if (TRANSACTION_EXPR_RELAXED (node))
2813 pp_string (pp, "__transaction_relaxed");
2814 else
2815 pp_string (pp, "__transaction_atomic");
2816 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2818 newline_and_indent (pp, spc);
2819 pp_left_brace (pp);
2820 newline_and_indent (pp, spc + 2);
2821 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
2822 spc + 2, flags, false);
2823 newline_and_indent (pp, spc);
2824 pp_right_brace (pp);
2826 is_expr = false;
2827 break;
2829 case REDUC_MAX_EXPR:
2830 pp_string (pp, " REDUC_MAX_EXPR < ");
2831 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2832 pp_string (pp, " > ");
2833 break;
2835 case REDUC_MIN_EXPR:
2836 pp_string (pp, " REDUC_MIN_EXPR < ");
2837 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2838 pp_string (pp, " > ");
2839 break;
2841 case REDUC_PLUS_EXPR:
2842 pp_string (pp, " REDUC_PLUS_EXPR < ");
2843 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2844 pp_string (pp, " > ");
2845 break;
2847 case VEC_WIDEN_MULT_HI_EXPR:
2848 case VEC_WIDEN_MULT_LO_EXPR:
2849 case VEC_WIDEN_MULT_EVEN_EXPR:
2850 case VEC_WIDEN_MULT_ODD_EXPR:
2851 case VEC_WIDEN_LSHIFT_HI_EXPR:
2852 case VEC_WIDEN_LSHIFT_LO_EXPR:
2853 pp_space (pp);
2854 for (str = get_tree_code_name (code); *str; str++)
2855 pp_character (pp, TOUPPER (*str));
2856 pp_string (pp, " < ");
2857 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2858 pp_string (pp, ", ");
2859 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2860 pp_string (pp, " > ");
2861 break;
2863 case VEC_UNPACK_HI_EXPR:
2864 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
2865 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2866 pp_string (pp, " > ");
2867 break;
2869 case VEC_UNPACK_LO_EXPR:
2870 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
2871 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2872 pp_string (pp, " > ");
2873 break;
2875 case VEC_UNPACK_FLOAT_HI_EXPR:
2876 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2877 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2878 pp_string (pp, " > ");
2879 break;
2881 case VEC_UNPACK_FLOAT_LO_EXPR:
2882 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2883 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2884 pp_string (pp, " > ");
2885 break;
2887 case VEC_PACK_TRUNC_EXPR:
2888 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
2889 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2890 pp_string (pp, ", ");
2891 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2892 pp_string (pp, " > ");
2893 break;
2895 case VEC_PACK_SAT_EXPR:
2896 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
2897 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2898 pp_string (pp, ", ");
2899 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2900 pp_string (pp, " > ");
2901 break;
2903 case VEC_PACK_FIX_TRUNC_EXPR:
2904 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
2905 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2906 pp_string (pp, ", ");
2907 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2908 pp_string (pp, " > ");
2909 break;
2911 case BLOCK:
2912 dump_block_node (pp, node, spc, flags);
2913 break;
2915 case CILK_SPAWN_STMT:
2916 pp_string (pp, "_Cilk_spawn ");
2917 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2918 break;
2920 case CILK_SYNC_STMT:
2921 pp_string (pp, "_Cilk_sync");
2922 break;
2924 default:
2925 NIY;
2928 if (is_stmt && is_expr)
2929 pp_semicolon (pp);
2931 return spc;
2934 /* Print the declaration of a variable. */
2936 void
2937 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
2939 INDENT (spc);
2941 if (TREE_CODE(t) == NAMELIST_DECL)
2943 pp_string(pp, "namelist ");
2944 dump_decl_name (pp, t, flags);
2945 pp_semicolon (pp);
2946 return;
2949 if (TREE_CODE (t) == TYPE_DECL)
2950 pp_string (pp, "typedef ");
2952 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2953 pp_string (pp, "register ");
2955 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2956 pp_string (pp, "extern ");
2957 else if (TREE_STATIC (t))
2958 pp_string (pp, "static ");
2960 /* Print the type and name. */
2961 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2963 tree tmp;
2965 /* Print array's type. */
2966 tmp = TREE_TYPE (t);
2967 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2968 tmp = TREE_TYPE (tmp);
2969 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
2971 /* Print variable's name. */
2972 pp_space (pp);
2973 dump_generic_node (pp, t, spc, flags, false);
2975 /* Print the dimensions. */
2976 tmp = TREE_TYPE (t);
2977 while (TREE_CODE (tmp) == ARRAY_TYPE)
2979 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2980 tmp = TREE_TYPE (tmp);
2983 else if (TREE_CODE (t) == FUNCTION_DECL)
2985 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2986 pp_space (pp);
2987 dump_decl_name (pp, t, flags);
2988 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
2990 else
2992 /* Print type declaration. */
2993 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
2995 /* Print variable's name. */
2996 pp_space (pp);
2997 dump_generic_node (pp, t, spc, flags, false);
3000 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3002 pp_string (pp, " __asm__ ");
3003 pp_left_paren (pp);
3004 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3005 pp_right_paren (pp);
3008 /* The initial value of a function serves to determine whether the function
3009 is declared or defined. So the following does not apply to function
3010 nodes. */
3011 if (TREE_CODE (t) != FUNCTION_DECL)
3013 /* Print the initial value. */
3014 if (DECL_INITIAL (t))
3016 pp_space (pp);
3017 pp_equal (pp);
3018 pp_space (pp);
3019 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3023 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3025 pp_string (pp, " [value-expr: ");
3026 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3027 pp_right_bracket (pp);
3030 pp_semicolon (pp);
3034 /* Prints a structure: name, fields, and methods.
3035 FIXME: Still incomplete. */
3037 static void
3038 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3040 /* Print the name of the structure. */
3041 if (TYPE_NAME (node))
3043 INDENT (spc);
3044 if (TREE_CODE (node) == RECORD_TYPE)
3045 pp_string (pp, "struct ");
3046 else if ((TREE_CODE (node) == UNION_TYPE
3047 || TREE_CODE (node) == QUAL_UNION_TYPE))
3048 pp_string (pp, "union ");
3050 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3053 /* Print the contents of the structure. */
3054 pp_newline (pp);
3055 INDENT (spc);
3056 pp_left_brace (pp);
3057 pp_newline (pp);
3059 /* Print the fields of the structure. */
3061 tree tmp;
3062 tmp = TYPE_FIELDS (node);
3063 while (tmp)
3065 /* Avoid to print recursively the structure. */
3066 /* FIXME : Not implemented correctly...,
3067 what about the case when we have a cycle in the contain graph? ...
3068 Maybe this could be solved by looking at the scope in which the
3069 structure was declared. */
3070 if (TREE_TYPE (tmp) != node
3071 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3072 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3074 print_declaration (pp, tmp, spc+2, flags);
3075 pp_newline (pp);
3077 tmp = DECL_CHAIN (tmp);
3080 INDENT (spc);
3081 pp_right_brace (pp);
3084 /* Return the priority of the operator CODE.
3086 From lowest to highest precedence with either left-to-right (L-R)
3087 or right-to-left (R-L) associativity]:
3089 1 [L-R] ,
3090 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3091 3 [R-L] ?:
3092 4 [L-R] ||
3093 5 [L-R] &&
3094 6 [L-R] |
3095 7 [L-R] ^
3096 8 [L-R] &
3097 9 [L-R] == !=
3098 10 [L-R] < <= > >=
3099 11 [L-R] << >>
3100 12 [L-R] + -
3101 13 [L-R] * / %
3102 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3103 15 [L-R] fn() [] -> .
3105 unary +, - and * have higher precedence than the corresponding binary
3106 operators. */
3109 op_code_prio (enum tree_code code)
3111 switch (code)
3113 case TREE_LIST:
3114 case COMPOUND_EXPR:
3115 case BIND_EXPR:
3116 return 1;
3118 case MODIFY_EXPR:
3119 case INIT_EXPR:
3120 return 2;
3122 case COND_EXPR:
3123 return 3;
3125 case TRUTH_OR_EXPR:
3126 case TRUTH_ORIF_EXPR:
3127 return 4;
3129 case TRUTH_AND_EXPR:
3130 case TRUTH_ANDIF_EXPR:
3131 return 5;
3133 case BIT_IOR_EXPR:
3134 return 6;
3136 case BIT_XOR_EXPR:
3137 case TRUTH_XOR_EXPR:
3138 return 7;
3140 case BIT_AND_EXPR:
3141 return 8;
3143 case EQ_EXPR:
3144 case NE_EXPR:
3145 return 9;
3147 case UNLT_EXPR:
3148 case UNLE_EXPR:
3149 case UNGT_EXPR:
3150 case UNGE_EXPR:
3151 case UNEQ_EXPR:
3152 case LTGT_EXPR:
3153 case ORDERED_EXPR:
3154 case UNORDERED_EXPR:
3155 case LT_EXPR:
3156 case LE_EXPR:
3157 case GT_EXPR:
3158 case GE_EXPR:
3159 return 10;
3161 case LSHIFT_EXPR:
3162 case RSHIFT_EXPR:
3163 case LROTATE_EXPR:
3164 case RROTATE_EXPR:
3165 case VEC_WIDEN_LSHIFT_HI_EXPR:
3166 case VEC_WIDEN_LSHIFT_LO_EXPR:
3167 case WIDEN_LSHIFT_EXPR:
3168 return 11;
3170 case WIDEN_SUM_EXPR:
3171 case PLUS_EXPR:
3172 case POINTER_PLUS_EXPR:
3173 case MINUS_EXPR:
3174 return 12;
3176 case VEC_WIDEN_MULT_HI_EXPR:
3177 case VEC_WIDEN_MULT_LO_EXPR:
3178 case WIDEN_MULT_EXPR:
3179 case DOT_PROD_EXPR:
3180 case WIDEN_MULT_PLUS_EXPR:
3181 case WIDEN_MULT_MINUS_EXPR:
3182 case MULT_EXPR:
3183 case MULT_HIGHPART_EXPR:
3184 case TRUNC_DIV_EXPR:
3185 case CEIL_DIV_EXPR:
3186 case FLOOR_DIV_EXPR:
3187 case ROUND_DIV_EXPR:
3188 case RDIV_EXPR:
3189 case EXACT_DIV_EXPR:
3190 case TRUNC_MOD_EXPR:
3191 case CEIL_MOD_EXPR:
3192 case FLOOR_MOD_EXPR:
3193 case ROUND_MOD_EXPR:
3194 case FMA_EXPR:
3195 return 13;
3197 case TRUTH_NOT_EXPR:
3198 case BIT_NOT_EXPR:
3199 case POSTINCREMENT_EXPR:
3200 case POSTDECREMENT_EXPR:
3201 case PREINCREMENT_EXPR:
3202 case PREDECREMENT_EXPR:
3203 case NEGATE_EXPR:
3204 case INDIRECT_REF:
3205 case ADDR_EXPR:
3206 case FLOAT_EXPR:
3207 CASE_CONVERT:
3208 case FIX_TRUNC_EXPR:
3209 case TARGET_EXPR:
3210 return 14;
3212 case CALL_EXPR:
3213 case ARRAY_REF:
3214 case ARRAY_RANGE_REF:
3215 case COMPONENT_REF:
3216 return 15;
3218 /* Special expressions. */
3219 case MIN_EXPR:
3220 case MAX_EXPR:
3221 case ABS_EXPR:
3222 case REALPART_EXPR:
3223 case IMAGPART_EXPR:
3224 case REDUC_MAX_EXPR:
3225 case REDUC_MIN_EXPR:
3226 case REDUC_PLUS_EXPR:
3227 case VEC_UNPACK_HI_EXPR:
3228 case VEC_UNPACK_LO_EXPR:
3229 case VEC_UNPACK_FLOAT_HI_EXPR:
3230 case VEC_UNPACK_FLOAT_LO_EXPR:
3231 case VEC_PACK_TRUNC_EXPR:
3232 case VEC_PACK_SAT_EXPR:
3233 return 16;
3235 default:
3236 /* Return an arbitrarily high precedence to avoid surrounding single
3237 VAR_DECLs in ()s. */
3238 return 9999;
3242 /* Return the priority of the operator OP. */
3245 op_prio (const_tree op)
3247 enum tree_code code;
3249 if (op == NULL)
3250 return 9999;
3252 code = TREE_CODE (op);
3253 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3254 return op_prio (TREE_OPERAND (op, 0));
3256 return op_code_prio (code);
3259 /* Return the symbol associated with operator CODE. */
3261 const char *
3262 op_symbol_code (enum tree_code code)
3264 switch (code)
3266 case MODIFY_EXPR:
3267 return "=";
3269 case TRUTH_OR_EXPR:
3270 case TRUTH_ORIF_EXPR:
3271 return "||";
3273 case TRUTH_AND_EXPR:
3274 case TRUTH_ANDIF_EXPR:
3275 return "&&";
3277 case BIT_IOR_EXPR:
3278 return "|";
3280 case TRUTH_XOR_EXPR:
3281 case BIT_XOR_EXPR:
3282 return "^";
3284 case ADDR_EXPR:
3285 case BIT_AND_EXPR:
3286 return "&";
3288 case ORDERED_EXPR:
3289 return "ord";
3290 case UNORDERED_EXPR:
3291 return "unord";
3293 case EQ_EXPR:
3294 return "==";
3295 case UNEQ_EXPR:
3296 return "u==";
3298 case NE_EXPR:
3299 return "!=";
3301 case LT_EXPR:
3302 return "<";
3303 case UNLT_EXPR:
3304 return "u<";
3306 case LE_EXPR:
3307 return "<=";
3308 case UNLE_EXPR:
3309 return "u<=";
3311 case GT_EXPR:
3312 return ">";
3313 case UNGT_EXPR:
3314 return "u>";
3316 case GE_EXPR:
3317 return ">=";
3318 case UNGE_EXPR:
3319 return "u>=";
3321 case LTGT_EXPR:
3322 return "<>";
3324 case LSHIFT_EXPR:
3325 return "<<";
3327 case RSHIFT_EXPR:
3328 return ">>";
3330 case LROTATE_EXPR:
3331 return "r<<";
3333 case RROTATE_EXPR:
3334 return "r>>";
3336 case WIDEN_LSHIFT_EXPR:
3337 return "w<<";
3339 case POINTER_PLUS_EXPR:
3340 return "+";
3342 case PLUS_EXPR:
3343 return "+";
3345 case REDUC_PLUS_EXPR:
3346 return "r+";
3348 case WIDEN_SUM_EXPR:
3349 return "w+";
3351 case WIDEN_MULT_EXPR:
3352 return "w*";
3354 case MULT_HIGHPART_EXPR:
3355 return "h*";
3357 case NEGATE_EXPR:
3358 case MINUS_EXPR:
3359 return "-";
3361 case BIT_NOT_EXPR:
3362 return "~";
3364 case TRUTH_NOT_EXPR:
3365 return "!";
3367 case MULT_EXPR:
3368 case INDIRECT_REF:
3369 return "*";
3371 case TRUNC_DIV_EXPR:
3372 case RDIV_EXPR:
3373 return "/";
3375 case CEIL_DIV_EXPR:
3376 return "/[cl]";
3378 case FLOOR_DIV_EXPR:
3379 return "/[fl]";
3381 case ROUND_DIV_EXPR:
3382 return "/[rd]";
3384 case EXACT_DIV_EXPR:
3385 return "/[ex]";
3387 case TRUNC_MOD_EXPR:
3388 return "%";
3390 case CEIL_MOD_EXPR:
3391 return "%[cl]";
3393 case FLOOR_MOD_EXPR:
3394 return "%[fl]";
3396 case ROUND_MOD_EXPR:
3397 return "%[rd]";
3399 case PREDECREMENT_EXPR:
3400 return " --";
3402 case PREINCREMENT_EXPR:
3403 return " ++";
3405 case POSTDECREMENT_EXPR:
3406 return "-- ";
3408 case POSTINCREMENT_EXPR:
3409 return "++ ";
3411 case MAX_EXPR:
3412 return "max";
3414 case MIN_EXPR:
3415 return "min";
3417 default:
3418 return "<<< ??? >>>";
3422 /* Return the symbol associated with operator OP. */
3424 static const char *
3425 op_symbol (const_tree op)
3427 return op_symbol_code (TREE_CODE (op));
3430 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3431 the gimple_call_fn of a GIMPLE_CALL. */
3433 void
3434 print_call_name (pretty_printer *pp, tree node, int flags)
3436 tree op0 = node;
3438 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3439 op0 = TREE_OPERAND (op0, 0);
3441 again:
3442 switch (TREE_CODE (op0))
3444 case VAR_DECL:
3445 case PARM_DECL:
3446 case FUNCTION_DECL:
3447 dump_function_name (pp, op0, flags);
3448 break;
3450 case ADDR_EXPR:
3451 case INDIRECT_REF:
3452 CASE_CONVERT:
3453 op0 = TREE_OPERAND (op0, 0);
3454 goto again;
3456 case COND_EXPR:
3457 pp_left_paren (pp);
3458 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3459 pp_string (pp, ") ? ");
3460 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3461 pp_string (pp, " : ");
3462 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3463 break;
3465 case ARRAY_REF:
3466 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3467 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3468 else
3469 dump_generic_node (pp, op0, 0, flags, false);
3470 break;
3472 case MEM_REF:
3473 if (integer_zerop (TREE_OPERAND (op0, 1)))
3475 op0 = TREE_OPERAND (op0, 0);
3476 goto again;
3478 /* Fallthru. */
3479 case COMPONENT_REF:
3480 case SSA_NAME:
3481 case OBJ_TYPE_REF:
3482 dump_generic_node (pp, op0, 0, flags, false);
3483 break;
3485 default:
3486 NIY;
3490 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3492 static void
3493 pretty_print_string (pretty_printer *pp, const char *str)
3495 if (str == NULL)
3496 return;
3498 while (*str)
3500 switch (str[0])
3502 case '\b':
3503 pp_string (pp, "\\b");
3504 break;
3506 case '\f':
3507 pp_string (pp, "\\f");
3508 break;
3510 case '\n':
3511 pp_string (pp, "\\n");
3512 break;
3514 case '\r':
3515 pp_string (pp, "\\r");
3516 break;
3518 case '\t':
3519 pp_string (pp, "\\t");
3520 break;
3522 case '\v':
3523 pp_string (pp, "\\v");
3524 break;
3526 case '\\':
3527 pp_string (pp, "\\\\");
3528 break;
3530 case '\"':
3531 pp_string (pp, "\\\"");
3532 break;
3534 case '\'':
3535 pp_string (pp, "\\'");
3536 break;
3538 /* No need to handle \0; the loop terminates on \0. */
3540 case '\1':
3541 pp_string (pp, "\\1");
3542 break;
3544 case '\2':
3545 pp_string (pp, "\\2");
3546 break;
3548 case '\3':
3549 pp_string (pp, "\\3");
3550 break;
3552 case '\4':
3553 pp_string (pp, "\\4");
3554 break;
3556 case '\5':
3557 pp_string (pp, "\\5");
3558 break;
3560 case '\6':
3561 pp_string (pp, "\\6");
3562 break;
3564 case '\7':
3565 pp_string (pp, "\\7");
3566 break;
3568 default:
3569 pp_character (pp, str[0]);
3570 break;
3572 str++;
3576 static void
3577 maybe_init_pretty_print (FILE *file)
3579 if (!tree_pp)
3581 tree_pp = new pretty_printer ();
3582 pp_needs_newline (tree_pp) = true;
3583 pp_translate_identifiers (tree_pp) = false;
3586 tree_pp->buffer->stream = file;
3589 static void
3590 newline_and_indent (pretty_printer *pp, int spc)
3592 pp_newline (pp);
3593 INDENT (spc);
3596 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3597 it can also be used in front ends.
3598 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3601 void
3602 percent_K_format (text_info *text)
3604 tree t = va_arg (*text->args_ptr, tree), block;
3605 text->set_location (0, EXPR_LOCATION (t));
3606 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3607 block = TREE_BLOCK (t);
3608 *pp_ti_abstract_origin (text) = NULL;
3610 if (in_lto_p)
3612 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3613 representing the outermost block of an inlined function.
3614 So walk the BLOCK tree until we hit such a scope. */
3615 while (block
3616 && TREE_CODE (block) == BLOCK)
3618 if (inlined_function_outer_scope_p (block))
3620 *pp_ti_abstract_origin (text) = block;
3621 break;
3623 block = BLOCK_SUPERCONTEXT (block);
3625 return;
3628 while (block
3629 && TREE_CODE (block) == BLOCK
3630 && BLOCK_ABSTRACT_ORIGIN (block))
3632 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3634 while (TREE_CODE (ao) == BLOCK
3635 && BLOCK_ABSTRACT_ORIGIN (ao)
3636 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3637 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3639 if (TREE_CODE (ao) == FUNCTION_DECL)
3641 *pp_ti_abstract_origin (text) = block;
3642 break;
3644 block = BLOCK_SUPERCONTEXT (block);
3648 /* Print the identifier ID to PRETTY-PRINTER. */
3650 void
3651 pp_tree_identifier (pretty_printer *pp, tree id)
3653 if (pp_translate_identifiers (pp))
3655 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3656 pp_append_text (pp, text, text + strlen (text));
3658 else
3659 pp_append_text (pp, IDENTIFIER_POINTER (id),
3660 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3663 /* A helper function that is used to dump function information before the
3664 function dump. */
3666 void
3667 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3669 const char *dname, *aname;
3670 struct cgraph_node *node = cgraph_node::get (fdecl);
3671 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3673 dname = lang_hooks.decl_printable_name (fdecl, 2);
3675 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3676 aname = (IDENTIFIER_POINTER
3677 (DECL_ASSEMBLER_NAME (fdecl)));
3678 else
3679 aname = "<unset-asm-name>";
3681 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3682 dname, aname, fun->funcdef_no);
3683 if (!(flags & TDF_NOUID))
3684 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3685 if (node)
3687 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3688 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3689 node->frequency == NODE_FREQUENCY_HOT
3690 ? " (hot)"
3691 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3692 ? " (unlikely executed)"
3693 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3694 ? " (executed once)"
3695 : "");
3697 else
3698 fprintf (dump_file, ")\n\n");
3701 /* Dump double_int D to pretty_printer PP. UNS is true
3702 if D is unsigned and false otherwise. */
3703 void
3704 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3706 if (d.fits_shwi ())
3707 pp_wide_integer (pp, d.low);
3708 else if (d.fits_uhwi ())
3709 pp_unsigned_wide_integer (pp, d.low);
3710 else
3712 unsigned HOST_WIDE_INT low = d.low;
3713 HOST_WIDE_INT high = d.high;
3714 if (!uns && d.is_negative ())
3716 pp_minus (pp);
3717 high = ~high + !low;
3718 low = -low;
3720 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3721 systems? */
3722 sprintf (pp_buffer (pp)->digit_buffer,
3723 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3724 (unsigned HOST_WIDE_INT) high, low);
3725 pp_string (pp, pp_buffer (pp)->digit_buffer);