gcc/
[official-gcc.git] / gcc / tree-pretty-print.c
blobbbdb38de10db66e7fe0a670f4afe6a2abeafcd50
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "output.h"
28 #include "tree-pretty-print.h"
29 #include "hashtab.h"
30 #include "tree-flow.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "tree-chrec.h"
34 #include "tree-pass.h"
35 #include "value-prof.h"
36 #include "predict.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree);
40 static void pretty_print_string (pretty_printer *, const char*);
41 static void newline_and_indent (pretty_printer *, int);
42 static void maybe_init_pretty_print (FILE *);
43 static void print_struct_decl (pretty_printer *, const_tree, int, int);
44 static void do_niy (pretty_printer *, const_tree);
46 #define INDENT(SPACE) do { \
47 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
49 #define NIY do_niy(buffer,node)
51 static pretty_printer buffer;
52 static int initialized = 0;
54 /* Try to print something for an unknown tree code. */
56 static void
57 do_niy (pretty_printer *buffer, const_tree node)
59 int i, len;
61 pp_string (buffer, "<<< Unknown tree: ");
62 pp_string (buffer, tree_code_name[(int) TREE_CODE (node)]);
64 if (EXPR_P (node))
66 len = TREE_OPERAND_LENGTH (node);
67 for (i = 0; i < len; ++i)
69 newline_and_indent (buffer, 2);
70 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
74 pp_string (buffer, " >>>\n");
77 /* Debugging function to print out a generic expression. */
79 DEBUG_FUNCTION void
80 debug_generic_expr (tree t)
82 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
83 fprintf (stderr, "\n");
86 /* Debugging function to print out a generic statement. */
88 DEBUG_FUNCTION void
89 debug_generic_stmt (tree t)
91 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
92 fprintf (stderr, "\n");
95 /* Debugging function to print out a chain of trees . */
97 DEBUG_FUNCTION void
98 debug_tree_chain (tree t)
100 struct pointer_set_t *seen = pointer_set_create ();
102 while (t)
104 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
105 fprintf (stderr, " ");
106 t = TREE_CHAIN (t);
107 if (pointer_set_insert (seen, t))
109 fprintf (stderr, "... [cycled back to ");
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
111 fprintf (stderr, "]");
112 break;
115 fprintf (stderr, "\n");
117 pointer_set_destroy (seen);
120 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
121 void
122 print_generic_decl (FILE *file, tree decl, int flags)
124 maybe_init_pretty_print (file);
125 print_declaration (&buffer, decl, 2, flags);
126 pp_write_text_to_stream (&buffer);
129 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
130 to show in the dump. See TDF_* in tree-pass.h. */
132 void
133 print_generic_stmt (FILE *file, tree t, int flags)
135 maybe_init_pretty_print (file);
136 dump_generic_node (&buffer, t, 0, flags, true);
137 pp_flush (&buffer);
140 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
141 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
142 INDENT spaces. */
144 void
145 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
147 int i;
149 maybe_init_pretty_print (file);
151 for (i = 0; i < indent; i++)
152 pp_space (&buffer);
153 dump_generic_node (&buffer, t, indent, flags, true);
154 pp_flush (&buffer);
157 /* Print a single expression T on file FILE. FLAGS specifies details to show
158 in the dump. See TDF_* in tree-pass.h. */
160 void
161 print_generic_expr (FILE *file, tree t, int flags)
163 maybe_init_pretty_print (file);
164 dump_generic_node (&buffer, t, 0, flags, false);
167 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
168 in FLAGS. */
170 static void
171 dump_decl_name (pretty_printer *buffer, tree node, int flags)
173 if (DECL_NAME (node))
175 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
176 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
177 else
178 pp_tree_identifier (buffer, DECL_NAME (node));
180 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
182 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
183 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
184 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
186 if (flags & TDF_NOUID)
187 pp_string (buffer, "D#xxxx");
188 else
189 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
191 else
193 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
194 if (flags & TDF_NOUID)
195 pp_printf (buffer, "%c.xxxx", c);
196 else
197 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
200 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
202 if (flags & TDF_NOUID)
203 pp_printf (buffer, "ptD.xxxx");
204 else
205 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
209 /* Like the above, but used for pretty printing function calls. */
211 static void
212 dump_function_name (pretty_printer *buffer, tree node, int flags)
214 if (TREE_CODE (node) == NOP_EXPR)
215 node = TREE_OPERAND (node, 0);
216 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
217 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
218 else
219 dump_decl_name (buffer, node, flags);
222 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
223 FLAGS are as in dump_generic_node. */
225 static void
226 dump_function_declaration (pretty_printer *buffer, tree node,
227 int spc, int flags)
229 bool wrote_arg = false;
230 tree arg;
232 pp_space (buffer);
233 pp_character (buffer, '(');
235 /* Print the argument types. The last element in the list is a VOID_TYPE.
236 The following avoids printing the last element. */
237 arg = TYPE_ARG_TYPES (node);
238 while (arg && TREE_CHAIN (arg) && arg != error_mark_node)
240 wrote_arg = true;
241 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
242 arg = TREE_CHAIN (arg);
243 if (TREE_CHAIN (arg) && TREE_CODE (TREE_CHAIN (arg)) == TREE_LIST)
245 pp_character (buffer, ',');
246 pp_space (buffer);
250 if (!wrote_arg)
251 pp_string (buffer, "void");
253 pp_character (buffer, ')');
256 /* Dump the domain associated with an array. */
258 static void
259 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
261 pp_character (buffer, '[');
262 if (domain)
264 tree min = TYPE_MIN_VALUE (domain);
265 tree max = TYPE_MAX_VALUE (domain);
267 if (min && max
268 && integer_zerop (min)
269 && host_integerp (max, 0))
270 pp_wide_integer (buffer, TREE_INT_CST_LOW (max) + 1);
271 else
273 if (min)
274 dump_generic_node (buffer, min, spc, flags, false);
275 pp_character (buffer, ':');
276 if (max)
277 dump_generic_node (buffer, max, spc, flags, false);
280 else
281 pp_string (buffer, "<unknown>");
282 pp_character (buffer, ']');
286 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
287 dump_generic_node. */
289 static void
290 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
292 const char *name;
294 switch (OMP_CLAUSE_CODE (clause))
296 case OMP_CLAUSE_PRIVATE:
297 name = "private";
298 goto print_remap;
299 case OMP_CLAUSE_SHARED:
300 name = "shared";
301 goto print_remap;
302 case OMP_CLAUSE_FIRSTPRIVATE:
303 name = "firstprivate";
304 goto print_remap;
305 case OMP_CLAUSE_LASTPRIVATE:
306 name = "lastprivate";
307 goto print_remap;
308 case OMP_CLAUSE_COPYIN:
309 name = "copyin";
310 goto print_remap;
311 case OMP_CLAUSE_COPYPRIVATE:
312 name = "copyprivate";
313 goto print_remap;
314 print_remap:
315 pp_string (buffer, name);
316 pp_character (buffer, '(');
317 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
318 spc, flags, false);
319 pp_character (buffer, ')');
320 break;
322 case OMP_CLAUSE_REDUCTION:
323 pp_string (buffer, "reduction(");
324 pp_string (buffer, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
325 pp_character (buffer, ':');
326 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
327 spc, flags, false);
328 pp_character (buffer, ')');
329 break;
331 case OMP_CLAUSE_IF:
332 pp_string (buffer, "if(");
333 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
334 spc, flags, false);
335 pp_character (buffer, ')');
336 break;
338 case OMP_CLAUSE_NUM_THREADS:
339 pp_string (buffer, "num_threads(");
340 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
341 spc, flags, false);
342 pp_character (buffer, ')');
343 break;
345 case OMP_CLAUSE_NOWAIT:
346 pp_string (buffer, "nowait");
347 break;
348 case OMP_CLAUSE_ORDERED:
349 pp_string (buffer, "ordered");
350 break;
352 case OMP_CLAUSE_DEFAULT:
353 pp_string (buffer, "default(");
354 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
356 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
357 break;
358 case OMP_CLAUSE_DEFAULT_SHARED:
359 pp_string (buffer, "shared");
360 break;
361 case OMP_CLAUSE_DEFAULT_NONE:
362 pp_string (buffer, "none");
363 break;
364 case OMP_CLAUSE_DEFAULT_PRIVATE:
365 pp_string (buffer, "private");
366 break;
367 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
368 pp_string (buffer, "firstprivate");
369 break;
370 default:
371 gcc_unreachable ();
373 pp_character (buffer, ')');
374 break;
376 case OMP_CLAUSE_SCHEDULE:
377 pp_string (buffer, "schedule(");
378 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
380 case OMP_CLAUSE_SCHEDULE_STATIC:
381 pp_string (buffer, "static");
382 break;
383 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
384 pp_string (buffer, "dynamic");
385 break;
386 case OMP_CLAUSE_SCHEDULE_GUIDED:
387 pp_string (buffer, "guided");
388 break;
389 case OMP_CLAUSE_SCHEDULE_RUNTIME:
390 pp_string (buffer, "runtime");
391 break;
392 case OMP_CLAUSE_SCHEDULE_AUTO:
393 pp_string (buffer, "auto");
394 break;
395 default:
396 gcc_unreachable ();
398 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
400 pp_character (buffer, ',');
401 dump_generic_node (buffer,
402 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
403 spc, flags, false);
405 pp_character (buffer, ')');
406 break;
408 case OMP_CLAUSE_UNTIED:
409 pp_string (buffer, "untied");
410 break;
412 case OMP_CLAUSE_COLLAPSE:
413 pp_string (buffer, "collapse(");
414 dump_generic_node (buffer,
415 OMP_CLAUSE_COLLAPSE_EXPR (clause),
416 spc, flags, false);
417 pp_character (buffer, ')');
418 break;
420 default:
421 /* Should never happen. */
422 dump_generic_node (buffer, clause, spc, flags, false);
423 break;
428 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
429 dump_generic_node. */
431 void
432 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
434 if (clause == NULL)
435 return;
437 pp_space (buffer);
438 while (1)
440 dump_omp_clause (buffer, clause, spc, flags);
441 clause = OMP_CLAUSE_CHAIN (clause);
442 if (clause == NULL)
443 return;
444 pp_space (buffer);
449 /* Dump location LOC to BUFFER. */
451 static void
452 dump_location (pretty_printer *buffer, location_t loc)
454 expanded_location xloc = expand_location (loc);
456 pp_character (buffer, '[');
457 if (xloc.file)
459 pp_string (buffer, xloc.file);
460 pp_string (buffer, " : ");
462 pp_decimal_int (buffer, xloc.line);
463 pp_string (buffer, "] ");
467 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
468 dump_generic_node. */
470 static void
471 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
473 tree t;
475 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
477 if (flags & TDF_ADDRESS)
478 pp_printf (buffer, "[%p] ", (void *) block);
480 if (BLOCK_ABSTRACT (block))
481 pp_string (buffer, "[abstract] ");
483 if (TREE_ASM_WRITTEN (block))
484 pp_string (buffer, "[written] ");
486 if (flags & TDF_SLIM)
487 return;
489 if (BLOCK_SOURCE_LOCATION (block))
490 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
492 newline_and_indent (buffer, spc + 2);
494 if (BLOCK_SUPERCONTEXT (block))
496 pp_string (buffer, "SUPERCONTEXT: ");
497 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
498 flags | TDF_SLIM, false);
499 newline_and_indent (buffer, spc + 2);
502 if (BLOCK_SUBBLOCKS (block))
504 pp_string (buffer, "SUBBLOCKS: ");
505 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
507 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
508 pp_string (buffer, " ");
510 newline_and_indent (buffer, spc + 2);
513 if (BLOCK_CHAIN (block))
515 pp_string (buffer, "SIBLINGS: ");
516 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
518 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
519 pp_string (buffer, " ");
521 newline_and_indent (buffer, spc + 2);
524 if (BLOCK_VARS (block))
526 pp_string (buffer, "VARS: ");
527 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
529 dump_generic_node (buffer, t, 0, flags, false);
530 pp_string (buffer, " ");
532 newline_and_indent (buffer, spc + 2);
535 if (VEC_length (tree, BLOCK_NONLOCALIZED_VARS (block)) > 0)
537 unsigned i;
538 VEC(tree,gc) *nlv = BLOCK_NONLOCALIZED_VARS (block);
540 pp_string (buffer, "NONLOCALIZED_VARS: ");
541 for (i = 0; VEC_iterate (tree, nlv, i, t); i++)
543 dump_generic_node (buffer, t, 0, flags, false);
544 pp_string (buffer, " ");
546 newline_and_indent (buffer, spc + 2);
549 if (BLOCK_ABSTRACT_ORIGIN (block))
551 pp_string (buffer, "ABSTRACT_ORIGIN: ");
552 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
553 flags | TDF_SLIM, false);
554 newline_and_indent (buffer, spc + 2);
557 if (BLOCK_FRAGMENT_ORIGIN (block))
559 pp_string (buffer, "FRAGMENT_ORIGIN: ");
560 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
561 flags | TDF_SLIM, false);
562 newline_and_indent (buffer, spc + 2);
565 if (BLOCK_FRAGMENT_CHAIN (block))
567 pp_string (buffer, "FRAGMENT_CHAIN: ");
568 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
570 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
571 pp_string (buffer, " ");
573 newline_and_indent (buffer, spc + 2);
578 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
579 indent. FLAGS specifies details to show in the dump (see TDF_* in
580 tree-pass.h). If IS_STMT is true, the object printed is considered
581 to be a statement and it is terminated by ';' if appropriate. */
584 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
585 bool is_stmt)
587 tree type;
588 tree op0, op1;
589 const char *str;
590 bool is_expr;
592 if (node == NULL_TREE)
593 return spc;
595 is_expr = EXPR_P (node);
597 if (is_stmt && (flags & TDF_STMTADDR))
598 pp_printf (buffer, "<&%p> ", (void *)node);
600 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
601 dump_location (buffer, EXPR_LOCATION (node));
603 switch (TREE_CODE (node))
605 case ERROR_MARK:
606 pp_string (buffer, "<<< error >>>");
607 break;
609 case IDENTIFIER_NODE:
610 pp_tree_identifier (buffer, node);
611 break;
613 case TREE_LIST:
614 while (node && node != error_mark_node)
616 if (TREE_PURPOSE (node))
618 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
619 pp_space (buffer);
621 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
622 node = TREE_CHAIN (node);
623 if (node && TREE_CODE (node) == TREE_LIST)
625 pp_character (buffer, ',');
626 pp_space (buffer);
629 break;
631 case TREE_BINFO:
632 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
633 break;
635 case TREE_VEC:
637 size_t i;
638 if (TREE_VEC_LENGTH (node) > 0)
640 size_t len = TREE_VEC_LENGTH (node);
641 for (i = 0; i < len - 1; i++)
643 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
644 false);
645 pp_character (buffer, ',');
646 pp_space (buffer);
648 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
649 flags, false);
652 break;
654 case VOID_TYPE:
655 case INTEGER_TYPE:
656 case REAL_TYPE:
657 case FIXED_POINT_TYPE:
658 case COMPLEX_TYPE:
659 case VECTOR_TYPE:
660 case ENUMERAL_TYPE:
661 case BOOLEAN_TYPE:
663 unsigned int quals = TYPE_QUALS (node);
664 enum tree_code_class tclass;
666 if (quals & TYPE_QUAL_CONST)
667 pp_string (buffer, "const ");
668 else if (quals & TYPE_QUAL_VOLATILE)
669 pp_string (buffer, "volatile ");
670 else if (quals & TYPE_QUAL_RESTRICT)
671 pp_string (buffer, "restrict ");
673 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
675 pp_string (buffer, "<address-space-");
676 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
677 pp_string (buffer, "> ");
680 tclass = TREE_CODE_CLASS (TREE_CODE (node));
682 if (tclass == tcc_declaration)
684 if (DECL_NAME (node))
685 dump_decl_name (buffer, node, flags);
686 else
687 pp_string (buffer, "<unnamed type decl>");
689 else if (tclass == tcc_type)
691 if (TYPE_NAME (node))
693 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
694 pp_tree_identifier (buffer, TYPE_NAME (node));
695 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
696 && DECL_NAME (TYPE_NAME (node)))
697 dump_decl_name (buffer, TYPE_NAME (node), flags);
698 else
699 pp_string (buffer, "<unnamed type>");
701 else if (TREE_CODE (node) == VECTOR_TYPE)
703 pp_string (buffer, "vector");
704 pp_character (buffer, '(');
705 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
706 pp_string (buffer, ") ");
707 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
709 else if (TREE_CODE (node) == INTEGER_TYPE)
711 pp_string (buffer, (TYPE_UNSIGNED (node)
712 ? "<unnamed-unsigned:"
713 : "<unnamed-signed:"));
714 pp_decimal_int (buffer, TYPE_PRECISION (node));
715 pp_string (buffer, ">");
717 else if (TREE_CODE (node) == COMPLEX_TYPE)
719 pp_string (buffer, "__complex__ ");
720 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
722 else if (TREE_CODE (node) == REAL_TYPE)
724 pp_string (buffer, "<float:");
725 pp_decimal_int (buffer, TYPE_PRECISION (node));
726 pp_string (buffer, ">");
728 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
730 pp_string (buffer, "<fixed-point-");
731 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
732 pp_decimal_int (buffer, TYPE_PRECISION (node));
733 pp_string (buffer, ">");
735 else
736 pp_string (buffer, "<unnamed type>");
738 break;
741 case POINTER_TYPE:
742 case REFERENCE_TYPE:
743 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
745 if (TREE_TYPE (node) == NULL)
747 pp_string (buffer, str);
748 pp_string (buffer, "<null type>");
750 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
752 tree fnode = TREE_TYPE (node);
754 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
755 pp_space (buffer);
756 pp_character (buffer, '(');
757 pp_string (buffer, str);
758 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
759 dump_decl_name (buffer, TYPE_NAME (node), flags);
760 else
761 pp_printf (buffer, "<T%x>", TYPE_UID (node));
763 pp_character (buffer, ')');
764 dump_function_declaration (buffer, fnode, spc, flags);
766 else
768 unsigned int quals = TYPE_QUALS (node);
770 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
771 pp_space (buffer);
772 pp_string (buffer, str);
774 if (quals & TYPE_QUAL_CONST)
775 pp_string (buffer, " const");
776 if (quals & TYPE_QUAL_VOLATILE)
777 pp_string (buffer, " volatile");
778 if (quals & TYPE_QUAL_RESTRICT)
779 pp_string (buffer, " restrict");
781 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
783 pp_string (buffer, " <address-space-");
784 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
785 pp_string (buffer, ">");
788 if (TYPE_REF_CAN_ALIAS_ALL (node))
789 pp_string (buffer, " {ref-all}");
791 break;
793 case OFFSET_TYPE:
794 NIY;
795 break;
797 case TARGET_MEM_REF:
799 const char *sep = "";
800 tree tmp;
802 pp_string (buffer, "MEM[");
804 tmp = TMR_SYMBOL (node);
805 if (tmp)
807 pp_string (buffer, sep);
808 sep = ", ";
809 pp_string (buffer, "symbol: ");
810 dump_generic_node (buffer, tmp, spc, flags, false);
812 tmp = TMR_BASE (node);
813 if (tmp)
815 pp_string (buffer, sep);
816 sep = ", ";
817 pp_string (buffer, "base: ");
818 dump_generic_node (buffer, tmp, spc, flags, false);
820 tmp = TMR_INDEX (node);
821 if (tmp)
823 pp_string (buffer, sep);
824 sep = ", ";
825 pp_string (buffer, "index: ");
826 dump_generic_node (buffer, tmp, spc, flags, false);
828 tmp = TMR_STEP (node);
829 if (tmp)
831 pp_string (buffer, sep);
832 sep = ", ";
833 pp_string (buffer, "step: ");
834 dump_generic_node (buffer, tmp, spc, flags, false);
836 tmp = TMR_OFFSET (node);
837 if (tmp)
839 pp_string (buffer, sep);
840 sep = ", ";
841 pp_string (buffer, "offset: ");
842 dump_generic_node (buffer, tmp, spc, flags, false);
844 pp_string (buffer, "]");
845 if (flags & TDF_DETAILS)
847 pp_string (buffer, "{");
848 dump_generic_node (buffer, TMR_ORIGINAL (node), spc, flags,
849 false);
850 pp_string (buffer, "}");
853 break;
855 case ARRAY_TYPE:
857 tree tmp;
859 /* Print the innermost component type. */
860 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
861 tmp = TREE_TYPE (tmp))
863 dump_generic_node (buffer, tmp, spc, flags, false);
865 /* Print the dimensions. */
866 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
867 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
868 break;
871 case RECORD_TYPE:
872 case UNION_TYPE:
873 case QUAL_UNION_TYPE:
875 unsigned int quals = TYPE_QUALS (node);
877 if (quals & TYPE_QUAL_CONST)
878 pp_string (buffer, "const ");
879 if (quals & TYPE_QUAL_VOLATILE)
880 pp_string (buffer, "volatile ");
882 /* Print the name of the structure. */
883 if (TREE_CODE (node) == RECORD_TYPE)
884 pp_string (buffer, "struct ");
885 else if (TREE_CODE (node) == UNION_TYPE)
886 pp_string (buffer, "union ");
888 if (TYPE_NAME (node))
889 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
890 else if (!(flags & TDF_SLIM))
891 /* FIXME: If we eliminate the 'else' above and attempt
892 to show the fields for named types, we may get stuck
893 following a cycle of pointers to structs. The alleged
894 self-reference check in print_struct_decl will not detect
895 cycles involving more than one pointer or struct type. */
896 print_struct_decl (buffer, node, spc, flags);
897 break;
900 case LANG_TYPE:
901 NIY;
902 break;
904 case INTEGER_CST:
905 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
907 /* In the case of a pointer, one may want to divide by the
908 size of the pointed-to type. Unfortunately, this not
909 straightforward. The C front-end maps expressions
911 (int *) 5
912 int *p; (p + 5)
914 in such a way that the two INTEGER_CST nodes for "5" have
915 different values but identical types. In the latter
916 case, the 5 is multiplied by sizeof (int) in c-common.c
917 (pointer_int_sum) to convert it to a byte address, and
918 yet the type of the node is left unchanged. Argh. What
919 is consistent though is that the number value corresponds
920 to bytes (UNITS) offset.
922 NB: Neither of the following divisors can be trivially
923 used to recover the original literal:
925 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
926 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
927 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
928 pp_string (buffer, "B"); /* pseudo-unit */
930 else if (! host_integerp (node, 0))
932 tree val = node;
933 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val);
934 HOST_WIDE_INT high = TREE_INT_CST_HIGH (val);
936 if (tree_int_cst_sgn (val) < 0)
938 pp_character (buffer, '-');
939 high = ~high + !low;
940 low = -low;
942 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
943 systems? */
944 sprintf (pp_buffer (buffer)->digit_buffer,
945 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
946 (unsigned HOST_WIDE_INT) high, low);
947 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
949 else
950 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
951 break;
953 case REAL_CST:
954 /* Code copied from print_node. */
956 REAL_VALUE_TYPE d;
957 if (TREE_OVERFLOW (node))
958 pp_string (buffer, " overflow");
960 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
961 d = TREE_REAL_CST (node);
962 if (REAL_VALUE_ISINF (d))
963 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
964 else if (REAL_VALUE_ISNAN (d))
965 pp_string (buffer, " Nan");
966 else
968 char string[100];
969 real_to_decimal (string, &d, sizeof (string), 0, 1);
970 pp_string (buffer, string);
972 #else
974 HOST_WIDE_INT i;
975 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
976 pp_string (buffer, "0x");
977 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
978 output_formatted_integer (buffer, "%02x", *p++);
980 #endif
981 break;
984 case FIXED_CST:
986 char string[100];
987 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
988 pp_string (buffer, string);
989 break;
992 case COMPLEX_CST:
993 pp_string (buffer, "__complex__ (");
994 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
995 pp_string (buffer, ", ");
996 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
997 pp_string (buffer, ")");
998 break;
1000 case STRING_CST:
1001 pp_string (buffer, "\"");
1002 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1003 pp_string (buffer, "\"");
1004 break;
1006 case VECTOR_CST:
1008 tree elt;
1009 pp_string (buffer, "{ ");
1010 for (elt = TREE_VECTOR_CST_ELTS (node); elt; elt = TREE_CHAIN (elt))
1012 dump_generic_node (buffer, TREE_VALUE (elt), spc, flags, false);
1013 if (TREE_CHAIN (elt))
1014 pp_string (buffer, ", ");
1016 pp_string (buffer, " }");
1018 break;
1020 case FUNCTION_TYPE:
1021 case METHOD_TYPE:
1022 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1023 pp_space (buffer);
1024 if (TREE_CODE (node) == METHOD_TYPE)
1026 if (TYPE_METHOD_BASETYPE (node))
1027 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1028 flags);
1029 else
1030 pp_string (buffer, "<null method basetype>");
1031 pp_string (buffer, "::");
1033 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1034 dump_decl_name (buffer, TYPE_NAME (node), flags);
1035 else
1036 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1037 dump_function_declaration (buffer, node, spc, flags);
1038 break;
1040 case FUNCTION_DECL:
1041 case CONST_DECL:
1042 dump_decl_name (buffer, node, flags);
1043 break;
1045 case LABEL_DECL:
1046 if (DECL_NAME (node))
1047 dump_decl_name (buffer, node, flags);
1048 else if (LABEL_DECL_UID (node) != -1)
1049 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1050 else
1052 if (flags & TDF_NOUID)
1053 pp_string (buffer, "<D.xxxx>");
1054 else
1055 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1057 break;
1059 case TYPE_DECL:
1060 if (DECL_IS_BUILTIN (node))
1062 /* Don't print the declaration of built-in types. */
1063 break;
1065 if (DECL_NAME (node))
1066 dump_decl_name (buffer, node, flags);
1067 else
1069 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1070 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1071 && TYPE_METHODS (TREE_TYPE (node)))
1073 /* The type is a c++ class: all structures have at least
1074 4 methods. */
1075 pp_string (buffer, "class ");
1076 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1078 else
1080 pp_string (buffer,
1081 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1082 ? "union" : "struct "));
1083 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1086 break;
1088 case VAR_DECL:
1089 case PARM_DECL:
1090 case FIELD_DECL:
1091 case DEBUG_EXPR_DECL:
1092 case NAMESPACE_DECL:
1093 dump_decl_name (buffer, node, flags);
1094 break;
1096 case RESULT_DECL:
1097 pp_string (buffer, "<retval>");
1098 break;
1100 case COMPONENT_REF:
1101 op0 = TREE_OPERAND (node, 0);
1102 str = ".";
1103 if (op0 && TREE_CODE (op0) == INDIRECT_REF)
1105 op0 = TREE_OPERAND (op0, 0);
1106 str = "->";
1108 if (op_prio (op0) < op_prio (node))
1109 pp_character (buffer, '(');
1110 dump_generic_node (buffer, op0, spc, flags, false);
1111 if (op_prio (op0) < op_prio (node))
1112 pp_character (buffer, ')');
1113 pp_string (buffer, str);
1114 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1115 op0 = component_ref_field_offset (node);
1116 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1118 pp_string (buffer, "{off: ");
1119 dump_generic_node (buffer, op0, spc, flags, false);
1120 pp_character (buffer, '}');
1122 break;
1124 case BIT_FIELD_REF:
1125 pp_string (buffer, "BIT_FIELD_REF <");
1126 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1127 pp_string (buffer, ", ");
1128 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1129 pp_string (buffer, ", ");
1130 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1131 pp_string (buffer, ">");
1132 break;
1134 case ARRAY_REF:
1135 case ARRAY_RANGE_REF:
1136 op0 = TREE_OPERAND (node, 0);
1137 if (op_prio (op0) < op_prio (node))
1138 pp_character (buffer, '(');
1139 dump_generic_node (buffer, op0, spc, flags, false);
1140 if (op_prio (op0) < op_prio (node))
1141 pp_character (buffer, ')');
1142 pp_character (buffer, '[');
1143 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1144 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1145 pp_string (buffer, " ...");
1146 pp_character (buffer, ']');
1148 op0 = array_ref_low_bound (node);
1149 op1 = array_ref_element_size (node);
1151 if (!integer_zerop (op0)
1152 || TREE_OPERAND (node, 2)
1153 || TREE_OPERAND (node, 3))
1155 pp_string (buffer, "{lb: ");
1156 dump_generic_node (buffer, op0, spc, flags, false);
1157 pp_string (buffer, " sz: ");
1158 dump_generic_node (buffer, op1, spc, flags, false);
1159 pp_character (buffer, '}');
1161 break;
1163 case CONSTRUCTOR:
1165 unsigned HOST_WIDE_INT ix;
1166 tree field, val;
1167 bool is_struct_init = FALSE;
1168 pp_character (buffer, '{');
1169 if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1170 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1171 is_struct_init = TRUE;
1172 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1174 if (field && is_struct_init)
1176 pp_character (buffer, '.');
1177 dump_generic_node (buffer, field, spc, flags, false);
1178 pp_string (buffer, "=");
1180 if (val && TREE_CODE (val) == ADDR_EXPR)
1181 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1182 val = TREE_OPERAND (val, 0);
1183 if (val && TREE_CODE (val) == FUNCTION_DECL)
1184 dump_decl_name (buffer, val, flags);
1185 else
1186 dump_generic_node (buffer, val, spc, flags, false);
1187 if (ix != VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node)) - 1)
1189 pp_character (buffer, ',');
1190 pp_space (buffer);
1193 pp_character (buffer, '}');
1195 break;
1197 case COMPOUND_EXPR:
1199 tree *tp;
1200 if (flags & TDF_SLIM)
1202 pp_string (buffer, "<COMPOUND_EXPR>");
1203 break;
1206 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1207 spc, flags, !(flags & TDF_SLIM));
1208 if (flags & TDF_SLIM)
1209 newline_and_indent (buffer, spc);
1210 else
1212 pp_character (buffer, ',');
1213 pp_space (buffer);
1216 for (tp = &TREE_OPERAND (node, 1);
1217 TREE_CODE (*tp) == COMPOUND_EXPR;
1218 tp = &TREE_OPERAND (*tp, 1))
1220 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1221 spc, flags, !(flags & TDF_SLIM));
1222 if (flags & TDF_SLIM)
1223 newline_and_indent (buffer, spc);
1224 else
1226 pp_character (buffer, ',');
1227 pp_space (buffer);
1231 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1233 break;
1235 case STATEMENT_LIST:
1237 tree_stmt_iterator si;
1238 bool first = true;
1240 if (flags & TDF_SLIM)
1242 pp_string (buffer, "<STATEMENT_LIST>");
1243 break;
1246 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1248 if (!first)
1249 newline_and_indent (buffer, spc);
1250 else
1251 first = false;
1252 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1255 break;
1257 case MODIFY_EXPR:
1258 case INIT_EXPR:
1259 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1260 false);
1261 pp_space (buffer);
1262 pp_character (buffer, '=');
1263 if (TREE_CODE (node) == MODIFY_EXPR
1264 && MOVE_NONTEMPORAL (node))
1265 pp_string (buffer, "{nt}");
1266 pp_space (buffer);
1267 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1268 false);
1269 break;
1271 case TARGET_EXPR:
1272 pp_string (buffer, "TARGET_EXPR <");
1273 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1274 pp_character (buffer, ',');
1275 pp_space (buffer);
1276 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1277 pp_character (buffer, '>');
1278 break;
1280 case DECL_EXPR:
1281 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1282 is_stmt = false;
1283 break;
1285 case COND_EXPR:
1286 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1288 pp_string (buffer, "if (");
1289 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1290 pp_character (buffer, ')');
1291 /* The lowered cond_exprs should always be printed in full. */
1292 if (COND_EXPR_THEN (node)
1293 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1294 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1295 && COND_EXPR_ELSE (node)
1296 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1297 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1299 pp_space (buffer);
1300 dump_generic_node (buffer, COND_EXPR_THEN (node),
1301 0, flags, true);
1302 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1304 pp_string (buffer, " else ");
1305 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1306 0, flags, true);
1309 else if (!(flags & TDF_SLIM))
1311 /* Output COND_EXPR_THEN. */
1312 if (COND_EXPR_THEN (node))
1314 newline_and_indent (buffer, spc+2);
1315 pp_character (buffer, '{');
1316 newline_and_indent (buffer, spc+4);
1317 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1318 flags, true);
1319 newline_and_indent (buffer, spc+2);
1320 pp_character (buffer, '}');
1323 /* Output COND_EXPR_ELSE. */
1324 if (COND_EXPR_ELSE (node)
1325 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1327 newline_and_indent (buffer, spc);
1328 pp_string (buffer, "else");
1329 newline_and_indent (buffer, spc+2);
1330 pp_character (buffer, '{');
1331 newline_and_indent (buffer, spc+4);
1332 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1333 flags, true);
1334 newline_and_indent (buffer, spc+2);
1335 pp_character (buffer, '}');
1338 is_expr = false;
1340 else
1342 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1343 pp_space (buffer);
1344 pp_character (buffer, '?');
1345 pp_space (buffer);
1346 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1347 pp_space (buffer);
1348 pp_character (buffer, ':');
1349 pp_space (buffer);
1350 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1352 break;
1354 case BIND_EXPR:
1355 pp_character (buffer, '{');
1356 if (!(flags & TDF_SLIM))
1358 if (BIND_EXPR_VARS (node))
1360 pp_newline (buffer);
1362 for (op0 = BIND_EXPR_VARS (node); op0; op0 = TREE_CHAIN (op0))
1364 print_declaration (buffer, op0, spc+2, flags);
1365 pp_newline (buffer);
1369 newline_and_indent (buffer, spc+2);
1370 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1371 newline_and_indent (buffer, spc);
1372 pp_character (buffer, '}');
1374 is_expr = false;
1375 break;
1377 case CALL_EXPR:
1378 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1380 /* Print parameters. */
1381 pp_space (buffer);
1382 pp_character (buffer, '(');
1384 tree arg;
1385 call_expr_arg_iterator iter;
1386 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1388 dump_generic_node (buffer, arg, spc, flags, false);
1389 if (more_call_expr_args_p (&iter))
1391 pp_character (buffer, ',');
1392 pp_space (buffer);
1396 if (CALL_EXPR_VA_ARG_PACK (node))
1398 if (call_expr_nargs (node) > 0)
1400 pp_character (buffer, ',');
1401 pp_space (buffer);
1403 pp_string (buffer, "__builtin_va_arg_pack ()");
1405 pp_character (buffer, ')');
1407 op1 = CALL_EXPR_STATIC_CHAIN (node);
1408 if (op1)
1410 pp_string (buffer, " [static-chain: ");
1411 dump_generic_node (buffer, op1, spc, flags, false);
1412 pp_character (buffer, ']');
1415 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1416 pp_string (buffer, " [return slot optimization]");
1417 if (CALL_EXPR_TAILCALL (node))
1418 pp_string (buffer, " [tail call]");
1419 break;
1421 case WITH_CLEANUP_EXPR:
1422 NIY;
1423 break;
1425 case CLEANUP_POINT_EXPR:
1426 pp_string (buffer, "<<cleanup_point ");
1427 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1428 pp_string (buffer, ">>");
1429 break;
1431 case PLACEHOLDER_EXPR:
1432 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1433 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1434 pp_character (buffer, '>');
1435 break;
1437 /* Binary arithmetic and logic expressions. */
1438 case WIDEN_SUM_EXPR:
1439 case WIDEN_MULT_EXPR:
1440 case MULT_EXPR:
1441 case PLUS_EXPR:
1442 case POINTER_PLUS_EXPR:
1443 case MINUS_EXPR:
1444 case TRUNC_DIV_EXPR:
1445 case CEIL_DIV_EXPR:
1446 case FLOOR_DIV_EXPR:
1447 case ROUND_DIV_EXPR:
1448 case TRUNC_MOD_EXPR:
1449 case CEIL_MOD_EXPR:
1450 case FLOOR_MOD_EXPR:
1451 case ROUND_MOD_EXPR:
1452 case RDIV_EXPR:
1453 case EXACT_DIV_EXPR:
1454 case LSHIFT_EXPR:
1455 case RSHIFT_EXPR:
1456 case LROTATE_EXPR:
1457 case RROTATE_EXPR:
1458 case VEC_LSHIFT_EXPR:
1459 case VEC_RSHIFT_EXPR:
1460 case BIT_IOR_EXPR:
1461 case BIT_XOR_EXPR:
1462 case BIT_AND_EXPR:
1463 case TRUTH_ANDIF_EXPR:
1464 case TRUTH_ORIF_EXPR:
1465 case TRUTH_AND_EXPR:
1466 case TRUTH_OR_EXPR:
1467 case TRUTH_XOR_EXPR:
1468 case LT_EXPR:
1469 case LE_EXPR:
1470 case GT_EXPR:
1471 case GE_EXPR:
1472 case EQ_EXPR:
1473 case NE_EXPR:
1474 case UNLT_EXPR:
1475 case UNLE_EXPR:
1476 case UNGT_EXPR:
1477 case UNGE_EXPR:
1478 case UNEQ_EXPR:
1479 case LTGT_EXPR:
1480 case ORDERED_EXPR:
1481 case UNORDERED_EXPR:
1483 const char *op = op_symbol (node);
1484 op0 = TREE_OPERAND (node, 0);
1485 op1 = TREE_OPERAND (node, 1);
1487 /* When the operands are expressions with less priority,
1488 keep semantics of the tree representation. */
1489 if (op_prio (op0) <= op_prio (node))
1491 pp_character (buffer, '(');
1492 dump_generic_node (buffer, op0, spc, flags, false);
1493 pp_character (buffer, ')');
1495 else
1496 dump_generic_node (buffer, op0, spc, flags, false);
1498 pp_space (buffer);
1499 pp_string (buffer, op);
1500 pp_space (buffer);
1502 /* When the operands are expressions with less priority,
1503 keep semantics of the tree representation. */
1504 if (op_prio (op1) <= op_prio (node))
1506 pp_character (buffer, '(');
1507 dump_generic_node (buffer, op1, spc, flags, false);
1508 pp_character (buffer, ')');
1510 else
1511 dump_generic_node (buffer, op1, spc, flags, false);
1513 break;
1515 /* Unary arithmetic and logic expressions. */
1516 case NEGATE_EXPR:
1517 case BIT_NOT_EXPR:
1518 case TRUTH_NOT_EXPR:
1519 case ADDR_EXPR:
1520 case PREDECREMENT_EXPR:
1521 case PREINCREMENT_EXPR:
1522 case ALIGN_INDIRECT_REF:
1523 case MISALIGNED_INDIRECT_REF:
1524 case INDIRECT_REF:
1525 if (TREE_CODE (node) == ADDR_EXPR
1526 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1527 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1528 ; /* Do not output '&' for strings and function pointers. */
1529 else
1530 pp_string (buffer, op_symbol (node));
1532 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1534 pp_character (buffer, '(');
1535 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1536 pp_character (buffer, ')');
1538 else
1539 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1541 if (TREE_CODE (node) == MISALIGNED_INDIRECT_REF)
1543 pp_string (buffer, "{misalignment: ");
1544 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1545 pp_character (buffer, '}');
1547 break;
1549 case POSTDECREMENT_EXPR:
1550 case POSTINCREMENT_EXPR:
1551 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1553 pp_character (buffer, '(');
1554 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1555 pp_character (buffer, ')');
1557 else
1558 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1559 pp_string (buffer, op_symbol (node));
1560 break;
1562 case MIN_EXPR:
1563 pp_string (buffer, "MIN_EXPR <");
1564 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1565 pp_string (buffer, ", ");
1566 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1567 pp_character (buffer, '>');
1568 break;
1570 case MAX_EXPR:
1571 pp_string (buffer, "MAX_EXPR <");
1572 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1573 pp_string (buffer, ", ");
1574 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1575 pp_character (buffer, '>');
1576 break;
1578 case ABS_EXPR:
1579 pp_string (buffer, "ABS_EXPR <");
1580 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1581 pp_character (buffer, '>');
1582 break;
1584 case RANGE_EXPR:
1585 NIY;
1586 break;
1588 case ADDR_SPACE_CONVERT_EXPR:
1589 case FIXED_CONVERT_EXPR:
1590 case FIX_TRUNC_EXPR:
1591 case FLOAT_EXPR:
1592 CASE_CONVERT:
1593 type = TREE_TYPE (node);
1594 op0 = TREE_OPERAND (node, 0);
1595 if (type != TREE_TYPE (op0))
1597 pp_character (buffer, '(');
1598 dump_generic_node (buffer, type, spc, flags, false);
1599 pp_string (buffer, ") ");
1601 if (op_prio (op0) < op_prio (node))
1602 pp_character (buffer, '(');
1603 dump_generic_node (buffer, op0, spc, flags, false);
1604 if (op_prio (op0) < op_prio (node))
1605 pp_character (buffer, ')');
1606 break;
1608 case VIEW_CONVERT_EXPR:
1609 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1610 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1611 pp_string (buffer, ">(");
1612 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1613 pp_character (buffer, ')');
1614 break;
1616 case PAREN_EXPR:
1617 pp_string (buffer, "((");
1618 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1619 pp_string (buffer, "))");
1620 break;
1622 case NON_LVALUE_EXPR:
1623 pp_string (buffer, "NON_LVALUE_EXPR <");
1624 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1625 pp_character (buffer, '>');
1626 break;
1628 case SAVE_EXPR:
1629 pp_string (buffer, "SAVE_EXPR <");
1630 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1631 pp_character (buffer, '>');
1632 break;
1634 case COMPLEX_EXPR:
1635 pp_string (buffer, "COMPLEX_EXPR <");
1636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1637 pp_string (buffer, ", ");
1638 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1639 pp_string (buffer, ">");
1640 break;
1642 case CONJ_EXPR:
1643 pp_string (buffer, "CONJ_EXPR <");
1644 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1645 pp_string (buffer, ">");
1646 break;
1648 case REALPART_EXPR:
1649 pp_string (buffer, "REALPART_EXPR <");
1650 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1651 pp_string (buffer, ">");
1652 break;
1654 case IMAGPART_EXPR:
1655 pp_string (buffer, "IMAGPART_EXPR <");
1656 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1657 pp_string (buffer, ">");
1658 break;
1660 case VA_ARG_EXPR:
1661 pp_string (buffer, "VA_ARG_EXPR <");
1662 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1663 pp_string (buffer, ">");
1664 break;
1666 case TRY_FINALLY_EXPR:
1667 case TRY_CATCH_EXPR:
1668 pp_string (buffer, "try");
1669 newline_and_indent (buffer, spc+2);
1670 pp_string (buffer, "{");
1671 newline_and_indent (buffer, spc+4);
1672 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
1673 newline_and_indent (buffer, spc+2);
1674 pp_string (buffer, "}");
1675 newline_and_indent (buffer, spc);
1676 pp_string (buffer,
1677 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
1678 newline_and_indent (buffer, spc+2);
1679 pp_string (buffer, "{");
1680 newline_and_indent (buffer, spc+4);
1681 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
1682 newline_and_indent (buffer, spc+2);
1683 pp_string (buffer, "}");
1684 is_expr = false;
1685 break;
1687 case CATCH_EXPR:
1688 pp_string (buffer, "catch (");
1689 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
1690 pp_string (buffer, ")");
1691 newline_and_indent (buffer, spc+2);
1692 pp_string (buffer, "{");
1693 newline_and_indent (buffer, spc+4);
1694 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
1695 newline_and_indent (buffer, spc+2);
1696 pp_string (buffer, "}");
1697 is_expr = false;
1698 break;
1700 case EH_FILTER_EXPR:
1701 pp_string (buffer, "<<<eh_filter (");
1702 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
1703 pp_string (buffer, ")>>>");
1704 newline_and_indent (buffer, spc+2);
1705 pp_string (buffer, "{");
1706 newline_and_indent (buffer, spc+4);
1707 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
1708 newline_and_indent (buffer, spc+2);
1709 pp_string (buffer, "}");
1710 is_expr = false;
1711 break;
1713 case LABEL_EXPR:
1714 op0 = TREE_OPERAND (node, 0);
1715 /* If this is for break or continue, don't bother printing it. */
1716 if (DECL_NAME (op0))
1718 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1719 if (strcmp (name, "break") == 0
1720 || strcmp (name, "continue") == 0)
1721 break;
1723 dump_generic_node (buffer, op0, spc, flags, false);
1724 pp_character (buffer, ':');
1725 if (DECL_NONLOCAL (op0))
1726 pp_string (buffer, " [non-local]");
1727 break;
1729 case LOOP_EXPR:
1730 pp_string (buffer, "while (1)");
1731 if (!(flags & TDF_SLIM))
1733 newline_and_indent (buffer, spc+2);
1734 pp_character (buffer, '{');
1735 newline_and_indent (buffer, spc+4);
1736 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
1737 newline_and_indent (buffer, spc+2);
1738 pp_character (buffer, '}');
1740 is_expr = false;
1741 break;
1743 case PREDICT_EXPR:
1744 pp_string (buffer, "// predicted ");
1745 if (PREDICT_EXPR_OUTCOME (node))
1746 pp_string (buffer, "likely by ");
1747 else
1748 pp_string (buffer, "unlikely by ");
1749 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
1750 pp_string (buffer, " predictor.");
1751 break;
1753 case RETURN_EXPR:
1754 pp_string (buffer, "return");
1755 op0 = TREE_OPERAND (node, 0);
1756 if (op0)
1758 pp_space (buffer);
1759 if (TREE_CODE (op0) == MODIFY_EXPR)
1760 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
1761 spc, flags, false);
1762 else
1763 dump_generic_node (buffer, op0, spc, flags, false);
1765 break;
1767 case EXIT_EXPR:
1768 pp_string (buffer, "if (");
1769 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1770 pp_string (buffer, ") break");
1771 break;
1773 case SWITCH_EXPR:
1774 pp_string (buffer, "switch (");
1775 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
1776 pp_character (buffer, ')');
1777 if (!(flags & TDF_SLIM))
1779 newline_and_indent (buffer, spc+2);
1780 pp_character (buffer, '{');
1781 if (SWITCH_BODY (node))
1783 newline_and_indent (buffer, spc+4);
1784 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
1785 true);
1787 else
1789 tree vec = SWITCH_LABELS (node);
1790 size_t i, n = TREE_VEC_LENGTH (vec);
1791 for (i = 0; i < n; ++i)
1793 tree elt = TREE_VEC_ELT (vec, i);
1794 newline_and_indent (buffer, spc+4);
1795 if (elt)
1797 dump_generic_node (buffer, elt, spc+4, flags, false);
1798 pp_string (buffer, " goto ");
1799 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
1800 flags, true);
1801 pp_semicolon (buffer);
1803 else
1804 pp_string (buffer, "case ???: goto ???;");
1807 newline_and_indent (buffer, spc+2);
1808 pp_character (buffer, '}');
1810 is_expr = false;
1811 break;
1813 case GOTO_EXPR:
1814 op0 = GOTO_DESTINATION (node);
1815 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
1817 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1818 if (strcmp (name, "break") == 0
1819 || strcmp (name, "continue") == 0)
1821 pp_string (buffer, name);
1822 break;
1825 pp_string (buffer, "goto ");
1826 dump_generic_node (buffer, op0, spc, flags, false);
1827 break;
1829 case ASM_EXPR:
1830 pp_string (buffer, "__asm__");
1831 if (ASM_VOLATILE_P (node))
1832 pp_string (buffer, " __volatile__");
1833 pp_character (buffer, '(');
1834 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
1835 pp_character (buffer, ':');
1836 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
1837 pp_character (buffer, ':');
1838 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
1839 if (ASM_CLOBBERS (node))
1841 pp_character (buffer, ':');
1842 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
1844 pp_string (buffer, ")");
1845 break;
1847 case CASE_LABEL_EXPR:
1848 if (CASE_LOW (node) && CASE_HIGH (node))
1850 pp_string (buffer, "case ");
1851 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1852 pp_string (buffer, " ... ");
1853 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
1855 else if (CASE_LOW (node))
1857 pp_string (buffer, "case ");
1858 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1860 else
1861 pp_string (buffer, "default");
1862 pp_character (buffer, ':');
1863 break;
1865 case OBJ_TYPE_REF:
1866 pp_string (buffer, "OBJ_TYPE_REF(");
1867 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
1868 pp_character (buffer, ';');
1869 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
1870 pp_character (buffer, '-');
1871 pp_character (buffer, '>');
1872 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
1873 pp_character (buffer, ')');
1874 break;
1876 case SSA_NAME:
1877 dump_generic_node (buffer, SSA_NAME_VAR (node), spc, flags, false);
1878 pp_string (buffer, "_");
1879 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
1880 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
1881 pp_string (buffer, "(ab)");
1882 else if (SSA_NAME_IS_DEFAULT_DEF (node))
1883 pp_string (buffer, "(D)");
1884 break;
1886 case WITH_SIZE_EXPR:
1887 pp_string (buffer, "WITH_SIZE_EXPR <");
1888 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1889 pp_string (buffer, ", ");
1890 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1891 pp_string (buffer, ">");
1892 break;
1894 case ASSERT_EXPR:
1895 pp_string (buffer, "ASSERT_EXPR <");
1896 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
1897 pp_string (buffer, ", ");
1898 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
1899 pp_string (buffer, ">");
1900 break;
1902 case SCEV_KNOWN:
1903 pp_string (buffer, "scev_known");
1904 break;
1906 case SCEV_NOT_KNOWN:
1907 pp_string (buffer, "scev_not_known");
1908 break;
1910 case POLYNOMIAL_CHREC:
1911 pp_string (buffer, "{");
1912 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
1913 pp_string (buffer, ", +, ");
1914 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
1915 pp_string (buffer, "}_");
1916 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
1917 is_stmt = false;
1918 break;
1920 case REALIGN_LOAD_EXPR:
1921 pp_string (buffer, "REALIGN_LOAD <");
1922 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1923 pp_string (buffer, ", ");
1924 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1925 pp_string (buffer, ", ");
1926 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1927 pp_string (buffer, ">");
1928 break;
1930 case VEC_COND_EXPR:
1931 pp_string (buffer, " VEC_COND_EXPR < ");
1932 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1933 pp_string (buffer, " , ");
1934 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1935 pp_string (buffer, " , ");
1936 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1937 pp_string (buffer, " > ");
1938 break;
1940 case DOT_PROD_EXPR:
1941 pp_string (buffer, " DOT_PROD_EXPR < ");
1942 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1943 pp_string (buffer, ", ");
1944 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1945 pp_string (buffer, ", ");
1946 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1947 pp_string (buffer, " > ");
1948 break;
1950 case OMP_PARALLEL:
1951 pp_string (buffer, "#pragma omp parallel");
1952 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
1954 dump_omp_body:
1955 if (!(flags & TDF_SLIM) && OMP_BODY (node))
1957 newline_and_indent (buffer, spc + 2);
1958 pp_character (buffer, '{');
1959 newline_and_indent (buffer, spc + 4);
1960 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
1961 newline_and_indent (buffer, spc + 2);
1962 pp_character (buffer, '}');
1964 is_expr = false;
1965 break;
1967 case OMP_TASK:
1968 pp_string (buffer, "#pragma omp task");
1969 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
1970 goto dump_omp_body;
1972 case OMP_FOR:
1973 pp_string (buffer, "#pragma omp for");
1974 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
1976 if (!(flags & TDF_SLIM))
1978 int i;
1980 if (OMP_FOR_PRE_BODY (node))
1982 newline_and_indent (buffer, spc + 2);
1983 pp_character (buffer, '{');
1984 spc += 4;
1985 newline_and_indent (buffer, spc);
1986 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
1987 spc, flags, false);
1989 spc -= 2;
1990 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
1992 spc += 2;
1993 newline_and_indent (buffer, spc);
1994 pp_string (buffer, "for (");
1995 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INIT (node), i),
1996 spc, flags, false);
1997 pp_string (buffer, "; ");
1998 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_COND (node), i),
1999 spc, flags, false);
2000 pp_string (buffer, "; ");
2001 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2002 spc, flags, false);
2003 pp_string (buffer, ")");
2005 if (OMP_FOR_BODY (node))
2007 newline_and_indent (buffer, spc + 2);
2008 pp_character (buffer, '{');
2009 newline_and_indent (buffer, spc + 4);
2010 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2011 false);
2012 newline_and_indent (buffer, spc + 2);
2013 pp_character (buffer, '}');
2015 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2016 if (OMP_FOR_PRE_BODY (node))
2018 spc -= 4;
2019 newline_and_indent (buffer, spc + 2);
2020 pp_character (buffer, '}');
2023 is_expr = false;
2024 break;
2026 case OMP_SECTIONS:
2027 pp_string (buffer, "#pragma omp sections");
2028 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2029 goto dump_omp_body;
2031 case OMP_SECTION:
2032 pp_string (buffer, "#pragma omp section");
2033 goto dump_omp_body;
2035 case OMP_MASTER:
2036 pp_string (buffer, "#pragma omp master");
2037 goto dump_omp_body;
2039 case OMP_ORDERED:
2040 pp_string (buffer, "#pragma omp ordered");
2041 goto dump_omp_body;
2043 case OMP_CRITICAL:
2044 pp_string (buffer, "#pragma omp critical");
2045 if (OMP_CRITICAL_NAME (node))
2047 pp_space (buffer);
2048 pp_character (buffer, '(');
2049 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2050 flags, false);
2051 pp_character (buffer, ')');
2053 goto dump_omp_body;
2055 case OMP_ATOMIC:
2056 pp_string (buffer, "#pragma omp atomic");
2057 newline_and_indent (buffer, spc + 2);
2058 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2059 pp_space (buffer);
2060 pp_character (buffer, '=');
2061 pp_space (buffer);
2062 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2063 break;
2065 case OMP_SINGLE:
2066 pp_string (buffer, "#pragma omp single");
2067 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2068 goto dump_omp_body;
2070 case OMP_CLAUSE:
2071 dump_omp_clause (buffer, node, spc, flags);
2072 is_expr = false;
2073 break;
2075 case REDUC_MAX_EXPR:
2076 pp_string (buffer, " REDUC_MAX_EXPR < ");
2077 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2078 pp_string (buffer, " > ");
2079 break;
2081 case REDUC_MIN_EXPR:
2082 pp_string (buffer, " REDUC_MIN_EXPR < ");
2083 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2084 pp_string (buffer, " > ");
2085 break;
2087 case REDUC_PLUS_EXPR:
2088 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2089 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2090 pp_string (buffer, " > ");
2091 break;
2093 case VEC_WIDEN_MULT_HI_EXPR:
2094 pp_string (buffer, " VEC_WIDEN_MULT_HI_EXPR < ");
2095 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2096 pp_string (buffer, ", ");
2097 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2098 pp_string (buffer, " > ");
2099 break;
2101 case VEC_WIDEN_MULT_LO_EXPR:
2102 pp_string (buffer, " VEC_WIDEN_MULT_LO_EXPR < ");
2103 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2104 pp_string (buffer, ", ");
2105 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2106 pp_string (buffer, " > ");
2107 break;
2109 case VEC_UNPACK_HI_EXPR:
2110 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2111 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2112 pp_string (buffer, " > ");
2113 break;
2115 case VEC_UNPACK_LO_EXPR:
2116 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2117 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2118 pp_string (buffer, " > ");
2119 break;
2121 case VEC_UNPACK_FLOAT_HI_EXPR:
2122 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2123 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2124 pp_string (buffer, " > ");
2125 break;
2127 case VEC_UNPACK_FLOAT_LO_EXPR:
2128 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2129 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2130 pp_string (buffer, " > ");
2131 break;
2133 case VEC_PACK_TRUNC_EXPR:
2134 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2135 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2136 pp_string (buffer, ", ");
2137 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2138 pp_string (buffer, " > ");
2139 break;
2141 case VEC_PACK_SAT_EXPR:
2142 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2143 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2144 pp_string (buffer, ", ");
2145 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2146 pp_string (buffer, " > ");
2147 break;
2149 case VEC_PACK_FIX_TRUNC_EXPR:
2150 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2151 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2152 pp_string (buffer, ", ");
2153 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2154 pp_string (buffer, " > ");
2155 break;
2157 case BLOCK:
2158 dump_block_node (buffer, node, spc, flags);
2159 break;
2161 case VEC_EXTRACT_EVEN_EXPR:
2162 pp_string (buffer, " VEC_EXTRACT_EVEN_EXPR < ");
2163 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2164 pp_string (buffer, ", ");
2165 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2166 pp_string (buffer, " > ");
2167 break;
2169 case VEC_EXTRACT_ODD_EXPR:
2170 pp_string (buffer, " VEC_EXTRACT_ODD_EXPR < ");
2171 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2172 pp_string (buffer, ", ");
2173 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2174 pp_string (buffer, " > ");
2175 break;
2177 case VEC_INTERLEAVE_HIGH_EXPR:
2178 pp_string (buffer, " VEC_INTERLEAVE_HIGH_EXPR < ");
2179 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2180 pp_string (buffer, ", ");
2181 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2182 pp_string (buffer, " > ");
2183 break;
2185 case VEC_INTERLEAVE_LOW_EXPR:
2186 pp_string (buffer, " VEC_INTERLEAVE_LOW_EXPR < ");
2187 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2188 pp_string (buffer, ", ");
2189 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2190 pp_string (buffer, " > ");
2191 break;
2193 default:
2194 NIY;
2197 if (is_stmt && is_expr)
2198 pp_semicolon (buffer);
2200 /* If we're building a diagnostic, the formatted text will be written
2201 into BUFFER's stream by the caller; otherwise, write it now. */
2202 if (!(flags & TDF_DIAGNOSTIC))
2203 pp_write_text_to_stream (buffer);
2205 return spc;
2208 /* Print the declaration of a variable. */
2210 void
2211 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2213 INDENT (spc);
2215 if (TREE_CODE (t) == TYPE_DECL)
2216 pp_string (buffer, "typedef ");
2218 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2219 pp_string (buffer, "register ");
2221 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2222 pp_string (buffer, "extern ");
2223 else if (TREE_STATIC (t))
2224 pp_string (buffer, "static ");
2226 /* Print the type and name. */
2227 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2229 tree tmp;
2231 /* Print array's type. */
2232 tmp = TREE_TYPE (t);
2233 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2234 tmp = TREE_TYPE (tmp);
2235 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2237 /* Print variable's name. */
2238 pp_space (buffer);
2239 dump_generic_node (buffer, t, spc, flags, false);
2241 /* Print the dimensions. */
2242 tmp = TREE_TYPE (t);
2243 while (TREE_CODE (tmp) == ARRAY_TYPE)
2245 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2246 tmp = TREE_TYPE (tmp);
2249 else if (TREE_CODE (t) == FUNCTION_DECL)
2251 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2252 pp_space (buffer);
2253 dump_decl_name (buffer, t, flags);
2254 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2256 else
2258 /* Print type declaration. */
2259 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2261 /* Print variable's name. */
2262 pp_space (buffer);
2263 dump_generic_node (buffer, t, spc, flags, false);
2266 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2268 pp_string (buffer, " __asm__ ");
2269 pp_character (buffer, '(');
2270 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2271 pp_character (buffer, ')');
2274 /* The initial value of a function serves to determine whether the function
2275 is declared or defined. So the following does not apply to function
2276 nodes. */
2277 if (TREE_CODE (t) != FUNCTION_DECL)
2279 /* Print the initial value. */
2280 if (DECL_INITIAL (t))
2282 pp_space (buffer);
2283 pp_character (buffer, '=');
2284 pp_space (buffer);
2285 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2289 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2291 pp_string (buffer, " [value-expr: ");
2292 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2293 pp_character (buffer, ']');
2296 pp_character (buffer, ';');
2300 /* Prints a structure: name, fields, and methods.
2301 FIXME: Still incomplete. */
2303 static void
2304 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2306 /* Print the name of the structure. */
2307 if (TYPE_NAME (node))
2309 INDENT (spc);
2310 if (TREE_CODE (node) == RECORD_TYPE)
2311 pp_string (buffer, "struct ");
2312 else if ((TREE_CODE (node) == UNION_TYPE
2313 || TREE_CODE (node) == QUAL_UNION_TYPE))
2314 pp_string (buffer, "union ");
2316 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2319 /* Print the contents of the structure. */
2320 pp_newline (buffer);
2321 INDENT (spc);
2322 pp_character (buffer, '{');
2323 pp_newline (buffer);
2325 /* Print the fields of the structure. */
2327 tree tmp;
2328 tmp = TYPE_FIELDS (node);
2329 while (tmp)
2331 /* Avoid to print recursively the structure. */
2332 /* FIXME : Not implemented correctly...,
2333 what about the case when we have a cycle in the contain graph? ...
2334 Maybe this could be solved by looking at the scope in which the
2335 structure was declared. */
2336 if (TREE_TYPE (tmp) != node
2337 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2338 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2340 print_declaration (buffer, tmp, spc+2, flags);
2341 pp_newline (buffer);
2343 tmp = TREE_CHAIN (tmp);
2346 INDENT (spc);
2347 pp_character (buffer, '}');
2350 /* Return the priority of the operator CODE.
2352 From lowest to highest precedence with either left-to-right (L-R)
2353 or right-to-left (R-L) associativity]:
2355 1 [L-R] ,
2356 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2357 3 [R-L] ?:
2358 4 [L-R] ||
2359 5 [L-R] &&
2360 6 [L-R] |
2361 7 [L-R] ^
2362 8 [L-R] &
2363 9 [L-R] == !=
2364 10 [L-R] < <= > >=
2365 11 [L-R] << >>
2366 12 [L-R] + -
2367 13 [L-R] * / %
2368 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2369 15 [L-R] fn() [] -> .
2371 unary +, - and * have higher precedence than the corresponding binary
2372 operators. */
2375 op_code_prio (enum tree_code code)
2377 switch (code)
2379 case TREE_LIST:
2380 case COMPOUND_EXPR:
2381 case BIND_EXPR:
2382 return 1;
2384 case MODIFY_EXPR:
2385 case INIT_EXPR:
2386 return 2;
2388 case COND_EXPR:
2389 return 3;
2391 case TRUTH_OR_EXPR:
2392 case TRUTH_ORIF_EXPR:
2393 return 4;
2395 case TRUTH_AND_EXPR:
2396 case TRUTH_ANDIF_EXPR:
2397 return 5;
2399 case BIT_IOR_EXPR:
2400 return 6;
2402 case BIT_XOR_EXPR:
2403 case TRUTH_XOR_EXPR:
2404 return 7;
2406 case BIT_AND_EXPR:
2407 return 8;
2409 case EQ_EXPR:
2410 case NE_EXPR:
2411 return 9;
2413 case UNLT_EXPR:
2414 case UNLE_EXPR:
2415 case UNGT_EXPR:
2416 case UNGE_EXPR:
2417 case UNEQ_EXPR:
2418 case LTGT_EXPR:
2419 case ORDERED_EXPR:
2420 case UNORDERED_EXPR:
2421 case LT_EXPR:
2422 case LE_EXPR:
2423 case GT_EXPR:
2424 case GE_EXPR:
2425 return 10;
2427 case LSHIFT_EXPR:
2428 case RSHIFT_EXPR:
2429 case LROTATE_EXPR:
2430 case RROTATE_EXPR:
2431 return 11;
2433 case WIDEN_SUM_EXPR:
2434 case PLUS_EXPR:
2435 case POINTER_PLUS_EXPR:
2436 case MINUS_EXPR:
2437 return 12;
2439 case VEC_WIDEN_MULT_HI_EXPR:
2440 case VEC_WIDEN_MULT_LO_EXPR:
2441 case WIDEN_MULT_EXPR:
2442 case DOT_PROD_EXPR:
2443 case MULT_EXPR:
2444 case TRUNC_DIV_EXPR:
2445 case CEIL_DIV_EXPR:
2446 case FLOOR_DIV_EXPR:
2447 case ROUND_DIV_EXPR:
2448 case RDIV_EXPR:
2449 case EXACT_DIV_EXPR:
2450 case TRUNC_MOD_EXPR:
2451 case CEIL_MOD_EXPR:
2452 case FLOOR_MOD_EXPR:
2453 case ROUND_MOD_EXPR:
2454 return 13;
2456 case TRUTH_NOT_EXPR:
2457 case BIT_NOT_EXPR:
2458 case POSTINCREMENT_EXPR:
2459 case POSTDECREMENT_EXPR:
2460 case PREINCREMENT_EXPR:
2461 case PREDECREMENT_EXPR:
2462 case NEGATE_EXPR:
2463 case ALIGN_INDIRECT_REF:
2464 case MISALIGNED_INDIRECT_REF:
2465 case INDIRECT_REF:
2466 case ADDR_EXPR:
2467 case FLOAT_EXPR:
2468 CASE_CONVERT:
2469 case FIX_TRUNC_EXPR:
2470 case TARGET_EXPR:
2471 return 14;
2473 case CALL_EXPR:
2474 case ARRAY_REF:
2475 case ARRAY_RANGE_REF:
2476 case COMPONENT_REF:
2477 return 15;
2479 /* Special expressions. */
2480 case MIN_EXPR:
2481 case MAX_EXPR:
2482 case ABS_EXPR:
2483 case REALPART_EXPR:
2484 case IMAGPART_EXPR:
2485 case REDUC_MAX_EXPR:
2486 case REDUC_MIN_EXPR:
2487 case REDUC_PLUS_EXPR:
2488 case VEC_LSHIFT_EXPR:
2489 case VEC_RSHIFT_EXPR:
2490 case VEC_UNPACK_HI_EXPR:
2491 case VEC_UNPACK_LO_EXPR:
2492 case VEC_UNPACK_FLOAT_HI_EXPR:
2493 case VEC_UNPACK_FLOAT_LO_EXPR:
2494 case VEC_PACK_TRUNC_EXPR:
2495 case VEC_PACK_SAT_EXPR:
2496 return 16;
2498 default:
2499 /* Return an arbitrarily high precedence to avoid surrounding single
2500 VAR_DECLs in ()s. */
2501 return 9999;
2505 /* Return the priority of the operator OP. */
2508 op_prio (const_tree op)
2510 enum tree_code code;
2512 if (op == NULL)
2513 return 9999;
2515 code = TREE_CODE (op);
2516 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
2517 return op_prio (TREE_OPERAND (op, 0));
2519 return op_code_prio (code);
2522 /* Return the symbol associated with operator CODE. */
2524 const char *
2525 op_symbol_code (enum tree_code code)
2527 switch (code)
2529 case MODIFY_EXPR:
2530 return "=";
2532 case TRUTH_OR_EXPR:
2533 case TRUTH_ORIF_EXPR:
2534 return "||";
2536 case TRUTH_AND_EXPR:
2537 case TRUTH_ANDIF_EXPR:
2538 return "&&";
2540 case BIT_IOR_EXPR:
2541 return "|";
2543 case TRUTH_XOR_EXPR:
2544 case BIT_XOR_EXPR:
2545 return "^";
2547 case ADDR_EXPR:
2548 case BIT_AND_EXPR:
2549 return "&";
2551 case ORDERED_EXPR:
2552 return "ord";
2553 case UNORDERED_EXPR:
2554 return "unord";
2556 case EQ_EXPR:
2557 return "==";
2558 case UNEQ_EXPR:
2559 return "u==";
2561 case NE_EXPR:
2562 return "!=";
2564 case LT_EXPR:
2565 return "<";
2566 case UNLT_EXPR:
2567 return "u<";
2569 case LE_EXPR:
2570 return "<=";
2571 case UNLE_EXPR:
2572 return "u<=";
2574 case GT_EXPR:
2575 return ">";
2576 case UNGT_EXPR:
2577 return "u>";
2579 case GE_EXPR:
2580 return ">=";
2581 case UNGE_EXPR:
2582 return "u>=";
2584 case LTGT_EXPR:
2585 return "<>";
2587 case LSHIFT_EXPR:
2588 return "<<";
2590 case RSHIFT_EXPR:
2591 return ">>";
2593 case LROTATE_EXPR:
2594 return "r<<";
2596 case RROTATE_EXPR:
2597 return "r>>";
2599 case VEC_LSHIFT_EXPR:
2600 return "v<<";
2602 case VEC_RSHIFT_EXPR:
2603 return "v>>";
2605 case POINTER_PLUS_EXPR:
2606 return "+";
2608 case PLUS_EXPR:
2609 return "+";
2611 case REDUC_PLUS_EXPR:
2612 return "r+";
2614 case WIDEN_SUM_EXPR:
2615 return "w+";
2617 case WIDEN_MULT_EXPR:
2618 return "w*";
2620 case NEGATE_EXPR:
2621 case MINUS_EXPR:
2622 return "-";
2624 case BIT_NOT_EXPR:
2625 return "~";
2627 case TRUTH_NOT_EXPR:
2628 return "!";
2630 case MULT_EXPR:
2631 case INDIRECT_REF:
2632 return "*";
2634 case ALIGN_INDIRECT_REF:
2635 return "A*";
2637 case MISALIGNED_INDIRECT_REF:
2638 return "M*";
2640 case TRUNC_DIV_EXPR:
2641 case RDIV_EXPR:
2642 return "/";
2644 case CEIL_DIV_EXPR:
2645 return "/[cl]";
2647 case FLOOR_DIV_EXPR:
2648 return "/[fl]";
2650 case ROUND_DIV_EXPR:
2651 return "/[rd]";
2653 case EXACT_DIV_EXPR:
2654 return "/[ex]";
2656 case TRUNC_MOD_EXPR:
2657 return "%";
2659 case CEIL_MOD_EXPR:
2660 return "%[cl]";
2662 case FLOOR_MOD_EXPR:
2663 return "%[fl]";
2665 case ROUND_MOD_EXPR:
2666 return "%[rd]";
2668 case PREDECREMENT_EXPR:
2669 return " --";
2671 case PREINCREMENT_EXPR:
2672 return " ++";
2674 case POSTDECREMENT_EXPR:
2675 return "-- ";
2677 case POSTINCREMENT_EXPR:
2678 return "++ ";
2680 case MAX_EXPR:
2681 return "max";
2683 case MIN_EXPR:
2684 return "min";
2686 default:
2687 return "<<< ??? >>>";
2691 /* Return the symbol associated with operator OP. */
2693 static const char *
2694 op_symbol (const_tree op)
2696 return op_symbol_code (TREE_CODE (op));
2699 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2700 the gimple_call_fn of a GIMPLE_CALL. */
2702 void
2703 print_call_name (pretty_printer *buffer, tree node, int flags)
2705 tree op0 = node;
2707 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
2708 op0 = TREE_OPERAND (op0, 0);
2710 again:
2711 switch (TREE_CODE (op0))
2713 case VAR_DECL:
2714 case PARM_DECL:
2715 case FUNCTION_DECL:
2716 dump_function_name (buffer, op0, flags);
2717 break;
2719 case ADDR_EXPR:
2720 case INDIRECT_REF:
2721 case NOP_EXPR:
2722 op0 = TREE_OPERAND (op0, 0);
2723 goto again;
2725 case COND_EXPR:
2726 pp_string (buffer, "(");
2727 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
2728 pp_string (buffer, ") ? ");
2729 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
2730 pp_string (buffer, " : ");
2731 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
2732 break;
2734 case ARRAY_REF:
2735 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
2736 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
2737 else
2738 dump_generic_node (buffer, op0, 0, flags, false);
2739 break;
2741 case COMPONENT_REF:
2742 case SSA_NAME:
2743 case OBJ_TYPE_REF:
2744 dump_generic_node (buffer, op0, 0, flags, false);
2745 break;
2747 default:
2748 NIY;
2752 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2754 static void
2755 pretty_print_string (pretty_printer *buffer, const char *str)
2757 if (str == NULL)
2758 return;
2760 while (*str)
2762 switch (str[0])
2764 case '\b':
2765 pp_string (buffer, "\\b");
2766 break;
2768 case '\f':
2769 pp_string (buffer, "\\f");
2770 break;
2772 case '\n':
2773 pp_string (buffer, "\\n");
2774 break;
2776 case '\r':
2777 pp_string (buffer, "\\r");
2778 break;
2780 case '\t':
2781 pp_string (buffer, "\\t");
2782 break;
2784 case '\v':
2785 pp_string (buffer, "\\v");
2786 break;
2788 case '\\':
2789 pp_string (buffer, "\\\\");
2790 break;
2792 case '\"':
2793 pp_string (buffer, "\\\"");
2794 break;
2796 case '\'':
2797 pp_string (buffer, "\\'");
2798 break;
2800 /* No need to handle \0; the loop terminates on \0. */
2802 case '\1':
2803 pp_string (buffer, "\\1");
2804 break;
2806 case '\2':
2807 pp_string (buffer, "\\2");
2808 break;
2810 case '\3':
2811 pp_string (buffer, "\\3");
2812 break;
2814 case '\4':
2815 pp_string (buffer, "\\4");
2816 break;
2818 case '\5':
2819 pp_string (buffer, "\\5");
2820 break;
2822 case '\6':
2823 pp_string (buffer, "\\6");
2824 break;
2826 case '\7':
2827 pp_string (buffer, "\\7");
2828 break;
2830 default:
2831 pp_character (buffer, str[0]);
2832 break;
2834 str++;
2838 static void
2839 maybe_init_pretty_print (FILE *file)
2841 if (!initialized)
2843 pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
2844 pp_needs_newline (&buffer) = true;
2845 pp_translate_identifiers (&buffer) = false;
2846 initialized = 1;
2849 buffer.buffer->stream = file;
2852 static void
2853 newline_and_indent (pretty_printer *buffer, int spc)
2855 pp_newline (buffer);
2856 INDENT (spc);
2859 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2860 it can also be used in front ends.
2861 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2864 void
2865 percent_K_format (text_info *text)
2867 tree t = va_arg (*text->args_ptr, tree), block;
2868 gcc_assert (text->locus != NULL);
2869 *text->locus = EXPR_LOCATION (t);
2870 gcc_assert (pp_ti_abstract_origin (text) != NULL);
2871 block = TREE_BLOCK (t);
2872 *pp_ti_abstract_origin (text) = NULL;
2873 while (block
2874 && TREE_CODE (block) == BLOCK
2875 && BLOCK_ABSTRACT_ORIGIN (block))
2877 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
2879 while (TREE_CODE (ao) == BLOCK
2880 && BLOCK_ABSTRACT_ORIGIN (ao)
2881 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
2882 ao = BLOCK_ABSTRACT_ORIGIN (ao);
2884 if (TREE_CODE (ao) == FUNCTION_DECL)
2886 *pp_ti_abstract_origin (text) = block;
2887 break;
2889 block = BLOCK_SUPERCONTEXT (block);
2893 /* Print the identifier ID to PRETTY-PRINTER. */
2895 void
2896 pp_base_tree_identifier (pretty_printer *pp, tree id)
2898 if (pp_translate_identifiers (pp))
2900 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
2901 pp_append_text (pp, text, text + strlen (text));
2903 else
2904 pp_append_text (pp, IDENTIFIER_POINTER (id),
2905 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));