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