gcc/ada/
[official-gcc.git] / gcc / tree-pretty-print.c
blob13587e6b04a6a6b84a6094efe568da4613475660
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "alias.h"
26 #include "symtab.h"
27 #include "tree.h"
28 #include "stor-layout.h"
29 #include "hard-reg-set.h"
30 #include "function.h"
31 #include "rtl.h"
32 #include "flags.h"
33 #include "insn-config.h"
34 #include "expmed.h"
35 #include "dojump.h"
36 #include "explow.h"
37 #include "calls.h"
38 #include "emit-rtl.h"
39 #include "varasm.h"
40 #include "stmt.h"
41 #include "expr.h"
42 #include "tree-pretty-print.h"
43 #include "gimple-expr.h"
44 #include "predict.h"
45 #include "plugin-api.h"
46 #include "ipa-ref.h"
47 #include "cgraph.h"
48 #include "langhooks.h"
49 #include "tree-iterator.h"
50 #include "tree-chrec.h"
51 #include "dumpfile.h"
52 #include "value-prof.h"
53 #include "wide-int-print.h"
54 #include "internal-fn.h"
55 #include "gomp-constants.h"
57 /* Local functions, macros and variables. */
58 static const char *op_symbol (const_tree);
59 static void pretty_print_string (pretty_printer *, const char*);
60 static void newline_and_indent (pretty_printer *, int);
61 static void maybe_init_pretty_print (FILE *);
62 static void print_struct_decl (pretty_printer *, const_tree, int, int);
63 static void do_niy (pretty_printer *, const_tree);
65 #define INDENT(SPACE) do { \
66 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
68 #define NIY do_niy (pp, node)
70 static pretty_printer *tree_pp;
72 /* Try to print something for an unknown tree code. */
74 static void
75 do_niy (pretty_printer *pp, const_tree node)
77 int i, len;
79 pp_string (pp, "<<< Unknown tree: ");
80 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
82 if (EXPR_P (node))
84 len = TREE_OPERAND_LENGTH (node);
85 for (i = 0; i < len; ++i)
87 newline_and_indent (pp, 2);
88 dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false);
92 pp_string (pp, " >>>");
95 /* Debugging function to print out a generic expression. */
97 DEBUG_FUNCTION void
98 debug_generic_expr (tree t)
100 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
101 fprintf (stderr, "\n");
104 /* Debugging function to print out a generic statement. */
106 DEBUG_FUNCTION void
107 debug_generic_stmt (tree t)
109 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
110 fprintf (stderr, "\n");
113 /* Debugging function to print out a chain of trees . */
115 DEBUG_FUNCTION void
116 debug_tree_chain (tree t)
118 hash_set<tree> seen;
120 while (t)
122 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
123 fprintf (stderr, " ");
124 t = TREE_CHAIN (t);
125 if (seen.add (t))
127 fprintf (stderr, "... [cycled back to ");
128 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
129 fprintf (stderr, "]");
130 break;
133 fprintf (stderr, "\n");
136 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
137 void
138 print_generic_decl (FILE *file, tree decl, int flags)
140 maybe_init_pretty_print (file);
141 print_declaration (tree_pp, decl, 2, flags);
142 pp_write_text_to_stream (tree_pp);
145 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
146 to show in the dump. See TDF_* in dumpfile.h. */
148 void
149 print_generic_stmt (FILE *file, tree t, int flags)
151 maybe_init_pretty_print (file);
152 dump_generic_node (tree_pp, t, 0, flags, true);
153 pp_newline_and_flush (tree_pp);
156 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
157 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
158 INDENT spaces. */
160 void
161 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
163 int i;
165 maybe_init_pretty_print (file);
167 for (i = 0; i < indent; i++)
168 pp_space (tree_pp);
169 dump_generic_node (tree_pp, t, indent, flags, true);
170 pp_newline_and_flush (tree_pp);
173 /* Print a single expression T on file FILE. FLAGS specifies details to show
174 in the dump. See TDF_* in dumpfile.h. */
176 void
177 print_generic_expr (FILE *file, tree t, int flags)
179 maybe_init_pretty_print (file);
180 dump_generic_node (tree_pp, t, 0, flags, false);
181 pp_flush (tree_pp);
184 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
185 in FLAGS. */
187 static void
188 dump_decl_name (pretty_printer *pp, tree node, int flags)
190 if (DECL_NAME (node))
192 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
193 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
194 else
195 pp_tree_identifier (pp, DECL_NAME (node));
197 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
199 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
200 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
201 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
203 if (flags & TDF_NOUID)
204 pp_string (pp, "D#xxxx");
205 else
206 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
208 else
210 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
211 if (flags & TDF_NOUID)
212 pp_printf (pp, "%c.xxxx", c);
213 else
214 pp_printf (pp, "%c.%u", c, DECL_UID (node));
217 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
219 if (flags & TDF_NOUID)
220 pp_printf (pp, "ptD.xxxx");
221 else
222 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
226 /* Like the above, but used for pretty printing function calls. */
228 static void
229 dump_function_name (pretty_printer *pp, tree node, int flags)
231 if (CONVERT_EXPR_P (node))
232 node = TREE_OPERAND (node, 0);
233 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
234 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
235 else
236 dump_decl_name (pp, node, flags);
239 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
240 FLAGS are as in dump_generic_node. */
242 static void
243 dump_function_declaration (pretty_printer *pp, tree node,
244 int spc, int flags)
246 bool wrote_arg = false;
247 tree arg;
249 pp_space (pp);
250 pp_left_paren (pp);
252 /* Print the argument types. */
253 arg = TYPE_ARG_TYPES (node);
254 while (arg && arg != void_list_node && arg != error_mark_node)
256 if (wrote_arg)
258 pp_comma (pp);
259 pp_space (pp);
261 wrote_arg = true;
262 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
263 arg = TREE_CHAIN (arg);
266 /* Drop the trailing void_type_node if we had any previous argument. */
267 if (arg == void_list_node && !wrote_arg)
268 pp_string (pp, "void");
269 /* Properly dump vararg function types. */
270 else if (!arg && wrote_arg)
271 pp_string (pp, ", ...");
272 /* Avoid printing any arg for unprototyped functions. */
274 pp_right_paren (pp);
277 /* Dump the domain associated with an array. */
279 static void
280 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
282 pp_left_bracket (pp);
283 if (domain)
285 tree min = TYPE_MIN_VALUE (domain);
286 tree max = TYPE_MAX_VALUE (domain);
288 if (min && max
289 && integer_zerop (min)
290 && tree_fits_shwi_p (max))
291 pp_wide_integer (pp, tree_to_shwi (max) + 1);
292 else
294 if (min)
295 dump_generic_node (pp, min, spc, flags, false);
296 pp_colon (pp);
297 if (max)
298 dump_generic_node (pp, max, spc, flags, false);
301 else
302 pp_string (pp, "<unknown>");
303 pp_right_bracket (pp);
307 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
308 dump_generic_node. */
310 static void
311 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
313 const char *name;
315 switch (OMP_CLAUSE_CODE (clause))
317 case OMP_CLAUSE_PRIVATE:
318 name = "private";
319 goto print_remap;
320 case OMP_CLAUSE_SHARED:
321 name = "shared";
322 goto print_remap;
323 case OMP_CLAUSE_FIRSTPRIVATE:
324 name = "firstprivate";
325 goto print_remap;
326 case OMP_CLAUSE_LASTPRIVATE:
327 name = "lastprivate";
328 goto print_remap;
329 case OMP_CLAUSE_COPYIN:
330 name = "copyin";
331 goto print_remap;
332 case OMP_CLAUSE_COPYPRIVATE:
333 name = "copyprivate";
334 goto print_remap;
335 case OMP_CLAUSE_UNIFORM:
336 name = "uniform";
337 goto print_remap;
338 case OMP_CLAUSE__LOOPTEMP_:
339 name = "_looptemp_";
340 goto print_remap;
341 case OMP_CLAUSE_DEVICE_RESIDENT:
342 name = "device_resident";
343 goto print_remap;
344 case OMP_CLAUSE_USE_DEVICE:
345 name = "use_device";
346 goto print_remap;
347 print_remap:
348 pp_string (pp, name);
349 pp_left_paren (pp);
350 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
351 spc, flags, false);
352 pp_right_paren (pp);
353 break;
355 case OMP_CLAUSE_REDUCTION:
356 pp_string (pp, "reduction(");
357 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
359 pp_string (pp,
360 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
361 pp_colon (pp);
363 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
364 spc, flags, false);
365 pp_right_paren (pp);
366 break;
368 case OMP_CLAUSE_IF:
369 pp_string (pp, "if(");
370 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
371 spc, flags, false);
372 pp_right_paren (pp);
373 break;
375 case OMP_CLAUSE_NUM_THREADS:
376 pp_string (pp, "num_threads(");
377 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
378 spc, flags, false);
379 pp_right_paren (pp);
380 break;
382 case OMP_CLAUSE__CILK_FOR_COUNT_:
383 pp_string (pp, "_Cilk_for_count_(");
384 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
385 spc, flags, false);
386 pp_right_paren (pp);
387 break;
389 case OMP_CLAUSE_NOWAIT:
390 pp_string (pp, "nowait");
391 break;
392 case OMP_CLAUSE_ORDERED:
393 pp_string (pp, "ordered");
394 break;
396 case OMP_CLAUSE_DEFAULT:
397 pp_string (pp, "default(");
398 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
400 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
401 break;
402 case OMP_CLAUSE_DEFAULT_SHARED:
403 pp_string (pp, "shared");
404 break;
405 case OMP_CLAUSE_DEFAULT_NONE:
406 pp_string (pp, "none");
407 break;
408 case OMP_CLAUSE_DEFAULT_PRIVATE:
409 pp_string (pp, "private");
410 break;
411 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
412 pp_string (pp, "firstprivate");
413 break;
414 default:
415 gcc_unreachable ();
417 pp_right_paren (pp);
418 break;
420 case OMP_CLAUSE_SCHEDULE:
421 pp_string (pp, "schedule(");
422 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
424 case OMP_CLAUSE_SCHEDULE_STATIC:
425 pp_string (pp, "static");
426 break;
427 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
428 pp_string (pp, "dynamic");
429 break;
430 case OMP_CLAUSE_SCHEDULE_GUIDED:
431 pp_string (pp, "guided");
432 break;
433 case OMP_CLAUSE_SCHEDULE_RUNTIME:
434 pp_string (pp, "runtime");
435 break;
436 case OMP_CLAUSE_SCHEDULE_AUTO:
437 pp_string (pp, "auto");
438 break;
439 case OMP_CLAUSE_SCHEDULE_CILKFOR:
440 pp_string (pp, "cilk-for grain");
441 break;
442 default:
443 gcc_unreachable ();
445 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
447 pp_comma (pp);
448 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
449 spc, flags, false);
451 pp_right_paren (pp);
452 break;
454 case OMP_CLAUSE_UNTIED:
455 pp_string (pp, "untied");
456 break;
458 case OMP_CLAUSE_COLLAPSE:
459 pp_string (pp, "collapse(");
460 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
461 spc, flags, false);
462 pp_right_paren (pp);
463 break;
465 case OMP_CLAUSE_FINAL:
466 pp_string (pp, "final(");
467 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
468 spc, flags, false);
469 pp_right_paren (pp);
470 break;
472 case OMP_CLAUSE_MERGEABLE:
473 pp_string (pp, "mergeable");
474 break;
476 case OMP_CLAUSE_LINEAR:
477 pp_string (pp, "linear(");
478 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
479 spc, flags, false);
480 pp_colon (pp);
481 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
482 spc, flags, false);
483 pp_right_paren (pp);
484 break;
486 case OMP_CLAUSE_ALIGNED:
487 pp_string (pp, "aligned(");
488 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
489 spc, flags, false);
490 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
492 pp_colon (pp);
493 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
494 spc, flags, false);
496 pp_right_paren (pp);
497 break;
499 case OMP_CLAUSE_DEPEND:
500 pp_string (pp, "depend(");
501 switch (OMP_CLAUSE_DEPEND_KIND (clause))
503 case OMP_CLAUSE_DEPEND_IN:
504 pp_string (pp, "in");
505 break;
506 case OMP_CLAUSE_DEPEND_OUT:
507 pp_string (pp, "out");
508 break;
509 case OMP_CLAUSE_DEPEND_INOUT:
510 pp_string (pp, "inout");
511 break;
512 default:
513 gcc_unreachable ();
515 pp_colon (pp);
516 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
517 spc, flags, false);
518 pp_right_paren (pp);
519 break;
521 case OMP_CLAUSE_MAP:
522 pp_string (pp, "map(");
523 switch (OMP_CLAUSE_MAP_KIND (clause))
525 case GOMP_MAP_ALLOC:
526 case GOMP_MAP_POINTER:
527 pp_string (pp, "alloc");
528 break;
529 case GOMP_MAP_TO:
530 case GOMP_MAP_TO_PSET:
531 pp_string (pp, "to");
532 break;
533 case GOMP_MAP_FROM:
534 pp_string (pp, "from");
535 break;
536 case GOMP_MAP_TOFROM:
537 pp_string (pp, "tofrom");
538 break;
539 case GOMP_MAP_FORCE_ALLOC:
540 pp_string (pp, "force_alloc");
541 break;
542 case GOMP_MAP_FORCE_TO:
543 pp_string (pp, "force_to");
544 break;
545 case GOMP_MAP_FORCE_FROM:
546 pp_string (pp, "force_from");
547 break;
548 case GOMP_MAP_FORCE_TOFROM:
549 pp_string (pp, "force_tofrom");
550 break;
551 case GOMP_MAP_FORCE_PRESENT:
552 pp_string (pp, "force_present");
553 break;
554 case GOMP_MAP_FORCE_DEALLOC:
555 pp_string (pp, "force_dealloc");
556 break;
557 case GOMP_MAP_FORCE_DEVICEPTR:
558 pp_string (pp, "force_deviceptr");
559 break;
560 default:
561 gcc_unreachable ();
563 pp_colon (pp);
564 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
565 spc, flags, false);
566 print_clause_size:
567 if (OMP_CLAUSE_SIZE (clause))
569 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
570 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER)
571 pp_string (pp, " [pointer assign, bias: ");
572 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
573 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET)
574 pp_string (pp, " [pointer set, len: ");
575 else
576 pp_string (pp, " [len: ");
577 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
578 spc, flags, false);
579 pp_right_bracket (pp);
581 pp_right_paren (pp);
582 break;
584 case OMP_CLAUSE_FROM:
585 pp_string (pp, "from(");
586 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
587 spc, flags, false);
588 goto print_clause_size;
590 case OMP_CLAUSE_TO:
591 pp_string (pp, "to(");
592 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
593 spc, flags, false);
594 goto print_clause_size;
596 case OMP_CLAUSE__CACHE_:
597 pp_string (pp, "(");
598 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
599 spc, flags, false);
600 goto print_clause_size;
602 case OMP_CLAUSE_NUM_TEAMS:
603 pp_string (pp, "num_teams(");
604 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
605 spc, flags, false);
606 pp_right_paren (pp);
607 break;
609 case OMP_CLAUSE_THREAD_LIMIT:
610 pp_string (pp, "thread_limit(");
611 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
612 spc, flags, false);
613 pp_right_paren (pp);
614 break;
616 case OMP_CLAUSE_DEVICE:
617 pp_string (pp, "device(");
618 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
619 spc, flags, false);
620 pp_right_paren (pp);
621 break;
623 case OMP_CLAUSE_DIST_SCHEDULE:
624 pp_string (pp, "dist_schedule(static");
625 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
627 pp_comma (pp);
628 dump_generic_node (pp,
629 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
630 spc, flags, false);
632 pp_right_paren (pp);
633 break;
635 case OMP_CLAUSE_PROC_BIND:
636 pp_string (pp, "proc_bind(");
637 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
639 case OMP_CLAUSE_PROC_BIND_MASTER:
640 pp_string (pp, "master");
641 break;
642 case OMP_CLAUSE_PROC_BIND_CLOSE:
643 pp_string (pp, "close");
644 break;
645 case OMP_CLAUSE_PROC_BIND_SPREAD:
646 pp_string (pp, "spread");
647 break;
648 default:
649 gcc_unreachable ();
651 pp_right_paren (pp);
652 break;
654 case OMP_CLAUSE_SAFELEN:
655 pp_string (pp, "safelen(");
656 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
657 spc, flags, false);
658 pp_right_paren (pp);
659 break;
661 case OMP_CLAUSE_SIMDLEN:
662 pp_string (pp, "simdlen(");
663 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
664 spc, flags, false);
665 pp_right_paren (pp);
666 break;
668 case OMP_CLAUSE__SIMDUID_:
669 pp_string (pp, "_simduid_(");
670 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
671 spc, flags, false);
672 pp_right_paren (pp);
673 break;
675 case OMP_CLAUSE_GANG:
676 pp_string (pp, "gang");
677 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
679 pp_string (pp, "(num: ");
680 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
681 spc, flags, false);
683 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
685 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
686 pp_left_paren (pp);
687 else
688 pp_space (pp);
689 pp_string (pp, "static:");
690 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
691 == integer_minus_one_node)
692 pp_character (pp, '*');
693 else
694 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
695 spc, flags, false);
697 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
698 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
699 pp_right_paren (pp);
700 break;
702 case OMP_CLAUSE_ASYNC:
703 pp_string (pp, "async");
704 if (OMP_CLAUSE_ASYNC_EXPR (clause))
706 pp_character(pp, '(');
707 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
708 spc, flags, false);
709 pp_character(pp, ')');
711 break;
713 case OMP_CLAUSE_AUTO:
714 case OMP_CLAUSE_SEQ:
715 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
716 break;
718 case OMP_CLAUSE_WAIT:
719 pp_string (pp, "wait(");
720 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
721 spc, flags, false);
722 pp_character(pp, ')');
723 break;
725 case OMP_CLAUSE_WORKER:
726 pp_string (pp, "worker");
727 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
729 pp_left_paren (pp);
730 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
731 spc, flags, false);
732 pp_right_paren (pp);
734 break;
736 case OMP_CLAUSE_VECTOR:
737 pp_string (pp, "vector");
738 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
740 pp_left_paren (pp);
741 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
742 spc, flags, false);
743 pp_right_paren (pp);
745 break;
747 case OMP_CLAUSE_NUM_GANGS:
748 pp_string (pp, "num_gangs(");
749 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
750 spc, flags, false);
751 pp_character (pp, ')');
752 break;
754 case OMP_CLAUSE_NUM_WORKERS:
755 pp_string (pp, "num_workers(");
756 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
757 spc, flags, false);
758 pp_character (pp, ')');
759 break;
761 case OMP_CLAUSE_VECTOR_LENGTH:
762 pp_string (pp, "vector_length(");
763 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
764 spc, flags, false);
765 pp_character (pp, ')');
766 break;
768 case OMP_CLAUSE_INBRANCH:
769 pp_string (pp, "inbranch");
770 break;
771 case OMP_CLAUSE_NOTINBRANCH:
772 pp_string (pp, "notinbranch");
773 break;
774 case OMP_CLAUSE_FOR:
775 pp_string (pp, "for");
776 break;
777 case OMP_CLAUSE_PARALLEL:
778 pp_string (pp, "parallel");
779 break;
780 case OMP_CLAUSE_SECTIONS:
781 pp_string (pp, "sections");
782 break;
783 case OMP_CLAUSE_TASKGROUP:
784 pp_string (pp, "taskgroup");
785 break;
786 case OMP_CLAUSE_INDEPENDENT:
787 pp_string (pp, "independent");
788 break;
790 default:
791 /* Should never happen. */
792 dump_generic_node (pp, clause, spc, flags, false);
793 break;
798 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
799 dump_generic_node. */
801 void
802 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
804 if (clause == NULL)
805 return;
807 pp_space (pp);
808 while (1)
810 dump_omp_clause (pp, clause, spc, flags);
811 clause = OMP_CLAUSE_CHAIN (clause);
812 if (clause == NULL)
813 return;
814 pp_space (pp);
819 /* Dump location LOC to PP. */
821 void
822 dump_location (pretty_printer *pp, location_t loc)
824 expanded_location xloc = expand_location (loc);
826 pp_left_bracket (pp);
827 if (xloc.file)
829 pp_string (pp, xloc.file);
830 pp_string (pp, ":");
832 pp_decimal_int (pp, xloc.line);
833 pp_colon (pp);
834 pp_decimal_int (pp, xloc.column);
835 pp_string (pp, "] ");
839 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
840 dump_generic_node. */
842 static void
843 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
845 tree t;
847 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
849 if (flags & TDF_ADDRESS)
850 pp_printf (pp, "[%p] ", (void *) block);
852 if (BLOCK_ABSTRACT (block))
853 pp_string (pp, "[abstract] ");
855 if (TREE_ASM_WRITTEN (block))
856 pp_string (pp, "[written] ");
858 if (flags & TDF_SLIM)
859 return;
861 if (BLOCK_SOURCE_LOCATION (block))
862 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
864 newline_and_indent (pp, spc + 2);
866 if (BLOCK_SUPERCONTEXT (block))
868 pp_string (pp, "SUPERCONTEXT: ");
869 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
870 flags | TDF_SLIM, false);
871 newline_and_indent (pp, spc + 2);
874 if (BLOCK_SUBBLOCKS (block))
876 pp_string (pp, "SUBBLOCKS: ");
877 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
879 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
880 pp_space (pp);
882 newline_and_indent (pp, spc + 2);
885 if (BLOCK_CHAIN (block))
887 pp_string (pp, "SIBLINGS: ");
888 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
890 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
891 pp_space (pp);
893 newline_and_indent (pp, spc + 2);
896 if (BLOCK_VARS (block))
898 pp_string (pp, "VARS: ");
899 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
901 dump_generic_node (pp, t, 0, flags, false);
902 pp_space (pp);
904 newline_and_indent (pp, spc + 2);
907 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
909 unsigned i;
910 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
912 pp_string (pp, "NONLOCALIZED_VARS: ");
913 FOR_EACH_VEC_ELT (*nlv, i, t)
915 dump_generic_node (pp, t, 0, flags, false);
916 pp_space (pp);
918 newline_and_indent (pp, spc + 2);
921 if (BLOCK_ABSTRACT_ORIGIN (block))
923 pp_string (pp, "ABSTRACT_ORIGIN: ");
924 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
925 flags | TDF_SLIM, false);
926 newline_and_indent (pp, spc + 2);
929 if (BLOCK_FRAGMENT_ORIGIN (block))
931 pp_string (pp, "FRAGMENT_ORIGIN: ");
932 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
933 flags | TDF_SLIM, false);
934 newline_and_indent (pp, spc + 2);
937 if (BLOCK_FRAGMENT_CHAIN (block))
939 pp_string (pp, "FRAGMENT_CHAIN: ");
940 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
942 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
943 pp_space (pp);
945 newline_and_indent (pp, spc + 2);
950 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
951 indent. FLAGS specifies details to show in the dump (see TDF_* in
952 dumpfile.h). If IS_STMT is true, the object printed is considered
953 to be a statement and it is terminated by ';' if appropriate. */
956 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
957 bool is_stmt)
959 tree type;
960 tree op0, op1;
961 const char *str;
962 bool is_expr;
963 enum tree_code code;
965 if (node == NULL_TREE)
966 return spc;
968 is_expr = EXPR_P (node);
970 if (is_stmt && (flags & TDF_STMTADDR))
971 pp_printf (pp, "<&%p> ", (void *)node);
973 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
974 dump_location (pp, EXPR_LOCATION (node));
976 code = TREE_CODE (node);
977 switch (code)
979 case ERROR_MARK:
980 pp_string (pp, "<<< error >>>");
981 break;
983 case IDENTIFIER_NODE:
984 pp_tree_identifier (pp, node);
985 break;
987 case TREE_LIST:
988 while (node && node != error_mark_node)
990 if (TREE_PURPOSE (node))
992 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
993 pp_space (pp);
995 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
996 node = TREE_CHAIN (node);
997 if (node && TREE_CODE (node) == TREE_LIST)
999 pp_comma (pp);
1000 pp_space (pp);
1003 break;
1005 case TREE_BINFO:
1006 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1007 break;
1009 case TREE_VEC:
1011 size_t i;
1012 if (TREE_VEC_LENGTH (node) > 0)
1014 size_t len = TREE_VEC_LENGTH (node);
1015 for (i = 0; i < len - 1; i++)
1017 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1018 false);
1019 pp_comma (pp);
1020 pp_space (pp);
1022 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1023 flags, false);
1026 break;
1028 case VOID_TYPE:
1029 case POINTER_BOUNDS_TYPE:
1030 case INTEGER_TYPE:
1031 case REAL_TYPE:
1032 case FIXED_POINT_TYPE:
1033 case COMPLEX_TYPE:
1034 case VECTOR_TYPE:
1035 case ENUMERAL_TYPE:
1036 case BOOLEAN_TYPE:
1038 unsigned int quals = TYPE_QUALS (node);
1039 enum tree_code_class tclass;
1041 if (quals & TYPE_QUAL_ATOMIC)
1042 pp_string (pp, "atomic ");
1043 if (quals & TYPE_QUAL_CONST)
1044 pp_string (pp, "const ");
1045 else if (quals & TYPE_QUAL_VOLATILE)
1046 pp_string (pp, "volatile ");
1047 else if (quals & TYPE_QUAL_RESTRICT)
1048 pp_string (pp, "restrict ");
1050 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1052 pp_string (pp, "<address-space-");
1053 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1054 pp_string (pp, "> ");
1057 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1059 if (tclass == tcc_declaration)
1061 if (DECL_NAME (node))
1062 dump_decl_name (pp, node, flags);
1063 else
1064 pp_string (pp, "<unnamed type decl>");
1066 else if (tclass == tcc_type)
1068 if (TYPE_NAME (node))
1070 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1071 pp_tree_identifier (pp, TYPE_NAME (node));
1072 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1073 && DECL_NAME (TYPE_NAME (node)))
1074 dump_decl_name (pp, TYPE_NAME (node), flags);
1075 else
1076 pp_string (pp, "<unnamed type>");
1078 else if (TREE_CODE (node) == VECTOR_TYPE)
1080 pp_string (pp, "vector");
1081 pp_left_paren (pp);
1082 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1083 pp_string (pp, ") ");
1084 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1086 else if (TREE_CODE (node) == INTEGER_TYPE)
1088 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1089 pp_string (pp, (TYPE_UNSIGNED (node)
1090 ? "unsigned char"
1091 : "signed char"));
1092 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1093 pp_string (pp, (TYPE_UNSIGNED (node)
1094 ? "unsigned short"
1095 : "signed short"));
1096 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1097 pp_string (pp, (TYPE_UNSIGNED (node)
1098 ? "unsigned int"
1099 : "signed int"));
1100 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1101 pp_string (pp, (TYPE_UNSIGNED (node)
1102 ? "unsigned long"
1103 : "signed long"));
1104 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1105 pp_string (pp, (TYPE_UNSIGNED (node)
1106 ? "unsigned long long"
1107 : "signed long long"));
1108 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1109 && exact_log2 (TYPE_PRECISION (node)) != -1)
1111 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1112 pp_decimal_int (pp, TYPE_PRECISION (node));
1113 pp_string (pp, "_t");
1115 else
1117 pp_string (pp, (TYPE_UNSIGNED (node)
1118 ? "<unnamed-unsigned:"
1119 : "<unnamed-signed:"));
1120 pp_decimal_int (pp, TYPE_PRECISION (node));
1121 pp_greater (pp);
1124 else if (TREE_CODE (node) == COMPLEX_TYPE)
1126 pp_string (pp, "__complex__ ");
1127 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1129 else if (TREE_CODE (node) == REAL_TYPE)
1131 pp_string (pp, "<float:");
1132 pp_decimal_int (pp, TYPE_PRECISION (node));
1133 pp_greater (pp);
1135 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1137 pp_string (pp, "<fixed-point-");
1138 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1139 pp_decimal_int (pp, TYPE_PRECISION (node));
1140 pp_greater (pp);
1142 else if (TREE_CODE (node) == VOID_TYPE)
1143 pp_string (pp, "void");
1144 else
1145 pp_string (pp, "<unnamed type>");
1147 break;
1150 case POINTER_TYPE:
1151 case REFERENCE_TYPE:
1152 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1154 if (TREE_TYPE (node) == NULL)
1156 pp_string (pp, str);
1157 pp_string (pp, "<null type>");
1159 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1161 tree fnode = TREE_TYPE (node);
1163 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1164 pp_space (pp);
1165 pp_left_paren (pp);
1166 pp_string (pp, str);
1167 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1168 dump_decl_name (pp, TYPE_NAME (node), flags);
1169 else if (flags & TDF_NOUID)
1170 pp_printf (pp, "<Txxxx>");
1171 else
1172 pp_printf (pp, "<T%x>", TYPE_UID (node));
1174 pp_right_paren (pp);
1175 dump_function_declaration (pp, fnode, spc, flags);
1177 else
1179 unsigned int quals = TYPE_QUALS (node);
1181 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1182 pp_space (pp);
1183 pp_string (pp, str);
1185 if (quals & TYPE_QUAL_CONST)
1186 pp_string (pp, " const");
1187 if (quals & TYPE_QUAL_VOLATILE)
1188 pp_string (pp, " volatile");
1189 if (quals & TYPE_QUAL_RESTRICT)
1190 pp_string (pp, " restrict");
1192 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1194 pp_string (pp, " <address-space-");
1195 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1196 pp_greater (pp);
1199 if (TYPE_REF_CAN_ALIAS_ALL (node))
1200 pp_string (pp, " {ref-all}");
1202 break;
1204 case OFFSET_TYPE:
1205 NIY;
1206 break;
1208 case MEM_REF:
1210 if (integer_zerop (TREE_OPERAND (node, 1))
1211 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1212 infer them and MEM_ATTR caching will share MEM_REFs
1213 with differently-typed op0s. */
1214 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1215 /* Released SSA_NAMES have no TREE_TYPE. */
1216 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1217 /* Same pointer types, but ignoring POINTER_TYPE vs.
1218 REFERENCE_TYPE. */
1219 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1220 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1221 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1222 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1223 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1224 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1225 /* Same value types ignoring qualifiers. */
1226 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1227 == TYPE_MAIN_VARIANT
1228 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1229 && (!(flags & TDF_ALIAS)
1230 || MR_DEPENDENCE_CLIQUE (node) == 0))
1232 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1234 pp_star (pp);
1235 dump_generic_node (pp, TREE_OPERAND (node, 0),
1236 spc, flags, false);
1238 else
1239 dump_generic_node (pp,
1240 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1241 spc, flags, false);
1243 else
1245 tree ptype;
1247 pp_string (pp, "MEM[");
1248 pp_left_paren (pp);
1249 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1250 dump_generic_node (pp, ptype,
1251 spc, flags | TDF_SLIM, false);
1252 pp_right_paren (pp);
1253 dump_generic_node (pp, TREE_OPERAND (node, 0),
1254 spc, flags, false);
1255 if (!integer_zerop (TREE_OPERAND (node, 1)))
1257 pp_string (pp, " + ");
1258 dump_generic_node (pp, TREE_OPERAND (node, 1),
1259 spc, flags, false);
1261 if ((flags & TDF_ALIAS)
1262 && MR_DEPENDENCE_CLIQUE (node) != 0)
1264 pp_string (pp, " clique ");
1265 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1266 pp_string (pp, " base ");
1267 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1269 pp_right_bracket (pp);
1271 break;
1274 case TARGET_MEM_REF:
1276 const char *sep = "";
1277 tree tmp;
1279 pp_string (pp, "MEM[");
1281 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1283 pp_string (pp, sep);
1284 sep = ", ";
1285 pp_string (pp, "symbol: ");
1286 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1287 spc, flags, false);
1289 else
1291 pp_string (pp, sep);
1292 sep = ", ";
1293 pp_string (pp, "base: ");
1294 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1296 tmp = TMR_INDEX2 (node);
1297 if (tmp)
1299 pp_string (pp, sep);
1300 sep = ", ";
1301 pp_string (pp, "base: ");
1302 dump_generic_node (pp, tmp, spc, flags, false);
1304 tmp = TMR_INDEX (node);
1305 if (tmp)
1307 pp_string (pp, sep);
1308 sep = ", ";
1309 pp_string (pp, "index: ");
1310 dump_generic_node (pp, tmp, spc, flags, false);
1312 tmp = TMR_STEP (node);
1313 if (tmp)
1315 pp_string (pp, sep);
1316 sep = ", ";
1317 pp_string (pp, "step: ");
1318 dump_generic_node (pp, tmp, spc, flags, false);
1320 tmp = TMR_OFFSET (node);
1321 if (tmp)
1323 pp_string (pp, sep);
1324 sep = ", ";
1325 pp_string (pp, "offset: ");
1326 dump_generic_node (pp, tmp, spc, flags, false);
1328 pp_right_bracket (pp);
1330 break;
1332 case ARRAY_TYPE:
1334 tree tmp;
1336 /* Print the innermost component type. */
1337 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1338 tmp = TREE_TYPE (tmp))
1340 dump_generic_node (pp, tmp, spc, flags, false);
1342 /* Print the dimensions. */
1343 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1344 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1345 break;
1348 case RECORD_TYPE:
1349 case UNION_TYPE:
1350 case QUAL_UNION_TYPE:
1352 unsigned int quals = TYPE_QUALS (node);
1354 if (quals & TYPE_QUAL_ATOMIC)
1355 pp_string (pp, "atomic ");
1356 if (quals & TYPE_QUAL_CONST)
1357 pp_string (pp, "const ");
1358 if (quals & TYPE_QUAL_VOLATILE)
1359 pp_string (pp, "volatile ");
1361 /* Print the name of the structure. */
1362 if (TREE_CODE (node) == RECORD_TYPE)
1363 pp_string (pp, "struct ");
1364 else if (TREE_CODE (node) == UNION_TYPE)
1365 pp_string (pp, "union ");
1367 if (TYPE_NAME (node))
1368 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1369 else if (!(flags & TDF_SLIM))
1370 /* FIXME: If we eliminate the 'else' above and attempt
1371 to show the fields for named types, we may get stuck
1372 following a cycle of pointers to structs. The alleged
1373 self-reference check in print_struct_decl will not detect
1374 cycles involving more than one pointer or struct type. */
1375 print_struct_decl (pp, node, spc, flags);
1376 break;
1379 case LANG_TYPE:
1380 NIY;
1381 break;
1383 case INTEGER_CST:
1384 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1386 /* In the case of a pointer, one may want to divide by the
1387 size of the pointed-to type. Unfortunately, this not
1388 straightforward. The C front-end maps expressions
1390 (int *) 5
1391 int *p; (p + 5)
1393 in such a way that the two INTEGER_CST nodes for "5" have
1394 different values but identical types. In the latter
1395 case, the 5 is multiplied by sizeof (int) in c-common.c
1396 (pointer_int_sum) to convert it to a byte address, and
1397 yet the type of the node is left unchanged. Argh. What
1398 is consistent though is that the number value corresponds
1399 to bytes (UNITS) offset.
1401 NB: Neither of the following divisors can be trivially
1402 used to recover the original literal:
1404 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1405 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1406 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1407 pp_string (pp, "B"); /* pseudo-unit */
1409 else if (tree_fits_shwi_p (node))
1410 pp_wide_integer (pp, tree_to_shwi (node));
1411 else if (tree_fits_uhwi_p (node))
1412 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1413 else
1415 wide_int val = node;
1417 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1419 pp_minus (pp);
1420 val = -val;
1422 print_hex (val, pp_buffer (pp)->digit_buffer);
1423 pp_string (pp, pp_buffer (pp)->digit_buffer);
1425 if (TREE_OVERFLOW (node))
1426 pp_string (pp, "(OVF)");
1427 break;
1429 case REAL_CST:
1430 /* Code copied from print_node. */
1432 REAL_VALUE_TYPE d;
1433 if (TREE_OVERFLOW (node))
1434 pp_string (pp, " overflow");
1436 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1437 d = TREE_REAL_CST (node);
1438 if (REAL_VALUE_ISINF (d))
1439 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1440 else if (REAL_VALUE_ISNAN (d))
1441 pp_string (pp, " Nan");
1442 else
1444 char string[100];
1445 real_to_decimal (string, &d, sizeof (string), 0, 1);
1446 pp_string (pp, string);
1448 #else
1450 HOST_WIDE_INT i;
1451 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1452 pp_string (pp, "0x");
1453 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1454 output_formatted_integer (pp, "%02x", *p++);
1456 #endif
1457 break;
1460 case FIXED_CST:
1462 char string[100];
1463 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1464 pp_string (pp, string);
1465 break;
1468 case COMPLEX_CST:
1469 pp_string (pp, "__complex__ (");
1470 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1471 pp_string (pp, ", ");
1472 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1473 pp_right_paren (pp);
1474 break;
1476 case STRING_CST:
1477 pp_string (pp, "\"");
1478 pretty_print_string (pp, TREE_STRING_POINTER (node));
1479 pp_string (pp, "\"");
1480 break;
1482 case VECTOR_CST:
1484 unsigned i;
1485 pp_string (pp, "{ ");
1486 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1488 if (i != 0)
1489 pp_string (pp, ", ");
1490 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1491 spc, flags, false);
1493 pp_string (pp, " }");
1495 break;
1497 case FUNCTION_TYPE:
1498 case METHOD_TYPE:
1499 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1500 pp_space (pp);
1501 if (TREE_CODE (node) == METHOD_TYPE)
1503 if (TYPE_METHOD_BASETYPE (node))
1504 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1505 flags);
1506 else
1507 pp_string (pp, "<null method basetype>");
1508 pp_colon_colon (pp);
1510 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1511 dump_decl_name (pp, TYPE_NAME (node), flags);
1512 else if (flags & TDF_NOUID)
1513 pp_printf (pp, "<Txxxx>");
1514 else
1515 pp_printf (pp, "<T%x>", TYPE_UID (node));
1516 dump_function_declaration (pp, node, spc, flags);
1517 break;
1519 case FUNCTION_DECL:
1520 case CONST_DECL:
1521 dump_decl_name (pp, node, flags);
1522 break;
1524 case LABEL_DECL:
1525 if (DECL_NAME (node))
1526 dump_decl_name (pp, node, flags);
1527 else if (LABEL_DECL_UID (node) != -1)
1528 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1529 else
1531 if (flags & TDF_NOUID)
1532 pp_string (pp, "<D.xxxx>");
1533 else
1534 pp_printf (pp, "<D.%u>", DECL_UID (node));
1536 break;
1538 case TYPE_DECL:
1539 if (DECL_IS_BUILTIN (node))
1541 /* Don't print the declaration of built-in types. */
1542 break;
1544 if (DECL_NAME (node))
1545 dump_decl_name (pp, node, flags);
1546 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1548 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1549 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1550 && TYPE_METHODS (TREE_TYPE (node)))
1552 /* The type is a c++ class: all structures have at least
1553 4 methods. */
1554 pp_string (pp, "class ");
1555 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1557 else
1559 pp_string (pp,
1560 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1561 ? "union" : "struct "));
1562 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1565 else
1566 pp_string (pp, "<anon>");
1567 break;
1569 case VAR_DECL:
1570 case PARM_DECL:
1571 case FIELD_DECL:
1572 case DEBUG_EXPR_DECL:
1573 case NAMESPACE_DECL:
1574 case NAMELIST_DECL:
1575 dump_decl_name (pp, node, flags);
1576 break;
1578 case RESULT_DECL:
1579 pp_string (pp, "<retval>");
1580 break;
1582 case COMPONENT_REF:
1583 op0 = TREE_OPERAND (node, 0);
1584 str = ".";
1585 if (op0
1586 && (TREE_CODE (op0) == INDIRECT_REF
1587 || (TREE_CODE (op0) == MEM_REF
1588 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1589 && integer_zerop (TREE_OPERAND (op0, 1))
1590 /* Dump the types of INTEGER_CSTs explicitly, for we
1591 can't infer them and MEM_ATTR caching will share
1592 MEM_REFs with differently-typed op0s. */
1593 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1594 /* Released SSA_NAMES have no TREE_TYPE. */
1595 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1596 /* Same pointer types, but ignoring POINTER_TYPE vs.
1597 REFERENCE_TYPE. */
1598 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1599 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1600 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1601 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1602 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1603 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1604 /* Same value types ignoring qualifiers. */
1605 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1606 == TYPE_MAIN_VARIANT
1607 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1608 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1610 op0 = TREE_OPERAND (op0, 0);
1611 str = "->";
1613 if (op_prio (op0) < op_prio (node))
1614 pp_left_paren (pp);
1615 dump_generic_node (pp, op0, spc, flags, false);
1616 if (op_prio (op0) < op_prio (node))
1617 pp_right_paren (pp);
1618 pp_string (pp, str);
1619 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1620 op0 = component_ref_field_offset (node);
1621 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1623 pp_string (pp, "{off: ");
1624 dump_generic_node (pp, op0, spc, flags, false);
1625 pp_right_brace (pp);
1627 break;
1629 case BIT_FIELD_REF:
1630 pp_string (pp, "BIT_FIELD_REF <");
1631 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1632 pp_string (pp, ", ");
1633 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1634 pp_string (pp, ", ");
1635 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1636 pp_greater (pp);
1637 break;
1639 case ARRAY_REF:
1640 case ARRAY_RANGE_REF:
1641 op0 = TREE_OPERAND (node, 0);
1642 if (op_prio (op0) < op_prio (node))
1643 pp_left_paren (pp);
1644 dump_generic_node (pp, op0, spc, flags, false);
1645 if (op_prio (op0) < op_prio (node))
1646 pp_right_paren (pp);
1647 pp_left_bracket (pp);
1648 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1649 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1650 pp_string (pp, " ...");
1651 pp_right_bracket (pp);
1653 op0 = array_ref_low_bound (node);
1654 op1 = array_ref_element_size (node);
1656 if (!integer_zerop (op0)
1657 || TREE_OPERAND (node, 2)
1658 || TREE_OPERAND (node, 3))
1660 pp_string (pp, "{lb: ");
1661 dump_generic_node (pp, op0, spc, flags, false);
1662 pp_string (pp, " sz: ");
1663 dump_generic_node (pp, op1, spc, flags, false);
1664 pp_right_brace (pp);
1666 break;
1668 case CONSTRUCTOR:
1670 unsigned HOST_WIDE_INT ix;
1671 tree field, val;
1672 bool is_struct_init = false;
1673 bool is_array_init = false;
1674 widest_int curidx;
1675 pp_left_brace (pp);
1676 if (TREE_CLOBBER_P (node))
1677 pp_string (pp, "CLOBBER");
1678 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1679 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1680 is_struct_init = true;
1681 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1682 && TYPE_DOMAIN (TREE_TYPE (node))
1683 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1684 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1685 == INTEGER_CST)
1687 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1688 is_array_init = true;
1689 curidx = wi::to_widest (minv);
1691 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1693 if (field)
1695 if (is_struct_init)
1697 pp_dot (pp);
1698 dump_generic_node (pp, field, spc, flags, false);
1699 pp_equal (pp);
1701 else if (is_array_init
1702 && (TREE_CODE (field) != INTEGER_CST
1703 || curidx != wi::to_widest (field)))
1705 pp_left_bracket (pp);
1706 if (TREE_CODE (field) == RANGE_EXPR)
1708 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1709 flags, false);
1710 pp_string (pp, " ... ");
1711 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1712 flags, false);
1713 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1714 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1716 else
1717 dump_generic_node (pp, field, spc, flags, false);
1718 if (TREE_CODE (field) == INTEGER_CST)
1719 curidx = wi::to_widest (field);
1720 pp_string (pp, "]=");
1723 if (is_array_init)
1724 curidx += 1;
1725 if (val && TREE_CODE (val) == ADDR_EXPR)
1726 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1727 val = TREE_OPERAND (val, 0);
1728 if (val && TREE_CODE (val) == FUNCTION_DECL)
1729 dump_decl_name (pp, val, flags);
1730 else
1731 dump_generic_node (pp, val, spc, flags, false);
1732 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1734 pp_comma (pp);
1735 pp_space (pp);
1738 pp_right_brace (pp);
1740 break;
1742 case COMPOUND_EXPR:
1744 tree *tp;
1745 if (flags & TDF_SLIM)
1747 pp_string (pp, "<COMPOUND_EXPR>");
1748 break;
1751 dump_generic_node (pp, TREE_OPERAND (node, 0),
1752 spc, flags, !(flags & TDF_SLIM));
1753 if (flags & TDF_SLIM)
1754 newline_and_indent (pp, spc);
1755 else
1757 pp_comma (pp);
1758 pp_space (pp);
1761 for (tp = &TREE_OPERAND (node, 1);
1762 TREE_CODE (*tp) == COMPOUND_EXPR;
1763 tp = &TREE_OPERAND (*tp, 1))
1765 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1766 spc, flags, !(flags & TDF_SLIM));
1767 if (flags & TDF_SLIM)
1768 newline_and_indent (pp, spc);
1769 else
1771 pp_comma (pp);
1772 pp_space (pp);
1776 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1778 break;
1780 case STATEMENT_LIST:
1782 tree_stmt_iterator si;
1783 bool first = true;
1785 if (flags & TDF_SLIM)
1787 pp_string (pp, "<STATEMENT_LIST>");
1788 break;
1791 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1793 if (!first)
1794 newline_and_indent (pp, spc);
1795 else
1796 first = false;
1797 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1800 break;
1802 case MODIFY_EXPR:
1803 case INIT_EXPR:
1804 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1805 false);
1806 pp_space (pp);
1807 pp_equal (pp);
1808 pp_space (pp);
1809 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1810 false);
1811 break;
1813 case TARGET_EXPR:
1814 pp_string (pp, "TARGET_EXPR <");
1815 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1816 pp_comma (pp);
1817 pp_space (pp);
1818 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1819 pp_greater (pp);
1820 break;
1822 case DECL_EXPR:
1823 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1824 is_stmt = false;
1825 break;
1827 case COND_EXPR:
1828 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1830 pp_string (pp, "if (");
1831 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1832 pp_right_paren (pp);
1833 /* The lowered cond_exprs should always be printed in full. */
1834 if (COND_EXPR_THEN (node)
1835 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1836 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1837 && COND_EXPR_ELSE (node)
1838 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1839 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1841 pp_space (pp);
1842 dump_generic_node (pp, COND_EXPR_THEN (node),
1843 0, flags, true);
1844 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1846 pp_string (pp, " else ");
1847 dump_generic_node (pp, COND_EXPR_ELSE (node),
1848 0, flags, true);
1851 else if (!(flags & TDF_SLIM))
1853 /* Output COND_EXPR_THEN. */
1854 if (COND_EXPR_THEN (node))
1856 newline_and_indent (pp, spc+2);
1857 pp_left_brace (pp);
1858 newline_and_indent (pp, spc+4);
1859 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
1860 flags, true);
1861 newline_and_indent (pp, spc+2);
1862 pp_right_brace (pp);
1865 /* Output COND_EXPR_ELSE. */
1866 if (COND_EXPR_ELSE (node)
1867 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1869 newline_and_indent (pp, spc);
1870 pp_string (pp, "else");
1871 newline_and_indent (pp, spc+2);
1872 pp_left_brace (pp);
1873 newline_and_indent (pp, spc+4);
1874 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
1875 flags, true);
1876 newline_and_indent (pp, spc+2);
1877 pp_right_brace (pp);
1880 is_expr = false;
1882 else
1884 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1885 pp_space (pp);
1886 pp_question (pp);
1887 pp_space (pp);
1888 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1889 pp_space (pp);
1890 pp_colon (pp);
1891 pp_space (pp);
1892 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1894 break;
1896 case BIND_EXPR:
1897 pp_left_brace (pp);
1898 if (!(flags & TDF_SLIM))
1900 if (BIND_EXPR_VARS (node))
1902 pp_newline (pp);
1904 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1906 print_declaration (pp, op0, spc+2, flags);
1907 pp_newline (pp);
1911 newline_and_indent (pp, spc+2);
1912 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
1913 newline_and_indent (pp, spc);
1914 pp_right_brace (pp);
1916 is_expr = false;
1917 break;
1919 case CALL_EXPR:
1920 if (CALL_EXPR_FN (node) != NULL_TREE)
1921 print_call_name (pp, CALL_EXPR_FN (node), flags);
1922 else
1923 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
1925 /* Print parameters. */
1926 pp_space (pp);
1927 pp_left_paren (pp);
1929 tree arg;
1930 call_expr_arg_iterator iter;
1931 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1933 dump_generic_node (pp, arg, spc, flags, false);
1934 if (more_call_expr_args_p (&iter))
1936 pp_comma (pp);
1937 pp_space (pp);
1941 if (CALL_EXPR_VA_ARG_PACK (node))
1943 if (call_expr_nargs (node) > 0)
1945 pp_comma (pp);
1946 pp_space (pp);
1948 pp_string (pp, "__builtin_va_arg_pack ()");
1950 pp_right_paren (pp);
1952 op1 = CALL_EXPR_STATIC_CHAIN (node);
1953 if (op1)
1955 pp_string (pp, " [static-chain: ");
1956 dump_generic_node (pp, op1, spc, flags, false);
1957 pp_right_bracket (pp);
1960 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1961 pp_string (pp, " [return slot optimization]");
1962 if (CALL_EXPR_TAILCALL (node))
1963 pp_string (pp, " [tail call]");
1964 break;
1966 case WITH_CLEANUP_EXPR:
1967 NIY;
1968 break;
1970 case CLEANUP_POINT_EXPR:
1971 pp_string (pp, "<<cleanup_point ");
1972 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1973 pp_string (pp, ">>");
1974 break;
1976 case PLACEHOLDER_EXPR:
1977 pp_string (pp, "<PLACEHOLDER_EXPR ");
1978 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1979 pp_greater (pp);
1980 break;
1982 /* Binary arithmetic and logic expressions. */
1983 case WIDEN_SUM_EXPR:
1984 case WIDEN_MULT_EXPR:
1985 case MULT_EXPR:
1986 case MULT_HIGHPART_EXPR:
1987 case PLUS_EXPR:
1988 case POINTER_PLUS_EXPR:
1989 case MINUS_EXPR:
1990 case TRUNC_DIV_EXPR:
1991 case CEIL_DIV_EXPR:
1992 case FLOOR_DIV_EXPR:
1993 case ROUND_DIV_EXPR:
1994 case TRUNC_MOD_EXPR:
1995 case CEIL_MOD_EXPR:
1996 case FLOOR_MOD_EXPR:
1997 case ROUND_MOD_EXPR:
1998 case RDIV_EXPR:
1999 case EXACT_DIV_EXPR:
2000 case LSHIFT_EXPR:
2001 case RSHIFT_EXPR:
2002 case LROTATE_EXPR:
2003 case RROTATE_EXPR:
2004 case WIDEN_LSHIFT_EXPR:
2005 case BIT_IOR_EXPR:
2006 case BIT_XOR_EXPR:
2007 case BIT_AND_EXPR:
2008 case TRUTH_ANDIF_EXPR:
2009 case TRUTH_ORIF_EXPR:
2010 case TRUTH_AND_EXPR:
2011 case TRUTH_OR_EXPR:
2012 case TRUTH_XOR_EXPR:
2013 case LT_EXPR:
2014 case LE_EXPR:
2015 case GT_EXPR:
2016 case GE_EXPR:
2017 case EQ_EXPR:
2018 case NE_EXPR:
2019 case UNLT_EXPR:
2020 case UNLE_EXPR:
2021 case UNGT_EXPR:
2022 case UNGE_EXPR:
2023 case UNEQ_EXPR:
2024 case LTGT_EXPR:
2025 case ORDERED_EXPR:
2026 case UNORDERED_EXPR:
2028 const char *op = op_symbol (node);
2029 op0 = TREE_OPERAND (node, 0);
2030 op1 = TREE_OPERAND (node, 1);
2032 /* When the operands are expressions with less priority,
2033 keep semantics of the tree representation. */
2034 if (op_prio (op0) <= op_prio (node))
2036 pp_left_paren (pp);
2037 dump_generic_node (pp, op0, spc, flags, false);
2038 pp_right_paren (pp);
2040 else
2041 dump_generic_node (pp, op0, spc, flags, false);
2043 pp_space (pp);
2044 pp_string (pp, op);
2045 pp_space (pp);
2047 /* When the operands are expressions with less priority,
2048 keep semantics of the tree representation. */
2049 if (op_prio (op1) <= op_prio (node))
2051 pp_left_paren (pp);
2052 dump_generic_node (pp, op1, spc, flags, false);
2053 pp_right_paren (pp);
2055 else
2056 dump_generic_node (pp, op1, spc, flags, false);
2058 break;
2060 /* Unary arithmetic and logic expressions. */
2061 case NEGATE_EXPR:
2062 case BIT_NOT_EXPR:
2063 case TRUTH_NOT_EXPR:
2064 case ADDR_EXPR:
2065 case PREDECREMENT_EXPR:
2066 case PREINCREMENT_EXPR:
2067 case INDIRECT_REF:
2068 if (TREE_CODE (node) == ADDR_EXPR
2069 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2070 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2071 ; /* Do not output '&' for strings and function pointers. */
2072 else
2073 pp_string (pp, op_symbol (node));
2075 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2077 pp_left_paren (pp);
2078 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2079 pp_right_paren (pp);
2081 else
2082 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2083 break;
2085 case POSTDECREMENT_EXPR:
2086 case POSTINCREMENT_EXPR:
2087 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2089 pp_left_paren (pp);
2090 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2091 pp_right_paren (pp);
2093 else
2094 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2095 pp_string (pp, op_symbol (node));
2096 break;
2098 case MIN_EXPR:
2099 pp_string (pp, "MIN_EXPR <");
2100 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2101 pp_string (pp, ", ");
2102 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2103 pp_greater (pp);
2104 break;
2106 case MAX_EXPR:
2107 pp_string (pp, "MAX_EXPR <");
2108 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2109 pp_string (pp, ", ");
2110 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2111 pp_greater (pp);
2112 break;
2114 case ABS_EXPR:
2115 pp_string (pp, "ABS_EXPR <");
2116 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2117 pp_greater (pp);
2118 break;
2120 case RANGE_EXPR:
2121 NIY;
2122 break;
2124 case ADDR_SPACE_CONVERT_EXPR:
2125 case FIXED_CONVERT_EXPR:
2126 case FIX_TRUNC_EXPR:
2127 case FLOAT_EXPR:
2128 CASE_CONVERT:
2129 type = TREE_TYPE (node);
2130 op0 = TREE_OPERAND (node, 0);
2131 if (type != TREE_TYPE (op0))
2133 pp_left_paren (pp);
2134 dump_generic_node (pp, type, spc, flags, false);
2135 pp_string (pp, ") ");
2137 if (op_prio (op0) < op_prio (node))
2138 pp_left_paren (pp);
2139 dump_generic_node (pp, op0, spc, flags, false);
2140 if (op_prio (op0) < op_prio (node))
2141 pp_right_paren (pp);
2142 break;
2144 case VIEW_CONVERT_EXPR:
2145 pp_string (pp, "VIEW_CONVERT_EXPR<");
2146 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2147 pp_string (pp, ">(");
2148 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2149 pp_right_paren (pp);
2150 break;
2152 case PAREN_EXPR:
2153 pp_string (pp, "((");
2154 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2155 pp_string (pp, "))");
2156 break;
2158 case NON_LVALUE_EXPR:
2159 pp_string (pp, "NON_LVALUE_EXPR <");
2160 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2161 pp_greater (pp);
2162 break;
2164 case SAVE_EXPR:
2165 pp_string (pp, "SAVE_EXPR <");
2166 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2167 pp_greater (pp);
2168 break;
2170 case COMPLEX_EXPR:
2171 pp_string (pp, "COMPLEX_EXPR <");
2172 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2173 pp_string (pp, ", ");
2174 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2175 pp_greater (pp);
2176 break;
2178 case CONJ_EXPR:
2179 pp_string (pp, "CONJ_EXPR <");
2180 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2181 pp_greater (pp);
2182 break;
2184 case REALPART_EXPR:
2185 pp_string (pp, "REALPART_EXPR <");
2186 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2187 pp_greater (pp);
2188 break;
2190 case IMAGPART_EXPR:
2191 pp_string (pp, "IMAGPART_EXPR <");
2192 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2193 pp_greater (pp);
2194 break;
2196 case VA_ARG_EXPR:
2197 pp_string (pp, "VA_ARG_EXPR <");
2198 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2199 pp_greater (pp);
2200 break;
2202 case TRY_FINALLY_EXPR:
2203 case TRY_CATCH_EXPR:
2204 pp_string (pp, "try");
2205 newline_and_indent (pp, spc+2);
2206 pp_left_brace (pp);
2207 newline_and_indent (pp, spc+4);
2208 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2209 newline_and_indent (pp, spc+2);
2210 pp_right_brace (pp);
2211 newline_and_indent (pp, spc);
2212 pp_string (pp,
2213 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2214 newline_and_indent (pp, spc+2);
2215 pp_left_brace (pp);
2216 newline_and_indent (pp, spc+4);
2217 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2218 newline_and_indent (pp, spc+2);
2219 pp_right_brace (pp);
2220 is_expr = false;
2221 break;
2223 case CATCH_EXPR:
2224 pp_string (pp, "catch (");
2225 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2226 pp_right_paren (pp);
2227 newline_and_indent (pp, spc+2);
2228 pp_left_brace (pp);
2229 newline_and_indent (pp, spc+4);
2230 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2231 newline_and_indent (pp, spc+2);
2232 pp_right_brace (pp);
2233 is_expr = false;
2234 break;
2236 case EH_FILTER_EXPR:
2237 pp_string (pp, "<<<eh_filter (");
2238 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2239 pp_string (pp, ")>>>");
2240 newline_and_indent (pp, spc+2);
2241 pp_left_brace (pp);
2242 newline_and_indent (pp, spc+4);
2243 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2244 newline_and_indent (pp, spc+2);
2245 pp_right_brace (pp);
2246 is_expr = false;
2247 break;
2249 case LABEL_EXPR:
2250 op0 = TREE_OPERAND (node, 0);
2251 /* If this is for break or continue, don't bother printing it. */
2252 if (DECL_NAME (op0))
2254 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2255 if (strcmp (name, "break") == 0
2256 || strcmp (name, "continue") == 0)
2257 break;
2259 dump_generic_node (pp, op0, spc, flags, false);
2260 pp_colon (pp);
2261 if (DECL_NONLOCAL (op0))
2262 pp_string (pp, " [non-local]");
2263 break;
2265 case LOOP_EXPR:
2266 pp_string (pp, "while (1)");
2267 if (!(flags & TDF_SLIM))
2269 newline_and_indent (pp, spc+2);
2270 pp_left_brace (pp);
2271 newline_and_indent (pp, spc+4);
2272 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2273 newline_and_indent (pp, spc+2);
2274 pp_right_brace (pp);
2276 is_expr = false;
2277 break;
2279 case PREDICT_EXPR:
2280 pp_string (pp, "// predicted ");
2281 if (PREDICT_EXPR_OUTCOME (node))
2282 pp_string (pp, "likely by ");
2283 else
2284 pp_string (pp, "unlikely by ");
2285 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2286 pp_string (pp, " predictor.");
2287 break;
2289 case ANNOTATE_EXPR:
2290 pp_string (pp, "ANNOTATE_EXPR <");
2291 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2292 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2294 case annot_expr_ivdep_kind:
2295 pp_string (pp, ", ivdep");
2296 break;
2297 case annot_expr_no_vector_kind:
2298 pp_string (pp, ", no-vector");
2299 break;
2300 case annot_expr_vector_kind:
2301 pp_string (pp, ", vector");
2302 break;
2303 default:
2304 gcc_unreachable ();
2306 pp_greater (pp);
2307 break;
2309 case RETURN_EXPR:
2310 pp_string (pp, "return");
2311 op0 = TREE_OPERAND (node, 0);
2312 if (op0)
2314 pp_space (pp);
2315 if (TREE_CODE (op0) == MODIFY_EXPR)
2316 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2317 spc, flags, false);
2318 else
2319 dump_generic_node (pp, op0, spc, flags, false);
2321 break;
2323 case EXIT_EXPR:
2324 pp_string (pp, "if (");
2325 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2326 pp_string (pp, ") break");
2327 break;
2329 case SWITCH_EXPR:
2330 pp_string (pp, "switch (");
2331 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2332 pp_right_paren (pp);
2333 if (!(flags & TDF_SLIM))
2335 newline_and_indent (pp, spc+2);
2336 pp_left_brace (pp);
2337 if (SWITCH_BODY (node))
2339 newline_and_indent (pp, spc+4);
2340 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2341 true);
2343 else
2345 tree vec = SWITCH_LABELS (node);
2346 size_t i, n = TREE_VEC_LENGTH (vec);
2347 for (i = 0; i < n; ++i)
2349 tree elt = TREE_VEC_ELT (vec, i);
2350 newline_and_indent (pp, spc+4);
2351 if (elt)
2353 dump_generic_node (pp, elt, spc+4, flags, false);
2354 pp_string (pp, " goto ");
2355 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2356 flags, true);
2357 pp_semicolon (pp);
2359 else
2360 pp_string (pp, "case ???: goto ???;");
2363 newline_and_indent (pp, spc+2);
2364 pp_right_brace (pp);
2366 is_expr = false;
2367 break;
2369 case GOTO_EXPR:
2370 op0 = GOTO_DESTINATION (node);
2371 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2373 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2374 if (strcmp (name, "break") == 0
2375 || strcmp (name, "continue") == 0)
2377 pp_string (pp, name);
2378 break;
2381 pp_string (pp, "goto ");
2382 dump_generic_node (pp, op0, spc, flags, false);
2383 break;
2385 case ASM_EXPR:
2386 pp_string (pp, "__asm__");
2387 if (ASM_VOLATILE_P (node))
2388 pp_string (pp, " __volatile__");
2389 pp_left_paren (pp);
2390 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2391 pp_colon (pp);
2392 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2393 pp_colon (pp);
2394 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2395 if (ASM_CLOBBERS (node))
2397 pp_colon (pp);
2398 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2400 pp_right_paren (pp);
2401 break;
2403 case CASE_LABEL_EXPR:
2404 if (CASE_LOW (node) && CASE_HIGH (node))
2406 pp_string (pp, "case ");
2407 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2408 pp_string (pp, " ... ");
2409 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2411 else if (CASE_LOW (node))
2413 pp_string (pp, "case ");
2414 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2416 else
2417 pp_string (pp, "default");
2418 pp_colon (pp);
2419 break;
2421 case OBJ_TYPE_REF:
2422 pp_string (pp, "OBJ_TYPE_REF(");
2423 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2424 pp_semicolon (pp);
2425 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2427 pp_string (pp, "(");
2428 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2429 pp_string (pp, ")");
2431 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2432 pp_arrow (pp);
2433 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2434 pp_right_paren (pp);
2435 break;
2437 case SSA_NAME:
2438 if (SSA_NAME_IDENTIFIER (node))
2439 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2440 spc, flags, false);
2441 pp_underscore (pp);
2442 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2443 if (SSA_NAME_IS_DEFAULT_DEF (node))
2444 pp_string (pp, "(D)");
2445 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2446 pp_string (pp, "(ab)");
2447 break;
2449 case WITH_SIZE_EXPR:
2450 pp_string (pp, "WITH_SIZE_EXPR <");
2451 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2452 pp_string (pp, ", ");
2453 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2454 pp_greater (pp);
2455 break;
2457 case ASSERT_EXPR:
2458 pp_string (pp, "ASSERT_EXPR <");
2459 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2460 pp_string (pp, ", ");
2461 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2462 pp_greater (pp);
2463 break;
2465 case SCEV_KNOWN:
2466 pp_string (pp, "scev_known");
2467 break;
2469 case SCEV_NOT_KNOWN:
2470 pp_string (pp, "scev_not_known");
2471 break;
2473 case POLYNOMIAL_CHREC:
2474 pp_left_brace (pp);
2475 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2476 pp_string (pp, ", +, ");
2477 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2478 pp_string (pp, "}_");
2479 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2480 is_stmt = false;
2481 break;
2483 case REALIGN_LOAD_EXPR:
2484 pp_string (pp, "REALIGN_LOAD <");
2485 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2486 pp_string (pp, ", ");
2487 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2488 pp_string (pp, ", ");
2489 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2490 pp_greater (pp);
2491 break;
2493 case VEC_COND_EXPR:
2494 pp_string (pp, " VEC_COND_EXPR < ");
2495 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2496 pp_string (pp, " , ");
2497 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2498 pp_string (pp, " , ");
2499 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2500 pp_string (pp, " > ");
2501 break;
2503 case VEC_PERM_EXPR:
2504 pp_string (pp, " VEC_PERM_EXPR < ");
2505 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2506 pp_string (pp, " , ");
2507 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2508 pp_string (pp, " , ");
2509 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2510 pp_string (pp, " > ");
2511 break;
2513 case DOT_PROD_EXPR:
2514 pp_string (pp, " DOT_PROD_EXPR < ");
2515 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2516 pp_string (pp, ", ");
2517 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2518 pp_string (pp, ", ");
2519 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2520 pp_string (pp, " > ");
2521 break;
2523 case WIDEN_MULT_PLUS_EXPR:
2524 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2525 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2526 pp_string (pp, ", ");
2527 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2528 pp_string (pp, ", ");
2529 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2530 pp_string (pp, " > ");
2531 break;
2533 case WIDEN_MULT_MINUS_EXPR:
2534 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2535 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2536 pp_string (pp, ", ");
2537 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2538 pp_string (pp, ", ");
2539 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2540 pp_string (pp, " > ");
2541 break;
2543 case FMA_EXPR:
2544 pp_string (pp, " FMA_EXPR < ");
2545 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2546 pp_string (pp, ", ");
2547 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2548 pp_string (pp, ", ");
2549 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2550 pp_string (pp, " > ");
2551 break;
2553 case OACC_PARALLEL:
2554 pp_string (pp, "#pragma acc parallel");
2555 dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags);
2556 goto dump_omp_body;
2558 case OACC_KERNELS:
2559 pp_string (pp, "#pragma acc kernels");
2560 dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags);
2561 goto dump_omp_body;
2563 case OACC_DATA:
2564 pp_string (pp, "#pragma acc data");
2565 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2566 goto dump_omp_body;
2568 case OACC_HOST_DATA:
2569 pp_string (pp, "#pragma acc host_data");
2570 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2571 goto dump_omp_body;
2573 case OACC_DECLARE:
2574 pp_string (pp, "#pragma acc declare");
2575 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2576 break;
2578 case OACC_UPDATE:
2579 pp_string (pp, "#pragma acc update");
2580 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2581 break;
2583 case OACC_ENTER_DATA:
2584 pp_string (pp, "#pragma acc enter data");
2585 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2586 break;
2588 case OACC_EXIT_DATA:
2589 pp_string (pp, "#pragma acc exit data");
2590 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2591 break;
2593 case OACC_CACHE:
2594 pp_string (pp, "#pragma acc cache");
2595 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2596 break;
2598 case OMP_PARALLEL:
2599 pp_string (pp, "#pragma omp parallel");
2600 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2602 dump_omp_body:
2603 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2605 newline_and_indent (pp, spc + 2);
2606 pp_left_brace (pp);
2607 newline_and_indent (pp, spc + 4);
2608 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2609 newline_and_indent (pp, spc + 2);
2610 pp_right_brace (pp);
2612 is_expr = false;
2613 break;
2615 case OMP_TASK:
2616 pp_string (pp, "#pragma omp task");
2617 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2618 goto dump_omp_body;
2620 case OMP_FOR:
2621 pp_string (pp, "#pragma omp for");
2622 goto dump_omp_loop;
2624 case OMP_SIMD:
2625 pp_string (pp, "#pragma omp simd");
2626 goto dump_omp_loop;
2628 case CILK_SIMD:
2629 pp_string (pp, "#pragma simd");
2630 goto dump_omp_loop;
2632 case CILK_FOR:
2633 /* This label points one line after dumping the clauses.
2634 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2635 parameters are printed out. */
2636 goto dump_omp_loop_cilk_for;
2638 case OMP_DISTRIBUTE:
2639 pp_string (pp, "#pragma omp distribute");
2640 goto dump_omp_loop;
2642 case OACC_LOOP:
2643 pp_string (pp, "#pragma acc loop");
2644 goto dump_omp_loop;
2646 case OMP_TEAMS:
2647 pp_string (pp, "#pragma omp teams");
2648 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2649 goto dump_omp_body;
2651 case OMP_TARGET_DATA:
2652 pp_string (pp, "#pragma omp target data");
2653 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2654 goto dump_omp_body;
2656 case OMP_TARGET:
2657 pp_string (pp, "#pragma omp target");
2658 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2659 goto dump_omp_body;
2661 case OMP_TARGET_UPDATE:
2662 pp_string (pp, "#pragma omp target update");
2663 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2664 is_expr = false;
2665 break;
2667 dump_omp_loop:
2668 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2670 dump_omp_loop_cilk_for:
2671 if (!(flags & TDF_SLIM))
2673 int i;
2675 if (OMP_FOR_PRE_BODY (node))
2677 if (TREE_CODE (node) == CILK_FOR)
2678 pp_string (pp, " ");
2679 else
2680 newline_and_indent (pp, spc + 2);
2681 pp_left_brace (pp);
2682 spc += 4;
2683 newline_and_indent (pp, spc);
2684 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2685 spc, flags, false);
2687 if (OMP_FOR_INIT (node))
2689 spc -= 2;
2690 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2692 spc += 2;
2693 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2694 newline_and_indent (pp, spc);
2695 if (TREE_CODE (node) == CILK_FOR)
2696 pp_string (pp, "_Cilk_for (");
2697 else
2698 pp_string (pp, "for (");
2699 dump_generic_node (pp,
2700 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2701 spc, flags, false);
2702 pp_string (pp, "; ");
2703 dump_generic_node (pp,
2704 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2705 spc, flags, false);
2706 pp_string (pp, "; ");
2707 dump_generic_node (pp,
2708 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2709 spc, flags, false);
2710 pp_right_paren (pp);
2712 if (TREE_CODE (node) == CILK_FOR)
2713 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2715 if (OMP_FOR_BODY (node))
2717 newline_and_indent (pp, spc + 2);
2718 pp_left_brace (pp);
2719 newline_and_indent (pp, spc + 4);
2720 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2721 false);
2722 newline_and_indent (pp, spc + 2);
2723 pp_right_brace (pp);
2725 if (OMP_FOR_INIT (node))
2726 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2727 if (OMP_FOR_PRE_BODY (node))
2729 spc -= 4;
2730 newline_and_indent (pp, spc + 2);
2731 pp_right_brace (pp);
2734 is_expr = false;
2735 break;
2737 case OMP_SECTIONS:
2738 pp_string (pp, "#pragma omp sections");
2739 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2740 goto dump_omp_body;
2742 case OMP_SECTION:
2743 pp_string (pp, "#pragma omp section");
2744 goto dump_omp_body;
2746 case OMP_MASTER:
2747 pp_string (pp, "#pragma omp master");
2748 goto dump_omp_body;
2750 case OMP_TASKGROUP:
2751 pp_string (pp, "#pragma omp taskgroup");
2752 goto dump_omp_body;
2754 case OMP_ORDERED:
2755 pp_string (pp, "#pragma omp ordered");
2756 goto dump_omp_body;
2758 case OMP_CRITICAL:
2759 pp_string (pp, "#pragma omp critical");
2760 if (OMP_CRITICAL_NAME (node))
2762 pp_space (pp);
2763 pp_left_paren (pp);
2764 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2765 flags, false);
2766 pp_right_paren (pp);
2768 goto dump_omp_body;
2770 case OMP_ATOMIC:
2771 pp_string (pp, "#pragma omp atomic");
2772 if (OMP_ATOMIC_SEQ_CST (node))
2773 pp_string (pp, " seq_cst");
2774 newline_and_indent (pp, spc + 2);
2775 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2776 pp_space (pp);
2777 pp_equal (pp);
2778 pp_space (pp);
2779 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2780 break;
2782 case OMP_ATOMIC_READ:
2783 pp_string (pp, "#pragma omp atomic read");
2784 if (OMP_ATOMIC_SEQ_CST (node))
2785 pp_string (pp, " seq_cst");
2786 newline_and_indent (pp, spc + 2);
2787 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2788 pp_space (pp);
2789 break;
2791 case OMP_ATOMIC_CAPTURE_OLD:
2792 case OMP_ATOMIC_CAPTURE_NEW:
2793 pp_string (pp, "#pragma omp atomic capture");
2794 if (OMP_ATOMIC_SEQ_CST (node))
2795 pp_string (pp, " seq_cst");
2796 newline_and_indent (pp, spc + 2);
2797 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2798 pp_space (pp);
2799 pp_equal (pp);
2800 pp_space (pp);
2801 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2802 break;
2804 case OMP_SINGLE:
2805 pp_string (pp, "#pragma omp single");
2806 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2807 goto dump_omp_body;
2809 case OMP_CLAUSE:
2810 dump_omp_clause (pp, node, spc, flags);
2811 is_expr = false;
2812 break;
2814 case TRANSACTION_EXPR:
2815 if (TRANSACTION_EXPR_OUTER (node))
2816 pp_string (pp, "__transaction_atomic [[outer]]");
2817 else if (TRANSACTION_EXPR_RELAXED (node))
2818 pp_string (pp, "__transaction_relaxed");
2819 else
2820 pp_string (pp, "__transaction_atomic");
2821 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2823 newline_and_indent (pp, spc);
2824 pp_left_brace (pp);
2825 newline_and_indent (pp, spc + 2);
2826 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
2827 spc + 2, flags, false);
2828 newline_and_indent (pp, spc);
2829 pp_right_brace (pp);
2831 is_expr = false;
2832 break;
2834 case REDUC_MAX_EXPR:
2835 pp_string (pp, " REDUC_MAX_EXPR < ");
2836 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2837 pp_string (pp, " > ");
2838 break;
2840 case REDUC_MIN_EXPR:
2841 pp_string (pp, " REDUC_MIN_EXPR < ");
2842 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2843 pp_string (pp, " > ");
2844 break;
2846 case REDUC_PLUS_EXPR:
2847 pp_string (pp, " REDUC_PLUS_EXPR < ");
2848 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2849 pp_string (pp, " > ");
2850 break;
2852 case VEC_WIDEN_MULT_HI_EXPR:
2853 case VEC_WIDEN_MULT_LO_EXPR:
2854 case VEC_WIDEN_MULT_EVEN_EXPR:
2855 case VEC_WIDEN_MULT_ODD_EXPR:
2856 case VEC_WIDEN_LSHIFT_HI_EXPR:
2857 case VEC_WIDEN_LSHIFT_LO_EXPR:
2858 pp_space (pp);
2859 for (str = get_tree_code_name (code); *str; str++)
2860 pp_character (pp, TOUPPER (*str));
2861 pp_string (pp, " < ");
2862 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2863 pp_string (pp, ", ");
2864 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2865 pp_string (pp, " > ");
2866 break;
2868 case VEC_UNPACK_HI_EXPR:
2869 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
2870 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2871 pp_string (pp, " > ");
2872 break;
2874 case VEC_UNPACK_LO_EXPR:
2875 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
2876 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2877 pp_string (pp, " > ");
2878 break;
2880 case VEC_UNPACK_FLOAT_HI_EXPR:
2881 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2882 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2883 pp_string (pp, " > ");
2884 break;
2886 case VEC_UNPACK_FLOAT_LO_EXPR:
2887 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2888 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2889 pp_string (pp, " > ");
2890 break;
2892 case VEC_PACK_TRUNC_EXPR:
2893 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
2894 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2895 pp_string (pp, ", ");
2896 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2897 pp_string (pp, " > ");
2898 break;
2900 case VEC_PACK_SAT_EXPR:
2901 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
2902 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2903 pp_string (pp, ", ");
2904 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2905 pp_string (pp, " > ");
2906 break;
2908 case VEC_PACK_FIX_TRUNC_EXPR:
2909 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
2910 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2911 pp_string (pp, ", ");
2912 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2913 pp_string (pp, " > ");
2914 break;
2916 case BLOCK:
2917 dump_block_node (pp, node, spc, flags);
2918 break;
2920 case CILK_SPAWN_STMT:
2921 pp_string (pp, "_Cilk_spawn ");
2922 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2923 break;
2925 case CILK_SYNC_STMT:
2926 pp_string (pp, "_Cilk_sync");
2927 break;
2929 default:
2930 NIY;
2933 if (is_stmt && is_expr)
2934 pp_semicolon (pp);
2936 return spc;
2939 /* Print the declaration of a variable. */
2941 void
2942 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
2944 INDENT (spc);
2946 if (TREE_CODE(t) == NAMELIST_DECL)
2948 pp_string(pp, "namelist ");
2949 dump_decl_name (pp, t, flags);
2950 pp_semicolon (pp);
2951 return;
2954 if (TREE_CODE (t) == TYPE_DECL)
2955 pp_string (pp, "typedef ");
2957 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2958 pp_string (pp, "register ");
2960 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2961 pp_string (pp, "extern ");
2962 else if (TREE_STATIC (t))
2963 pp_string (pp, "static ");
2965 /* Print the type and name. */
2966 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2968 tree tmp;
2970 /* Print array's type. */
2971 tmp = TREE_TYPE (t);
2972 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2973 tmp = TREE_TYPE (tmp);
2974 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
2976 /* Print variable's name. */
2977 pp_space (pp);
2978 dump_generic_node (pp, t, spc, flags, false);
2980 /* Print the dimensions. */
2981 tmp = TREE_TYPE (t);
2982 while (TREE_CODE (tmp) == ARRAY_TYPE)
2984 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2985 tmp = TREE_TYPE (tmp);
2988 else if (TREE_CODE (t) == FUNCTION_DECL)
2990 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2991 pp_space (pp);
2992 dump_decl_name (pp, t, flags);
2993 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
2995 else
2997 /* Print type declaration. */
2998 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3000 /* Print variable's name. */
3001 pp_space (pp);
3002 dump_generic_node (pp, t, spc, flags, false);
3005 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3007 pp_string (pp, " __asm__ ");
3008 pp_left_paren (pp);
3009 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3010 pp_right_paren (pp);
3013 /* The initial value of a function serves to determine whether the function
3014 is declared or defined. So the following does not apply to function
3015 nodes. */
3016 if (TREE_CODE (t) != FUNCTION_DECL)
3018 /* Print the initial value. */
3019 if (DECL_INITIAL (t))
3021 pp_space (pp);
3022 pp_equal (pp);
3023 pp_space (pp);
3024 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3028 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3030 pp_string (pp, " [value-expr: ");
3031 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3032 pp_right_bracket (pp);
3035 pp_semicolon (pp);
3039 /* Prints a structure: name, fields, and methods.
3040 FIXME: Still incomplete. */
3042 static void
3043 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3045 /* Print the name of the structure. */
3046 if (TYPE_NAME (node))
3048 INDENT (spc);
3049 if (TREE_CODE (node) == RECORD_TYPE)
3050 pp_string (pp, "struct ");
3051 else if ((TREE_CODE (node) == UNION_TYPE
3052 || TREE_CODE (node) == QUAL_UNION_TYPE))
3053 pp_string (pp, "union ");
3055 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3058 /* Print the contents of the structure. */
3059 pp_newline (pp);
3060 INDENT (spc);
3061 pp_left_brace (pp);
3062 pp_newline (pp);
3064 /* Print the fields of the structure. */
3066 tree tmp;
3067 tmp = TYPE_FIELDS (node);
3068 while (tmp)
3070 /* Avoid to print recursively the structure. */
3071 /* FIXME : Not implemented correctly...,
3072 what about the case when we have a cycle in the contain graph? ...
3073 Maybe this could be solved by looking at the scope in which the
3074 structure was declared. */
3075 if (TREE_TYPE (tmp) != node
3076 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3077 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3079 print_declaration (pp, tmp, spc+2, flags);
3080 pp_newline (pp);
3082 tmp = DECL_CHAIN (tmp);
3085 INDENT (spc);
3086 pp_right_brace (pp);
3089 /* Return the priority of the operator CODE.
3091 From lowest to highest precedence with either left-to-right (L-R)
3092 or right-to-left (R-L) associativity]:
3094 1 [L-R] ,
3095 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3096 3 [R-L] ?:
3097 4 [L-R] ||
3098 5 [L-R] &&
3099 6 [L-R] |
3100 7 [L-R] ^
3101 8 [L-R] &
3102 9 [L-R] == !=
3103 10 [L-R] < <= > >=
3104 11 [L-R] << >>
3105 12 [L-R] + -
3106 13 [L-R] * / %
3107 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3108 15 [L-R] fn() [] -> .
3110 unary +, - and * have higher precedence than the corresponding binary
3111 operators. */
3114 op_code_prio (enum tree_code code)
3116 switch (code)
3118 case TREE_LIST:
3119 case COMPOUND_EXPR:
3120 case BIND_EXPR:
3121 return 1;
3123 case MODIFY_EXPR:
3124 case INIT_EXPR:
3125 return 2;
3127 case COND_EXPR:
3128 return 3;
3130 case TRUTH_OR_EXPR:
3131 case TRUTH_ORIF_EXPR:
3132 return 4;
3134 case TRUTH_AND_EXPR:
3135 case TRUTH_ANDIF_EXPR:
3136 return 5;
3138 case BIT_IOR_EXPR:
3139 return 6;
3141 case BIT_XOR_EXPR:
3142 case TRUTH_XOR_EXPR:
3143 return 7;
3145 case BIT_AND_EXPR:
3146 return 8;
3148 case EQ_EXPR:
3149 case NE_EXPR:
3150 return 9;
3152 case UNLT_EXPR:
3153 case UNLE_EXPR:
3154 case UNGT_EXPR:
3155 case UNGE_EXPR:
3156 case UNEQ_EXPR:
3157 case LTGT_EXPR:
3158 case ORDERED_EXPR:
3159 case UNORDERED_EXPR:
3160 case LT_EXPR:
3161 case LE_EXPR:
3162 case GT_EXPR:
3163 case GE_EXPR:
3164 return 10;
3166 case LSHIFT_EXPR:
3167 case RSHIFT_EXPR:
3168 case LROTATE_EXPR:
3169 case RROTATE_EXPR:
3170 case VEC_WIDEN_LSHIFT_HI_EXPR:
3171 case VEC_WIDEN_LSHIFT_LO_EXPR:
3172 case WIDEN_LSHIFT_EXPR:
3173 return 11;
3175 case WIDEN_SUM_EXPR:
3176 case PLUS_EXPR:
3177 case POINTER_PLUS_EXPR:
3178 case MINUS_EXPR:
3179 return 12;
3181 case VEC_WIDEN_MULT_HI_EXPR:
3182 case VEC_WIDEN_MULT_LO_EXPR:
3183 case WIDEN_MULT_EXPR:
3184 case DOT_PROD_EXPR:
3185 case WIDEN_MULT_PLUS_EXPR:
3186 case WIDEN_MULT_MINUS_EXPR:
3187 case MULT_EXPR:
3188 case MULT_HIGHPART_EXPR:
3189 case TRUNC_DIV_EXPR:
3190 case CEIL_DIV_EXPR:
3191 case FLOOR_DIV_EXPR:
3192 case ROUND_DIV_EXPR:
3193 case RDIV_EXPR:
3194 case EXACT_DIV_EXPR:
3195 case TRUNC_MOD_EXPR:
3196 case CEIL_MOD_EXPR:
3197 case FLOOR_MOD_EXPR:
3198 case ROUND_MOD_EXPR:
3199 case FMA_EXPR:
3200 return 13;
3202 case TRUTH_NOT_EXPR:
3203 case BIT_NOT_EXPR:
3204 case POSTINCREMENT_EXPR:
3205 case POSTDECREMENT_EXPR:
3206 case PREINCREMENT_EXPR:
3207 case PREDECREMENT_EXPR:
3208 case NEGATE_EXPR:
3209 case INDIRECT_REF:
3210 case ADDR_EXPR:
3211 case FLOAT_EXPR:
3212 CASE_CONVERT:
3213 case FIX_TRUNC_EXPR:
3214 case TARGET_EXPR:
3215 return 14;
3217 case CALL_EXPR:
3218 case ARRAY_REF:
3219 case ARRAY_RANGE_REF:
3220 case COMPONENT_REF:
3221 return 15;
3223 /* Special expressions. */
3224 case MIN_EXPR:
3225 case MAX_EXPR:
3226 case ABS_EXPR:
3227 case REALPART_EXPR:
3228 case IMAGPART_EXPR:
3229 case REDUC_MAX_EXPR:
3230 case REDUC_MIN_EXPR:
3231 case REDUC_PLUS_EXPR:
3232 case VEC_UNPACK_HI_EXPR:
3233 case VEC_UNPACK_LO_EXPR:
3234 case VEC_UNPACK_FLOAT_HI_EXPR:
3235 case VEC_UNPACK_FLOAT_LO_EXPR:
3236 case VEC_PACK_TRUNC_EXPR:
3237 case VEC_PACK_SAT_EXPR:
3238 return 16;
3240 default:
3241 /* Return an arbitrarily high precedence to avoid surrounding single
3242 VAR_DECLs in ()s. */
3243 return 9999;
3247 /* Return the priority of the operator OP. */
3250 op_prio (const_tree op)
3252 enum tree_code code;
3254 if (op == NULL)
3255 return 9999;
3257 code = TREE_CODE (op);
3258 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3259 return op_prio (TREE_OPERAND (op, 0));
3261 return op_code_prio (code);
3264 /* Return the symbol associated with operator CODE. */
3266 const char *
3267 op_symbol_code (enum tree_code code)
3269 switch (code)
3271 case MODIFY_EXPR:
3272 return "=";
3274 case TRUTH_OR_EXPR:
3275 case TRUTH_ORIF_EXPR:
3276 return "||";
3278 case TRUTH_AND_EXPR:
3279 case TRUTH_ANDIF_EXPR:
3280 return "&&";
3282 case BIT_IOR_EXPR:
3283 return "|";
3285 case TRUTH_XOR_EXPR:
3286 case BIT_XOR_EXPR:
3287 return "^";
3289 case ADDR_EXPR:
3290 case BIT_AND_EXPR:
3291 return "&";
3293 case ORDERED_EXPR:
3294 return "ord";
3295 case UNORDERED_EXPR:
3296 return "unord";
3298 case EQ_EXPR:
3299 return "==";
3300 case UNEQ_EXPR:
3301 return "u==";
3303 case NE_EXPR:
3304 return "!=";
3306 case LT_EXPR:
3307 return "<";
3308 case UNLT_EXPR:
3309 return "u<";
3311 case LE_EXPR:
3312 return "<=";
3313 case UNLE_EXPR:
3314 return "u<=";
3316 case GT_EXPR:
3317 return ">";
3318 case UNGT_EXPR:
3319 return "u>";
3321 case GE_EXPR:
3322 return ">=";
3323 case UNGE_EXPR:
3324 return "u>=";
3326 case LTGT_EXPR:
3327 return "<>";
3329 case LSHIFT_EXPR:
3330 return "<<";
3332 case RSHIFT_EXPR:
3333 return ">>";
3335 case LROTATE_EXPR:
3336 return "r<<";
3338 case RROTATE_EXPR:
3339 return "r>>";
3341 case WIDEN_LSHIFT_EXPR:
3342 return "w<<";
3344 case POINTER_PLUS_EXPR:
3345 return "+";
3347 case PLUS_EXPR:
3348 return "+";
3350 case REDUC_PLUS_EXPR:
3351 return "r+";
3353 case WIDEN_SUM_EXPR:
3354 return "w+";
3356 case WIDEN_MULT_EXPR:
3357 return "w*";
3359 case MULT_HIGHPART_EXPR:
3360 return "h*";
3362 case NEGATE_EXPR:
3363 case MINUS_EXPR:
3364 return "-";
3366 case BIT_NOT_EXPR:
3367 return "~";
3369 case TRUTH_NOT_EXPR:
3370 return "!";
3372 case MULT_EXPR:
3373 case INDIRECT_REF:
3374 return "*";
3376 case TRUNC_DIV_EXPR:
3377 case RDIV_EXPR:
3378 return "/";
3380 case CEIL_DIV_EXPR:
3381 return "/[cl]";
3383 case FLOOR_DIV_EXPR:
3384 return "/[fl]";
3386 case ROUND_DIV_EXPR:
3387 return "/[rd]";
3389 case EXACT_DIV_EXPR:
3390 return "/[ex]";
3392 case TRUNC_MOD_EXPR:
3393 return "%";
3395 case CEIL_MOD_EXPR:
3396 return "%[cl]";
3398 case FLOOR_MOD_EXPR:
3399 return "%[fl]";
3401 case ROUND_MOD_EXPR:
3402 return "%[rd]";
3404 case PREDECREMENT_EXPR:
3405 return " --";
3407 case PREINCREMENT_EXPR:
3408 return " ++";
3410 case POSTDECREMENT_EXPR:
3411 return "-- ";
3413 case POSTINCREMENT_EXPR:
3414 return "++ ";
3416 case MAX_EXPR:
3417 return "max";
3419 case MIN_EXPR:
3420 return "min";
3422 default:
3423 return "<<< ??? >>>";
3427 /* Return the symbol associated with operator OP. */
3429 static const char *
3430 op_symbol (const_tree op)
3432 return op_symbol_code (TREE_CODE (op));
3435 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3436 the gimple_call_fn of a GIMPLE_CALL. */
3438 void
3439 print_call_name (pretty_printer *pp, tree node, int flags)
3441 tree op0 = node;
3443 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3444 op0 = TREE_OPERAND (op0, 0);
3446 again:
3447 switch (TREE_CODE (op0))
3449 case VAR_DECL:
3450 case PARM_DECL:
3451 case FUNCTION_DECL:
3452 dump_function_name (pp, op0, flags);
3453 break;
3455 case ADDR_EXPR:
3456 case INDIRECT_REF:
3457 CASE_CONVERT:
3458 op0 = TREE_OPERAND (op0, 0);
3459 goto again;
3461 case COND_EXPR:
3462 pp_left_paren (pp);
3463 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3464 pp_string (pp, ") ? ");
3465 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3466 pp_string (pp, " : ");
3467 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3468 break;
3470 case ARRAY_REF:
3471 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3472 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3473 else
3474 dump_generic_node (pp, op0, 0, flags, false);
3475 break;
3477 case MEM_REF:
3478 if (integer_zerop (TREE_OPERAND (op0, 1)))
3480 op0 = TREE_OPERAND (op0, 0);
3481 goto again;
3483 /* Fallthru. */
3484 case COMPONENT_REF:
3485 case SSA_NAME:
3486 case OBJ_TYPE_REF:
3487 dump_generic_node (pp, op0, 0, flags, false);
3488 break;
3490 default:
3491 NIY;
3495 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3497 static void
3498 pretty_print_string (pretty_printer *pp, const char *str)
3500 if (str == NULL)
3501 return;
3503 while (*str)
3505 switch (str[0])
3507 case '\b':
3508 pp_string (pp, "\\b");
3509 break;
3511 case '\f':
3512 pp_string (pp, "\\f");
3513 break;
3515 case '\n':
3516 pp_string (pp, "\\n");
3517 break;
3519 case '\r':
3520 pp_string (pp, "\\r");
3521 break;
3523 case '\t':
3524 pp_string (pp, "\\t");
3525 break;
3527 case '\v':
3528 pp_string (pp, "\\v");
3529 break;
3531 case '\\':
3532 pp_string (pp, "\\\\");
3533 break;
3535 case '\"':
3536 pp_string (pp, "\\\"");
3537 break;
3539 case '\'':
3540 pp_string (pp, "\\'");
3541 break;
3543 /* No need to handle \0; the loop terminates on \0. */
3545 case '\1':
3546 pp_string (pp, "\\1");
3547 break;
3549 case '\2':
3550 pp_string (pp, "\\2");
3551 break;
3553 case '\3':
3554 pp_string (pp, "\\3");
3555 break;
3557 case '\4':
3558 pp_string (pp, "\\4");
3559 break;
3561 case '\5':
3562 pp_string (pp, "\\5");
3563 break;
3565 case '\6':
3566 pp_string (pp, "\\6");
3567 break;
3569 case '\7':
3570 pp_string (pp, "\\7");
3571 break;
3573 default:
3574 pp_character (pp, str[0]);
3575 break;
3577 str++;
3581 static void
3582 maybe_init_pretty_print (FILE *file)
3584 if (!tree_pp)
3586 tree_pp = new pretty_printer ();
3587 pp_needs_newline (tree_pp) = true;
3588 pp_translate_identifiers (tree_pp) = false;
3591 tree_pp->buffer->stream = file;
3594 static void
3595 newline_and_indent (pretty_printer *pp, int spc)
3597 pp_newline (pp);
3598 INDENT (spc);
3601 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3602 it can also be used in front ends.
3603 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3606 void
3607 percent_K_format (text_info *text)
3609 tree t = va_arg (*text->args_ptr, tree), block;
3610 text->set_location (0, EXPR_LOCATION (t));
3611 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3612 block = TREE_BLOCK (t);
3613 *pp_ti_abstract_origin (text) = NULL;
3615 if (in_lto_p)
3617 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3618 representing the outermost block of an inlined function.
3619 So walk the BLOCK tree until we hit such a scope. */
3620 while (block
3621 && TREE_CODE (block) == BLOCK)
3623 if (inlined_function_outer_scope_p (block))
3625 *pp_ti_abstract_origin (text) = block;
3626 break;
3628 block = BLOCK_SUPERCONTEXT (block);
3630 return;
3633 while (block
3634 && TREE_CODE (block) == BLOCK
3635 && BLOCK_ABSTRACT_ORIGIN (block))
3637 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3639 while (TREE_CODE (ao) == BLOCK
3640 && BLOCK_ABSTRACT_ORIGIN (ao)
3641 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3642 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3644 if (TREE_CODE (ao) == FUNCTION_DECL)
3646 *pp_ti_abstract_origin (text) = block;
3647 break;
3649 block = BLOCK_SUPERCONTEXT (block);
3653 /* Print the identifier ID to PRETTY-PRINTER. */
3655 void
3656 pp_tree_identifier (pretty_printer *pp, tree id)
3658 if (pp_translate_identifiers (pp))
3660 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3661 pp_append_text (pp, text, text + strlen (text));
3663 else
3664 pp_append_text (pp, IDENTIFIER_POINTER (id),
3665 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3668 /* A helper function that is used to dump function information before the
3669 function dump. */
3671 void
3672 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3674 const char *dname, *aname;
3675 struct cgraph_node *node = cgraph_node::get (fdecl);
3676 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3678 dname = lang_hooks.decl_printable_name (fdecl, 2);
3680 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3681 aname = (IDENTIFIER_POINTER
3682 (DECL_ASSEMBLER_NAME (fdecl)));
3683 else
3684 aname = "<unset-asm-name>";
3686 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3687 dname, aname, fun->funcdef_no);
3688 if (!(flags & TDF_NOUID))
3689 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3690 if (node)
3692 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3693 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3694 node->frequency == NODE_FREQUENCY_HOT
3695 ? " (hot)"
3696 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3697 ? " (unlikely executed)"
3698 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3699 ? " (executed once)"
3700 : "");
3702 else
3703 fprintf (dump_file, ")\n\n");
3706 /* Dump double_int D to pretty_printer PP. UNS is true
3707 if D is unsigned and false otherwise. */
3708 void
3709 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3711 if (d.fits_shwi ())
3712 pp_wide_integer (pp, d.low);
3713 else if (d.fits_uhwi ())
3714 pp_unsigned_wide_integer (pp, d.low);
3715 else
3717 unsigned HOST_WIDE_INT low = d.low;
3718 HOST_WIDE_INT high = d.high;
3719 if (!uns && d.is_negative ())
3721 pp_minus (pp);
3722 high = ~high + !low;
3723 low = -low;
3725 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3726 systems? */
3727 sprintf (pp_buffer (pp)->digit_buffer,
3728 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3729 (unsigned HOST_WIDE_INT) high, low);
3730 pp_string (pp, pp_buffer (pp)->digit_buffer);