1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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
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
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/>. */
24 #include "coretypes.h"
28 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "langhooks.h"
33 #include "tree-iterator.h"
34 #include "tree-chrec.h"
35 #include "tree-pass.h"
36 #include "fixed-value.h"
37 #include "value-prof.h"
40 /* Local functions, macros and variables. */
41 static const char *op_symbol (const_tree);
42 static void pretty_print_string (pretty_printer *, const char*);
43 static void newline_and_indent (pretty_printer *, int);
44 static void maybe_init_pretty_print (FILE *);
45 static void print_struct_decl (pretty_printer *, const_tree, int, int);
46 static void do_niy (pretty_printer *, const_tree);
48 #define INDENT(SPACE) do { \
49 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
51 #define NIY do_niy(buffer,node)
53 static pretty_printer buffer;
54 static int initialized = 0;
56 /* Try to print something for an unknown tree code. */
59 do_niy (pretty_printer *buffer, const_tree node)
63 pp_string (buffer, "<<< Unknown tree: ");
64 pp_string (buffer, tree_code_name[(int) TREE_CODE (node)]);
68 len = TREE_OPERAND_LENGTH (node);
69 for (i = 0; i < len; ++i)
71 newline_and_indent (buffer, 2);
72 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
76 pp_string (buffer, " >>>\n");
79 /* Debugging function to print out a generic expression. */
82 debug_generic_expr (tree t)
84 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
85 fprintf (stderr, "\n");
88 /* Debugging function to print out a generic statement. */
91 debug_generic_stmt (tree t)
93 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
94 fprintf (stderr, "\n");
97 /* Debugging function to print out a chain of trees . */
100 debug_tree_chain (tree t)
102 struct pointer_set_t *seen = pointer_set_create ();
106 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
107 fprintf (stderr, " ");
109 if (pointer_set_insert (seen, t))
111 fprintf (stderr, "... [cycled back to ");
112 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
113 fprintf (stderr, "]");
117 fprintf (stderr, "\n");
119 pointer_set_destroy (seen);
122 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
124 print_generic_decl (FILE *file, tree decl, int flags)
126 maybe_init_pretty_print (file);
127 print_declaration (&buffer, decl, 2, flags);
128 pp_write_text_to_stream (&buffer);
131 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
132 to show in the dump. See TDF_* in tree-pass.h. */
135 print_generic_stmt (FILE *file, tree t, int flags)
137 maybe_init_pretty_print (file);
138 dump_generic_node (&buffer, t, 0, flags, true);
142 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
143 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
147 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
151 maybe_init_pretty_print (file);
153 for (i = 0; i < indent; i++)
155 dump_generic_node (&buffer, t, indent, flags, true);
159 /* Print a single expression T on file FILE. FLAGS specifies details to show
160 in the dump. See TDF_* in tree-pass.h. */
163 print_generic_expr (FILE *file, tree t, int flags)
165 maybe_init_pretty_print (file);
166 dump_generic_node (&buffer, t, 0, flags, false);
169 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
173 dump_decl_name (pretty_printer *buffer, tree node, int flags)
175 if (DECL_NAME (node))
177 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
178 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
180 pp_tree_identifier (buffer, DECL_NAME (node));
182 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
184 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
185 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
186 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
187 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
190 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
191 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
196 /* Like the above, but used for pretty printing function calls. */
199 dump_function_name (pretty_printer *buffer, tree node, int flags)
201 if (TREE_CODE (node) == NOP_EXPR)
202 node = TREE_OPERAND (node, 0);
203 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
204 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
206 dump_decl_name (buffer, node, flags);
209 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
210 FLAGS are as in dump_generic_node. */
213 dump_function_declaration (pretty_printer *buffer, tree node,
216 bool wrote_arg = false;
220 pp_character (buffer, '(');
222 /* Print the argument types. The last element in the list is a VOID_TYPE.
223 The following avoids printing the last element. */
224 arg = TYPE_ARG_TYPES (node);
225 while (arg && TREE_CHAIN (arg) && arg != error_mark_node)
228 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
229 arg = TREE_CHAIN (arg);
230 if (TREE_CHAIN (arg) && TREE_CODE (TREE_CHAIN (arg)) == TREE_LIST)
232 pp_character (buffer, ',');
238 pp_string (buffer, "void");
240 pp_character (buffer, ')');
243 /* Dump the domain associated with an array. */
246 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
248 pp_character (buffer, '[');
251 tree min = TYPE_MIN_VALUE (domain);
252 tree max = TYPE_MAX_VALUE (domain);
255 && integer_zerop (min)
256 && host_integerp (max, 0))
257 pp_wide_integer (buffer, TREE_INT_CST_LOW (max) + 1);
261 dump_generic_node (buffer, min, spc, flags, false);
262 pp_character (buffer, ':');
264 dump_generic_node (buffer, max, spc, flags, false);
268 pp_string (buffer, "<unknown>");
269 pp_character (buffer, ']');
273 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
274 dump_generic_node. */
277 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
281 switch (OMP_CLAUSE_CODE (clause))
283 case OMP_CLAUSE_PRIVATE:
286 case OMP_CLAUSE_SHARED:
289 case OMP_CLAUSE_FIRSTPRIVATE:
290 name = "firstprivate";
292 case OMP_CLAUSE_LASTPRIVATE:
293 name = "lastprivate";
295 case OMP_CLAUSE_COPYIN:
298 case OMP_CLAUSE_COPYPRIVATE:
299 name = "copyprivate";
302 pp_string (buffer, name);
303 pp_character (buffer, '(');
304 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
306 pp_character (buffer, ')');
309 case OMP_CLAUSE_REDUCTION:
310 pp_string (buffer, "reduction(");
311 pp_string (buffer, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
312 pp_character (buffer, ':');
313 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
315 pp_character (buffer, ')');
319 pp_string (buffer, "if(");
320 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
322 pp_character (buffer, ')');
325 case OMP_CLAUSE_NUM_THREADS:
326 pp_string (buffer, "num_threads(");
327 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
329 pp_character (buffer, ')');
332 case OMP_CLAUSE_NOWAIT:
333 pp_string (buffer, "nowait");
335 case OMP_CLAUSE_ORDERED:
336 pp_string (buffer, "ordered");
339 case OMP_CLAUSE_DEFAULT:
340 pp_string (buffer, "default(");
341 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
343 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
345 case OMP_CLAUSE_DEFAULT_SHARED:
346 pp_string (buffer, "shared");
348 case OMP_CLAUSE_DEFAULT_NONE:
349 pp_string (buffer, "none");
351 case OMP_CLAUSE_DEFAULT_PRIVATE:
352 pp_string (buffer, "private");
354 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
355 pp_string (buffer, "firstprivate");
360 pp_character (buffer, ')');
363 case OMP_CLAUSE_SCHEDULE:
364 pp_string (buffer, "schedule(");
365 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
367 case OMP_CLAUSE_SCHEDULE_STATIC:
368 pp_string (buffer, "static");
370 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
371 pp_string (buffer, "dynamic");
373 case OMP_CLAUSE_SCHEDULE_GUIDED:
374 pp_string (buffer, "guided");
376 case OMP_CLAUSE_SCHEDULE_RUNTIME:
377 pp_string (buffer, "runtime");
379 case OMP_CLAUSE_SCHEDULE_AUTO:
380 pp_string (buffer, "auto");
385 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
387 pp_character (buffer, ',');
388 dump_generic_node (buffer,
389 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
392 pp_character (buffer, ')');
395 case OMP_CLAUSE_UNTIED:
396 pp_string (buffer, "untied");
399 case OMP_CLAUSE_COLLAPSE:
400 pp_string (buffer, "collapse(");
401 dump_generic_node (buffer,
402 OMP_CLAUSE_COLLAPSE_EXPR (clause),
404 pp_character (buffer, ')');
408 /* Should never happen. */
409 dump_generic_node (buffer, clause, spc, flags, false);
415 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
416 dump_generic_node. */
419 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
427 dump_omp_clause (buffer, clause, spc, flags);
428 clause = OMP_CLAUSE_CHAIN (clause);
436 /* Dump location LOC to BUFFER. */
439 dump_location (pretty_printer *buffer, location_t loc)
441 expanded_location xloc = expand_location (loc);
443 pp_character (buffer, '[');
446 pp_string (buffer, xloc.file);
447 pp_string (buffer, " : ");
449 pp_decimal_int (buffer, xloc.line);
450 pp_string (buffer, "] ");
454 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
455 dump_generic_node. */
458 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
462 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
464 if (flags & TDF_ADDRESS)
465 pp_printf (buffer, "[%p] ", (void *) block);
467 if (BLOCK_ABSTRACT (block))
468 pp_string (buffer, "[abstract] ");
470 if (TREE_ASM_WRITTEN (block))
471 pp_string (buffer, "[written] ");
473 if (flags & TDF_SLIM)
476 if (BLOCK_SOURCE_LOCATION (block))
477 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
479 newline_and_indent (buffer, spc + 2);
481 if (BLOCK_SUPERCONTEXT (block))
483 pp_string (buffer, "SUPERCONTEXT: ");
484 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
485 flags | TDF_SLIM, false);
486 newline_and_indent (buffer, spc + 2);
489 if (BLOCK_SUBBLOCKS (block))
491 pp_string (buffer, "SUBBLOCKS: ");
492 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
494 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
495 pp_string (buffer, " ");
497 newline_and_indent (buffer, spc + 2);
500 if (BLOCK_CHAIN (block))
502 pp_string (buffer, "SIBLINGS: ");
503 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
505 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
506 pp_string (buffer, " ");
508 newline_and_indent (buffer, spc + 2);
511 if (BLOCK_VARS (block))
513 pp_string (buffer, "VARS: ");
514 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
516 dump_generic_node (buffer, t, 0, flags, false);
517 pp_string (buffer, " ");
519 newline_and_indent (buffer, spc + 2);
522 if (VEC_length (tree, BLOCK_NONLOCALIZED_VARS (block)) > 0)
525 VEC(tree,gc) *nlv = BLOCK_NONLOCALIZED_VARS (block);
527 pp_string (buffer, "NONLOCALIZED_VARS: ");
528 for (i = 0; VEC_iterate (tree, nlv, i, t); i++)
530 dump_generic_node (buffer, t, 0, flags, false);
531 pp_string (buffer, " ");
533 newline_and_indent (buffer, spc + 2);
536 if (BLOCK_ABSTRACT_ORIGIN (block))
538 pp_string (buffer, "ABSTRACT_ORIGIN: ");
539 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
540 flags | TDF_SLIM, false);
541 newline_and_indent (buffer, spc + 2);
544 if (BLOCK_FRAGMENT_ORIGIN (block))
546 pp_string (buffer, "FRAGMENT_ORIGIN: ");
547 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
548 flags | TDF_SLIM, false);
549 newline_and_indent (buffer, spc + 2);
552 if (BLOCK_FRAGMENT_CHAIN (block))
554 pp_string (buffer, "FRAGMENT_CHAIN: ");
555 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
557 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
558 pp_string (buffer, " ");
560 newline_and_indent (buffer, spc + 2);
565 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
566 indent. FLAGS specifies details to show in the dump (see TDF_* in
567 tree-pass.h). If IS_STMT is true, the object printed is considered
568 to be a statement and it is terminated by ';' if appropriate. */
571 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
579 if (node == NULL_TREE)
582 is_expr = EXPR_P (node);
584 if (is_stmt && (flags & TDF_STMTADDR))
585 pp_printf (buffer, "<&%p> ", (void *)node);
587 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
588 dump_location (buffer, EXPR_LOCATION (node));
590 switch (TREE_CODE (node))
593 pp_string (buffer, "<<< error >>>");
596 case IDENTIFIER_NODE:
597 pp_tree_identifier (buffer, node);
601 while (node && node != error_mark_node)
603 if (TREE_PURPOSE (node))
605 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
608 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
609 node = TREE_CHAIN (node);
610 if (node && TREE_CODE (node) == TREE_LIST)
612 pp_character (buffer, ',');
619 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
625 if (TREE_VEC_LENGTH (node) > 0)
627 size_t len = TREE_VEC_LENGTH (node);
628 for (i = 0; i < len - 1; i++)
630 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
632 pp_character (buffer, ',');
635 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
644 case FIXED_POINT_TYPE:
650 unsigned int quals = TYPE_QUALS (node);
651 enum tree_code_class tclass;
653 if (quals & TYPE_QUAL_CONST)
654 pp_string (buffer, "const ");
655 else if (quals & TYPE_QUAL_VOLATILE)
656 pp_string (buffer, "volatile ");
657 else if (quals & TYPE_QUAL_RESTRICT)
658 pp_string (buffer, "restrict ");
660 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
662 pp_string (buffer, "<address-space-");
663 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
664 pp_string (buffer, "> ");
667 tclass = TREE_CODE_CLASS (TREE_CODE (node));
669 if (tclass == tcc_declaration)
671 if (DECL_NAME (node))
672 dump_decl_name (buffer, node, flags);
674 pp_string (buffer, "<unnamed type decl>");
676 else if (tclass == tcc_type)
678 if (TYPE_NAME (node))
680 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
681 pp_tree_identifier (buffer, TYPE_NAME (node));
682 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
683 && DECL_NAME (TYPE_NAME (node)))
684 dump_decl_name (buffer, TYPE_NAME (node), flags);
686 pp_string (buffer, "<unnamed type>");
688 else if (TREE_CODE (node) == VECTOR_TYPE)
690 pp_string (buffer, "vector ");
691 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
693 else if (TREE_CODE (node) == INTEGER_TYPE)
695 pp_string (buffer, (TYPE_UNSIGNED (node)
696 ? "<unnamed-unsigned:"
697 : "<unnamed-signed:"));
698 pp_decimal_int (buffer, TYPE_PRECISION (node));
699 pp_string (buffer, ">");
701 else if (TREE_CODE (node) == COMPLEX_TYPE)
703 pp_string (buffer, "__complex__ ");
704 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
706 else if (TREE_CODE (node) == REAL_TYPE)
708 pp_string (buffer, "<float:");
709 pp_decimal_int (buffer, TYPE_PRECISION (node));
710 pp_string (buffer, ">");
712 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
714 pp_string (buffer, "<fixed-point-");
715 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
716 pp_decimal_int (buffer, TYPE_PRECISION (node));
717 pp_string (buffer, ">");
720 pp_string (buffer, "<unnamed type>");
727 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
729 if (TREE_TYPE (node) == NULL)
731 pp_string (buffer, str);
732 pp_string (buffer, "<null type>");
734 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
736 tree fnode = TREE_TYPE (node);
738 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
740 pp_character (buffer, '(');
741 pp_string (buffer, str);
742 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
743 dump_decl_name (buffer, TYPE_NAME (node), flags);
745 pp_printf (buffer, "<T%x>", TYPE_UID (node));
747 pp_character (buffer, ')');
748 dump_function_declaration (buffer, fnode, spc, flags);
752 unsigned int quals = TYPE_QUALS (node);
754 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
756 pp_string (buffer, str);
758 if (quals & TYPE_QUAL_CONST)
759 pp_string (buffer, " const");
760 if (quals & TYPE_QUAL_VOLATILE)
761 pp_string (buffer, " volatile");
762 if (quals & TYPE_QUAL_RESTRICT)
763 pp_string (buffer, " restrict");
765 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
767 pp_string (buffer, " <address-space-");
768 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
769 pp_string (buffer, ">");
772 if (TYPE_REF_CAN_ALIAS_ALL (node))
773 pp_string (buffer, " {ref-all}");
783 const char *sep = "";
786 pp_string (buffer, "MEM[");
788 tmp = TMR_SYMBOL (node);
791 pp_string (buffer, sep);
793 pp_string (buffer, "symbol: ");
794 dump_generic_node (buffer, tmp, spc, flags, false);
796 tmp = TMR_BASE (node);
799 pp_string (buffer, sep);
801 pp_string (buffer, "base: ");
802 dump_generic_node (buffer, tmp, spc, flags, false);
804 tmp = TMR_INDEX (node);
807 pp_string (buffer, sep);
809 pp_string (buffer, "index: ");
810 dump_generic_node (buffer, tmp, spc, flags, false);
812 tmp = TMR_STEP (node);
815 pp_string (buffer, sep);
817 pp_string (buffer, "step: ");
818 dump_generic_node (buffer, tmp, spc, flags, false);
820 tmp = TMR_OFFSET (node);
823 pp_string (buffer, sep);
825 pp_string (buffer, "offset: ");
826 dump_generic_node (buffer, tmp, spc, flags, false);
828 pp_string (buffer, "]");
829 if (flags & TDF_DETAILS)
831 pp_string (buffer, "{");
832 dump_generic_node (buffer, TMR_ORIGINAL (node), spc, flags,
834 pp_string (buffer, "}");
843 /* Print the innermost component type. */
844 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
845 tmp = TREE_TYPE (tmp))
847 dump_generic_node (buffer, tmp, spc, flags, false);
849 /* Print the dimensions. */
850 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
851 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
857 case QUAL_UNION_TYPE:
859 unsigned int quals = TYPE_QUALS (node);
861 if (quals & TYPE_QUAL_CONST)
862 pp_string (buffer, "const ");
863 if (quals & TYPE_QUAL_VOLATILE)
864 pp_string (buffer, "volatile ");
866 /* Print the name of the structure. */
867 if (TREE_CODE (node) == RECORD_TYPE)
868 pp_string (buffer, "struct ");
869 else if (TREE_CODE (node) == UNION_TYPE)
870 pp_string (buffer, "union ");
872 if (TYPE_NAME (node))
873 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
874 else if (!(flags & TDF_SLIM))
875 /* FIXME: If we eliminate the 'else' above and attempt
876 to show the fields for named types, we may get stuck
877 following a cycle of pointers to structs. The alleged
878 self-reference check in print_struct_decl will not detect
879 cycles involving more than one pointer or struct type. */
880 print_struct_decl (buffer, node, spc, flags);
889 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
891 /* In the case of a pointer, one may want to divide by the
892 size of the pointed-to type. Unfortunately, this not
893 straightforward. The C front-end maps expressions
898 in such a way that the two INTEGER_CST nodes for "5" have
899 different values but identical types. In the latter
900 case, the 5 is multiplied by sizeof (int) in c-common.c
901 (pointer_int_sum) to convert it to a byte address, and
902 yet the type of the node is left unchanged. Argh. What
903 is consistent though is that the number value corresponds
904 to bytes (UNITS) offset.
906 NB: Neither of the following divisors can be trivially
907 used to recover the original literal:
909 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
910 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
911 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
912 pp_string (buffer, "B"); /* pseudo-unit */
914 else if (! host_integerp (node, 0))
917 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val);
918 HOST_WIDE_INT high = TREE_INT_CST_HIGH (val);
920 if (tree_int_cst_sgn (val) < 0)
922 pp_character (buffer, '-');
926 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
928 sprintf (pp_buffer (buffer)->digit_buffer,
929 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
930 (unsigned HOST_WIDE_INT) high, low);
931 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
934 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
938 /* Code copied from print_node. */
941 if (TREE_OVERFLOW (node))
942 pp_string (buffer, " overflow");
944 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
945 d = TREE_REAL_CST (node);
946 if (REAL_VALUE_ISINF (d))
947 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
948 else if (REAL_VALUE_ISNAN (d))
949 pp_string (buffer, " Nan");
953 real_to_decimal (string, &d, sizeof (string), 0, 1);
954 pp_string (buffer, string);
959 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
960 pp_string (buffer, "0x");
961 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
962 output_formatted_integer (buffer, "%02x", *p++);
971 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
972 pp_string (buffer, string);
977 pp_string (buffer, "__complex__ (");
978 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
979 pp_string (buffer, ", ");
980 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
981 pp_string (buffer, ")");
985 pp_string (buffer, "\"");
986 pretty_print_string (buffer, TREE_STRING_POINTER (node));
987 pp_string (buffer, "\"");
993 pp_string (buffer, "{ ");
994 for (elt = TREE_VECTOR_CST_ELTS (node); elt; elt = TREE_CHAIN (elt))
996 dump_generic_node (buffer, TREE_VALUE (elt), spc, flags, false);
997 if (TREE_CHAIN (elt))
998 pp_string (buffer, ", ");
1000 pp_string (buffer, " }");
1006 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1008 if (TREE_CODE (node) == METHOD_TYPE)
1010 if (TYPE_METHOD_BASETYPE (node))
1011 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1014 pp_string (buffer, "<null method basetype>");
1015 pp_string (buffer, "::");
1017 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1018 dump_decl_name (buffer, TYPE_NAME (node), flags);
1020 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1021 dump_function_declaration (buffer, node, spc, flags);
1026 dump_decl_name (buffer, node, flags);
1030 if (DECL_NAME (node))
1031 dump_decl_name (buffer, node, flags);
1032 else if (LABEL_DECL_UID (node) != -1)
1033 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1035 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1039 if (DECL_IS_BUILTIN (node))
1041 /* Don't print the declaration of built-in types. */
1044 if (DECL_NAME (node))
1045 dump_decl_name (buffer, node, flags);
1048 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1049 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1050 && TYPE_METHODS (TREE_TYPE (node)))
1052 /* The type is a c++ class: all structures have at least
1054 pp_string (buffer, "class ");
1055 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1060 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1061 ? "union" : "struct "));
1062 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1070 case DEBUG_EXPR_DECL:
1071 case NAMESPACE_DECL:
1072 dump_decl_name (buffer, node, flags);
1076 pp_string (buffer, "<retval>");
1080 op0 = TREE_OPERAND (node, 0);
1082 if (op0 && TREE_CODE (op0) == INDIRECT_REF)
1084 op0 = TREE_OPERAND (op0, 0);
1087 if (op_prio (op0) < op_prio (node))
1088 pp_character (buffer, '(');
1089 dump_generic_node (buffer, op0, spc, flags, false);
1090 if (op_prio (op0) < op_prio (node))
1091 pp_character (buffer, ')');
1092 pp_string (buffer, str);
1093 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1094 op0 = component_ref_field_offset (node);
1095 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1097 pp_string (buffer, "{off: ");
1098 dump_generic_node (buffer, op0, spc, flags, false);
1099 pp_character (buffer, '}');
1104 pp_string (buffer, "BIT_FIELD_REF <");
1105 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1106 pp_string (buffer, ", ");
1107 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1108 pp_string (buffer, ", ");
1109 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1110 pp_string (buffer, ">");
1114 case ARRAY_RANGE_REF:
1115 op0 = TREE_OPERAND (node, 0);
1116 if (op_prio (op0) < op_prio (node))
1117 pp_character (buffer, '(');
1118 dump_generic_node (buffer, op0, spc, flags, false);
1119 if (op_prio (op0) < op_prio (node))
1120 pp_character (buffer, ')');
1121 pp_character (buffer, '[');
1122 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1123 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1124 pp_string (buffer, " ...");
1125 pp_character (buffer, ']');
1127 op0 = array_ref_low_bound (node);
1128 op1 = array_ref_element_size (node);
1130 if (!integer_zerop (op0)
1131 || TREE_OPERAND (node, 2)
1132 || TREE_OPERAND (node, 3))
1134 pp_string (buffer, "{lb: ");
1135 dump_generic_node (buffer, op0, spc, flags, false);
1136 pp_string (buffer, " sz: ");
1137 dump_generic_node (buffer, op1, spc, flags, false);
1138 pp_character (buffer, '}');
1144 unsigned HOST_WIDE_INT ix;
1146 bool is_struct_init = FALSE;
1147 pp_character (buffer, '{');
1148 if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1149 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1150 is_struct_init = TRUE;
1151 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1153 if (field && is_struct_init)
1155 pp_character (buffer, '.');
1156 dump_generic_node (buffer, field, spc, flags, false);
1157 pp_string (buffer, "=");
1159 if (val && TREE_CODE (val) == ADDR_EXPR)
1160 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1161 val = TREE_OPERAND (val, 0);
1162 if (val && TREE_CODE (val) == FUNCTION_DECL)
1163 dump_decl_name (buffer, val, flags);
1165 dump_generic_node (buffer, val, spc, flags, false);
1166 if (ix != VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node)) - 1)
1168 pp_character (buffer, ',');
1172 pp_character (buffer, '}');
1179 if (flags & TDF_SLIM)
1181 pp_string (buffer, "<COMPOUND_EXPR>");
1185 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1186 spc, flags, !(flags & TDF_SLIM));
1187 if (flags & TDF_SLIM)
1188 newline_and_indent (buffer, spc);
1191 pp_character (buffer, ',');
1195 for (tp = &TREE_OPERAND (node, 1);
1196 TREE_CODE (*tp) == COMPOUND_EXPR;
1197 tp = &TREE_OPERAND (*tp, 1))
1199 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1200 spc, flags, !(flags & TDF_SLIM));
1201 if (flags & TDF_SLIM)
1202 newline_and_indent (buffer, spc);
1205 pp_character (buffer, ',');
1210 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1214 case STATEMENT_LIST:
1216 tree_stmt_iterator si;
1219 if (flags & TDF_SLIM)
1221 pp_string (buffer, "<STATEMENT_LIST>");
1225 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1228 newline_and_indent (buffer, spc);
1231 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1238 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1241 pp_character (buffer, '=');
1242 if (TREE_CODE (node) == MODIFY_EXPR
1243 && MOVE_NONTEMPORAL (node))
1244 pp_string (buffer, "{nt}");
1246 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1251 pp_string (buffer, "TARGET_EXPR <");
1252 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1253 pp_character (buffer, ',');
1255 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1256 pp_character (buffer, '>');
1260 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1265 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1267 pp_string (buffer, "if (");
1268 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1269 pp_character (buffer, ')');
1270 /* The lowered cond_exprs should always be printed in full. */
1271 if (COND_EXPR_THEN (node)
1272 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1273 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1274 && COND_EXPR_ELSE (node)
1275 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1276 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1279 dump_generic_node (buffer, COND_EXPR_THEN (node),
1281 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1283 pp_string (buffer, " else ");
1284 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1288 else if (!(flags & TDF_SLIM))
1290 /* Output COND_EXPR_THEN. */
1291 if (COND_EXPR_THEN (node))
1293 newline_and_indent (buffer, spc+2);
1294 pp_character (buffer, '{');
1295 newline_and_indent (buffer, spc+4);
1296 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1298 newline_and_indent (buffer, spc+2);
1299 pp_character (buffer, '}');
1302 /* Output COND_EXPR_ELSE. */
1303 if (COND_EXPR_ELSE (node)
1304 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1306 newline_and_indent (buffer, spc);
1307 pp_string (buffer, "else");
1308 newline_and_indent (buffer, spc+2);
1309 pp_character (buffer, '{');
1310 newline_and_indent (buffer, spc+4);
1311 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1313 newline_and_indent (buffer, spc+2);
1314 pp_character (buffer, '}');
1321 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1323 pp_character (buffer, '?');
1325 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1327 pp_character (buffer, ':');
1329 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1334 pp_character (buffer, '{');
1335 if (!(flags & TDF_SLIM))
1337 if (BIND_EXPR_VARS (node))
1339 pp_newline (buffer);
1341 for (op0 = BIND_EXPR_VARS (node); op0; op0 = TREE_CHAIN (op0))
1343 print_declaration (buffer, op0, spc+2, flags);
1344 pp_newline (buffer);
1348 newline_and_indent (buffer, spc+2);
1349 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1350 newline_and_indent (buffer, spc);
1351 pp_character (buffer, '}');
1357 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1359 /* Print parameters. */
1361 pp_character (buffer, '(');
1364 call_expr_arg_iterator iter;
1365 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1367 dump_generic_node (buffer, arg, spc, flags, false);
1368 if (more_call_expr_args_p (&iter))
1370 pp_character (buffer, ',');
1375 if (CALL_EXPR_VA_ARG_PACK (node))
1377 if (call_expr_nargs (node) > 0)
1379 pp_character (buffer, ',');
1382 pp_string (buffer, "__builtin_va_arg_pack ()");
1384 pp_character (buffer, ')');
1386 op1 = CALL_EXPR_STATIC_CHAIN (node);
1389 pp_string (buffer, " [static-chain: ");
1390 dump_generic_node (buffer, op1, spc, flags, false);
1391 pp_character (buffer, ']');
1394 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1395 pp_string (buffer, " [return slot optimization]");
1396 if (CALL_EXPR_TAILCALL (node))
1397 pp_string (buffer, " [tail call]");
1400 case WITH_CLEANUP_EXPR:
1404 case CLEANUP_POINT_EXPR:
1405 pp_string (buffer, "<<cleanup_point ");
1406 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1407 pp_string (buffer, ">>");
1410 case PLACEHOLDER_EXPR:
1411 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1412 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1413 pp_character (buffer, '>');
1416 /* Binary arithmetic and logic expressions. */
1417 case WIDEN_SUM_EXPR:
1418 case WIDEN_MULT_EXPR:
1421 case POINTER_PLUS_EXPR:
1423 case TRUNC_DIV_EXPR:
1425 case FLOOR_DIV_EXPR:
1426 case ROUND_DIV_EXPR:
1427 case TRUNC_MOD_EXPR:
1429 case FLOOR_MOD_EXPR:
1430 case ROUND_MOD_EXPR:
1432 case EXACT_DIV_EXPR:
1437 case VEC_LSHIFT_EXPR:
1438 case VEC_RSHIFT_EXPR:
1442 case TRUTH_ANDIF_EXPR:
1443 case TRUTH_ORIF_EXPR:
1444 case TRUTH_AND_EXPR:
1446 case TRUTH_XOR_EXPR:
1460 case UNORDERED_EXPR:
1462 const char *op = op_symbol (node);
1463 op0 = TREE_OPERAND (node, 0);
1464 op1 = TREE_OPERAND (node, 1);
1466 /* When the operands are expressions with less priority,
1467 keep semantics of the tree representation. */
1468 if (op_prio (op0) <= op_prio (node))
1470 pp_character (buffer, '(');
1471 dump_generic_node (buffer, op0, spc, flags, false);
1472 pp_character (buffer, ')');
1475 dump_generic_node (buffer, op0, spc, flags, false);
1478 pp_string (buffer, op);
1481 /* When the operands are expressions with less priority,
1482 keep semantics of the tree representation. */
1483 if (op_prio (op1) <= op_prio (node))
1485 pp_character (buffer, '(');
1486 dump_generic_node (buffer, op1, spc, flags, false);
1487 pp_character (buffer, ')');
1490 dump_generic_node (buffer, op1, spc, flags, false);
1494 /* Unary arithmetic and logic expressions. */
1497 case TRUTH_NOT_EXPR:
1499 case PREDECREMENT_EXPR:
1500 case PREINCREMENT_EXPR:
1501 case ALIGN_INDIRECT_REF:
1502 case MISALIGNED_INDIRECT_REF:
1504 if (TREE_CODE (node) == ADDR_EXPR
1505 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1506 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1507 ; /* Do not output '&' for strings and function pointers. */
1509 pp_string (buffer, op_symbol (node));
1511 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1513 pp_character (buffer, '(');
1514 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1515 pp_character (buffer, ')');
1518 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1520 if (TREE_CODE (node) == MISALIGNED_INDIRECT_REF)
1522 pp_string (buffer, "{misalignment: ");
1523 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1524 pp_character (buffer, '}');
1528 case POSTDECREMENT_EXPR:
1529 case POSTINCREMENT_EXPR:
1530 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1532 pp_character (buffer, '(');
1533 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1534 pp_character (buffer, ')');
1537 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1538 pp_string (buffer, op_symbol (node));
1542 pp_string (buffer, "MIN_EXPR <");
1543 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1544 pp_string (buffer, ", ");
1545 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1546 pp_character (buffer, '>');
1550 pp_string (buffer, "MAX_EXPR <");
1551 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1552 pp_string (buffer, ", ");
1553 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1554 pp_character (buffer, '>');
1558 pp_string (buffer, "ABS_EXPR <");
1559 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1560 pp_character (buffer, '>');
1567 case ADDR_SPACE_CONVERT_EXPR:
1568 case FIXED_CONVERT_EXPR:
1569 case FIX_TRUNC_EXPR:
1572 type = TREE_TYPE (node);
1573 op0 = TREE_OPERAND (node, 0);
1574 if (type != TREE_TYPE (op0))
1576 pp_character (buffer, '(');
1577 dump_generic_node (buffer, type, spc, flags, false);
1578 pp_string (buffer, ") ");
1580 if (op_prio (op0) < op_prio (node))
1581 pp_character (buffer, '(');
1582 dump_generic_node (buffer, op0, spc, flags, false);
1583 if (op_prio (op0) < op_prio (node))
1584 pp_character (buffer, ')');
1587 case VIEW_CONVERT_EXPR:
1588 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1589 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1590 pp_string (buffer, ">(");
1591 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1592 pp_character (buffer, ')');
1596 pp_string (buffer, "((");
1597 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1598 pp_string (buffer, "))");
1601 case NON_LVALUE_EXPR:
1602 pp_string (buffer, "NON_LVALUE_EXPR <");
1603 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1604 pp_character (buffer, '>');
1608 pp_string (buffer, "SAVE_EXPR <");
1609 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1610 pp_character (buffer, '>');
1614 pp_string (buffer, "COMPLEX_EXPR <");
1615 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1616 pp_string (buffer, ", ");
1617 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1618 pp_string (buffer, ">");
1622 pp_string (buffer, "CONJ_EXPR <");
1623 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1624 pp_string (buffer, ">");
1628 pp_string (buffer, "REALPART_EXPR <");
1629 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1630 pp_string (buffer, ">");
1634 pp_string (buffer, "IMAGPART_EXPR <");
1635 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1636 pp_string (buffer, ">");
1640 pp_string (buffer, "VA_ARG_EXPR <");
1641 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1642 pp_string (buffer, ">");
1645 case TRY_FINALLY_EXPR:
1646 case TRY_CATCH_EXPR:
1647 pp_string (buffer, "try");
1648 newline_and_indent (buffer, spc+2);
1649 pp_string (buffer, "{");
1650 newline_and_indent (buffer, spc+4);
1651 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
1652 newline_and_indent (buffer, spc+2);
1653 pp_string (buffer, "}");
1654 newline_and_indent (buffer, spc);
1656 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
1657 newline_and_indent (buffer, spc+2);
1658 pp_string (buffer, "{");
1659 newline_and_indent (buffer, spc+4);
1660 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
1661 newline_and_indent (buffer, spc+2);
1662 pp_string (buffer, "}");
1667 pp_string (buffer, "catch (");
1668 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
1669 pp_string (buffer, ")");
1670 newline_and_indent (buffer, spc+2);
1671 pp_string (buffer, "{");
1672 newline_and_indent (buffer, spc+4);
1673 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
1674 newline_and_indent (buffer, spc+2);
1675 pp_string (buffer, "}");
1679 case EH_FILTER_EXPR:
1680 pp_string (buffer, "<<<eh_filter (");
1681 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
1682 pp_string (buffer, ")>>>");
1683 newline_and_indent (buffer, spc+2);
1684 pp_string (buffer, "{");
1685 newline_and_indent (buffer, spc+4);
1686 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
1687 newline_and_indent (buffer, spc+2);
1688 pp_string (buffer, "}");
1693 op0 = TREE_OPERAND (node, 0);
1694 /* If this is for break or continue, don't bother printing it. */
1695 if (DECL_NAME (op0))
1697 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1698 if (strcmp (name, "break") == 0
1699 || strcmp (name, "continue") == 0)
1702 dump_generic_node (buffer, op0, spc, flags, false);
1703 pp_character (buffer, ':');
1704 if (DECL_NONLOCAL (op0))
1705 pp_string (buffer, " [non-local]");
1709 pp_string (buffer, "while (1)");
1710 if (!(flags & TDF_SLIM))
1712 newline_and_indent (buffer, spc+2);
1713 pp_character (buffer, '{');
1714 newline_and_indent (buffer, spc+4);
1715 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
1716 newline_and_indent (buffer, spc+2);
1717 pp_character (buffer, '}');
1723 pp_string (buffer, "// predicted ");
1724 if (PREDICT_EXPR_OUTCOME (node))
1725 pp_string (buffer, "likely by ");
1727 pp_string (buffer, "unlikely by ");
1728 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
1729 pp_string (buffer, " predictor.");
1733 pp_string (buffer, "return");
1734 op0 = TREE_OPERAND (node, 0);
1738 if (TREE_CODE (op0) == MODIFY_EXPR)
1739 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
1742 dump_generic_node (buffer, op0, spc, flags, false);
1747 pp_string (buffer, "if (");
1748 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1749 pp_string (buffer, ") break");
1753 pp_string (buffer, "switch (");
1754 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
1755 pp_character (buffer, ')');
1756 if (!(flags & TDF_SLIM))
1758 newline_and_indent (buffer, spc+2);
1759 pp_character (buffer, '{');
1760 if (SWITCH_BODY (node))
1762 newline_and_indent (buffer, spc+4);
1763 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
1768 tree vec = SWITCH_LABELS (node);
1769 size_t i, n = TREE_VEC_LENGTH (vec);
1770 for (i = 0; i < n; ++i)
1772 tree elt = TREE_VEC_ELT (vec, i);
1773 newline_and_indent (buffer, spc+4);
1776 dump_generic_node (buffer, elt, spc+4, flags, false);
1777 pp_string (buffer, " goto ");
1778 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
1780 pp_semicolon (buffer);
1783 pp_string (buffer, "case ???: goto ???;");
1786 newline_and_indent (buffer, spc+2);
1787 pp_character (buffer, '}');
1793 op0 = GOTO_DESTINATION (node);
1794 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
1796 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1797 if (strcmp (name, "break") == 0
1798 || strcmp (name, "continue") == 0)
1800 pp_string (buffer, name);
1804 pp_string (buffer, "goto ");
1805 dump_generic_node (buffer, op0, spc, flags, false);
1809 pp_string (buffer, "__asm__");
1810 if (ASM_VOLATILE_P (node))
1811 pp_string (buffer, " __volatile__");
1812 pp_character (buffer, '(');
1813 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
1814 pp_character (buffer, ':');
1815 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
1816 pp_character (buffer, ':');
1817 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
1818 if (ASM_CLOBBERS (node))
1820 pp_character (buffer, ':');
1821 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
1823 pp_string (buffer, ")");
1826 case CASE_LABEL_EXPR:
1827 if (CASE_LOW (node) && CASE_HIGH (node))
1829 pp_string (buffer, "case ");
1830 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1831 pp_string (buffer, " ... ");
1832 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
1834 else if (CASE_LOW (node))
1836 pp_string (buffer, "case ");
1837 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1840 pp_string (buffer, "default");
1841 pp_character (buffer, ':');
1845 pp_string (buffer, "OBJ_TYPE_REF(");
1846 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
1847 pp_character (buffer, ';');
1848 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
1849 pp_character (buffer, '-');
1850 pp_character (buffer, '>');
1851 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
1852 pp_character (buffer, ')');
1856 dump_generic_node (buffer, SSA_NAME_VAR (node), spc, flags, false);
1857 pp_string (buffer, "_");
1858 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
1859 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
1860 pp_string (buffer, "(ab)");
1861 else if (SSA_NAME_IS_DEFAULT_DEF (node))
1862 pp_string (buffer, "(D)");
1865 case WITH_SIZE_EXPR:
1866 pp_string (buffer, "WITH_SIZE_EXPR <");
1867 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1868 pp_string (buffer, ", ");
1869 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1870 pp_string (buffer, ">");
1874 pp_string (buffer, "ASSERT_EXPR <");
1875 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
1876 pp_string (buffer, ", ");
1877 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
1878 pp_string (buffer, ">");
1882 pp_string (buffer, "scev_known");
1885 case SCEV_NOT_KNOWN:
1886 pp_string (buffer, "scev_not_known");
1889 case POLYNOMIAL_CHREC:
1890 pp_string (buffer, "{");
1891 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
1892 pp_string (buffer, ", +, ");
1893 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
1894 pp_string (buffer, "}_");
1895 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
1899 case REALIGN_LOAD_EXPR:
1900 pp_string (buffer, "REALIGN_LOAD <");
1901 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1902 pp_string (buffer, ", ");
1903 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1904 pp_string (buffer, ", ");
1905 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1906 pp_string (buffer, ">");
1910 pp_string (buffer, " VEC_COND_EXPR < ");
1911 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1912 pp_string (buffer, " , ");
1913 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1914 pp_string (buffer, " , ");
1915 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1916 pp_string (buffer, " > ");
1920 pp_string (buffer, " DOT_PROD_EXPR < ");
1921 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1922 pp_string (buffer, ", ");
1923 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1924 pp_string (buffer, ", ");
1925 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1926 pp_string (buffer, " > ");
1930 pp_string (buffer, "#pragma omp parallel");
1931 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
1934 if (!(flags & TDF_SLIM) && OMP_BODY (node))
1936 newline_and_indent (buffer, spc + 2);
1937 pp_character (buffer, '{');
1938 newline_and_indent (buffer, spc + 4);
1939 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
1940 newline_and_indent (buffer, spc + 2);
1941 pp_character (buffer, '}');
1947 pp_string (buffer, "#pragma omp task");
1948 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
1952 pp_string (buffer, "#pragma omp for");
1953 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
1955 if (!(flags & TDF_SLIM))
1959 if (OMP_FOR_PRE_BODY (node))
1961 newline_and_indent (buffer, spc + 2);
1962 pp_character (buffer, '{');
1964 newline_and_indent (buffer, spc);
1965 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
1969 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
1972 newline_and_indent (buffer, spc);
1973 pp_string (buffer, "for (");
1974 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INIT (node), i),
1976 pp_string (buffer, "; ");
1977 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_COND (node), i),
1979 pp_string (buffer, "; ");
1980 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INCR (node), i),
1982 pp_string (buffer, ")");
1984 if (OMP_FOR_BODY (node))
1986 newline_and_indent (buffer, spc + 2);
1987 pp_character (buffer, '{');
1988 newline_and_indent (buffer, spc + 4);
1989 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
1991 newline_and_indent (buffer, spc + 2);
1992 pp_character (buffer, '}');
1994 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
1995 if (OMP_FOR_PRE_BODY (node))
1998 newline_and_indent (buffer, spc + 2);
1999 pp_character (buffer, '}');
2006 pp_string (buffer, "#pragma omp sections");
2007 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2011 pp_string (buffer, "#pragma omp section");
2015 pp_string (buffer, "#pragma omp master");
2019 pp_string (buffer, "#pragma omp ordered");
2023 pp_string (buffer, "#pragma omp critical");
2024 if (OMP_CRITICAL_NAME (node))
2027 pp_character (buffer, '(');
2028 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2030 pp_character (buffer, ')');
2035 pp_string (buffer, "#pragma omp atomic");
2036 newline_and_indent (buffer, spc + 2);
2037 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2039 pp_character (buffer, '=');
2041 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2045 pp_string (buffer, "#pragma omp single");
2046 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2050 dump_omp_clause (buffer, node, spc, flags);
2054 case REDUC_MAX_EXPR:
2055 pp_string (buffer, " REDUC_MAX_EXPR < ");
2056 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2057 pp_string (buffer, " > ");
2060 case REDUC_MIN_EXPR:
2061 pp_string (buffer, " REDUC_MIN_EXPR < ");
2062 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2063 pp_string (buffer, " > ");
2066 case REDUC_PLUS_EXPR:
2067 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2068 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2069 pp_string (buffer, " > ");
2072 case VEC_WIDEN_MULT_HI_EXPR:
2073 pp_string (buffer, " VEC_WIDEN_MULT_HI_EXPR < ");
2074 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2075 pp_string (buffer, ", ");
2076 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2077 pp_string (buffer, " > ");
2080 case VEC_WIDEN_MULT_LO_EXPR:
2081 pp_string (buffer, " VEC_WIDEN_MULT_LO_EXPR < ");
2082 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2083 pp_string (buffer, ", ");
2084 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2085 pp_string (buffer, " > ");
2088 case VEC_UNPACK_HI_EXPR:
2089 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2090 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2091 pp_string (buffer, " > ");
2094 case VEC_UNPACK_LO_EXPR:
2095 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2096 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2097 pp_string (buffer, " > ");
2100 case VEC_UNPACK_FLOAT_HI_EXPR:
2101 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2102 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2103 pp_string (buffer, " > ");
2106 case VEC_UNPACK_FLOAT_LO_EXPR:
2107 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2108 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2109 pp_string (buffer, " > ");
2112 case VEC_PACK_TRUNC_EXPR:
2113 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2114 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2115 pp_string (buffer, ", ");
2116 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2117 pp_string (buffer, " > ");
2120 case VEC_PACK_SAT_EXPR:
2121 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2122 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2123 pp_string (buffer, ", ");
2124 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2125 pp_string (buffer, " > ");
2128 case VEC_PACK_FIX_TRUNC_EXPR:
2129 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2130 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2131 pp_string (buffer, ", ");
2132 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2133 pp_string (buffer, " > ");
2137 dump_block_node (buffer, node, spc, flags);
2140 case VEC_EXTRACT_EVEN_EXPR:
2141 pp_string (buffer, " VEC_EXTRACT_EVEN_EXPR < ");
2142 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2143 pp_string (buffer, ", ");
2144 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2145 pp_string (buffer, " > ");
2148 case VEC_EXTRACT_ODD_EXPR:
2149 pp_string (buffer, " VEC_EXTRACT_ODD_EXPR < ");
2150 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2151 pp_string (buffer, ", ");
2152 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2153 pp_string (buffer, " > ");
2156 case VEC_INTERLEAVE_HIGH_EXPR:
2157 pp_string (buffer, " VEC_INTERLEAVE_HIGH_EXPR < ");
2158 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2159 pp_string (buffer, ", ");
2160 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2161 pp_string (buffer, " > ");
2164 case VEC_INTERLEAVE_LOW_EXPR:
2165 pp_string (buffer, " VEC_INTERLEAVE_LOW_EXPR < ");
2166 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2167 pp_string (buffer, ", ");
2168 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2169 pp_string (buffer, " > ");
2176 if (is_stmt && is_expr)
2177 pp_semicolon (buffer);
2179 /* If we're building a diagnostic, the formatted text will be written
2180 into BUFFER's stream by the caller; otherwise, write it now. */
2181 if (!(flags & TDF_DIAGNOSTIC))
2182 pp_write_text_to_stream (buffer);
2187 /* Print the declaration of a variable. */
2190 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2194 if (TREE_CODE (t) == TYPE_DECL)
2195 pp_string (buffer, "typedef ");
2197 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2198 pp_string (buffer, "register ");
2200 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2201 pp_string (buffer, "extern ");
2202 else if (TREE_STATIC (t))
2203 pp_string (buffer, "static ");
2205 /* Print the type and name. */
2206 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2210 /* Print array's type. */
2211 tmp = TREE_TYPE (t);
2212 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2213 tmp = TREE_TYPE (tmp);
2214 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2216 /* Print variable's name. */
2218 dump_generic_node (buffer, t, spc, flags, false);
2220 /* Print the dimensions. */
2221 tmp = TREE_TYPE (t);
2222 while (TREE_CODE (tmp) == ARRAY_TYPE)
2224 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2225 tmp = TREE_TYPE (tmp);
2228 else if (TREE_CODE (t) == FUNCTION_DECL)
2230 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2232 dump_decl_name (buffer, t, flags);
2233 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2237 /* Print type declaration. */
2238 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2240 /* Print variable's name. */
2242 dump_generic_node (buffer, t, spc, flags, false);
2245 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2247 pp_string (buffer, " __asm__ ");
2248 pp_character (buffer, '(');
2249 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2250 pp_character (buffer, ')');
2253 /* The initial value of a function serves to determine whether the function
2254 is declared or defined. So the following does not apply to function
2256 if (TREE_CODE (t) != FUNCTION_DECL)
2258 /* Print the initial value. */
2259 if (DECL_INITIAL (t))
2262 pp_character (buffer, '=');
2264 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2268 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2270 pp_string (buffer, " [value-expr: ");
2271 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2272 pp_character (buffer, ']');
2275 pp_character (buffer, ';');
2279 /* Prints a structure: name, fields, and methods.
2280 FIXME: Still incomplete. */
2283 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2285 /* Print the name of the structure. */
2286 if (TYPE_NAME (node))
2289 if (TREE_CODE (node) == RECORD_TYPE)
2290 pp_string (buffer, "struct ");
2291 else if ((TREE_CODE (node) == UNION_TYPE
2292 || TREE_CODE (node) == QUAL_UNION_TYPE))
2293 pp_string (buffer, "union ");
2295 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2298 /* Print the contents of the structure. */
2299 pp_newline (buffer);
2301 pp_character (buffer, '{');
2302 pp_newline (buffer);
2304 /* Print the fields of the structure. */
2307 tmp = TYPE_FIELDS (node);
2310 /* Avoid to print recursively the structure. */
2311 /* FIXME : Not implemented correctly...,
2312 what about the case when we have a cycle in the contain graph? ...
2313 Maybe this could be solved by looking at the scope in which the
2314 structure was declared. */
2315 if (TREE_TYPE (tmp) != node
2316 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2317 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2319 print_declaration (buffer, tmp, spc+2, flags);
2320 pp_newline (buffer);
2322 tmp = TREE_CHAIN (tmp);
2326 pp_character (buffer, '}');
2329 /* Return the priority of the operator CODE.
2331 From lowest to highest precedence with either left-to-right (L-R)
2332 or right-to-left (R-L) associativity]:
2335 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2347 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2348 15 [L-R] fn() [] -> .
2350 unary +, - and * have higher precedence than the corresponding binary
2354 op_code_prio (enum tree_code code)
2371 case TRUTH_ORIF_EXPR:
2374 case TRUTH_AND_EXPR:
2375 case TRUTH_ANDIF_EXPR:
2382 case TRUTH_XOR_EXPR:
2399 case UNORDERED_EXPR:
2412 case WIDEN_SUM_EXPR:
2414 case POINTER_PLUS_EXPR:
2418 case VEC_WIDEN_MULT_HI_EXPR:
2419 case VEC_WIDEN_MULT_LO_EXPR:
2420 case WIDEN_MULT_EXPR:
2423 case TRUNC_DIV_EXPR:
2425 case FLOOR_DIV_EXPR:
2426 case ROUND_DIV_EXPR:
2428 case EXACT_DIV_EXPR:
2429 case TRUNC_MOD_EXPR:
2431 case FLOOR_MOD_EXPR:
2432 case ROUND_MOD_EXPR:
2435 case TRUTH_NOT_EXPR:
2437 case POSTINCREMENT_EXPR:
2438 case POSTDECREMENT_EXPR:
2439 case PREINCREMENT_EXPR:
2440 case PREDECREMENT_EXPR:
2442 case ALIGN_INDIRECT_REF:
2443 case MISALIGNED_INDIRECT_REF:
2448 case FIX_TRUNC_EXPR:
2454 case ARRAY_RANGE_REF:
2458 /* Special expressions. */
2464 case REDUC_MAX_EXPR:
2465 case REDUC_MIN_EXPR:
2466 case REDUC_PLUS_EXPR:
2467 case VEC_LSHIFT_EXPR:
2468 case VEC_RSHIFT_EXPR:
2469 case VEC_UNPACK_HI_EXPR:
2470 case VEC_UNPACK_LO_EXPR:
2471 case VEC_UNPACK_FLOAT_HI_EXPR:
2472 case VEC_UNPACK_FLOAT_LO_EXPR:
2473 case VEC_PACK_TRUNC_EXPR:
2474 case VEC_PACK_SAT_EXPR:
2478 /* Return an arbitrarily high precedence to avoid surrounding single
2479 VAR_DECLs in ()s. */
2484 /* Return the priority of the operator OP. */
2487 op_prio (const_tree op)
2489 enum tree_code code;
2494 code = TREE_CODE (op);
2495 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
2496 return op_prio (TREE_OPERAND (op, 0));
2498 return op_code_prio (code);
2501 /* Return the symbol associated with operator CODE. */
2504 op_symbol_code (enum tree_code code)
2512 case TRUTH_ORIF_EXPR:
2515 case TRUTH_AND_EXPR:
2516 case TRUTH_ANDIF_EXPR:
2522 case TRUTH_XOR_EXPR:
2532 case UNORDERED_EXPR:
2578 case VEC_LSHIFT_EXPR:
2581 case VEC_RSHIFT_EXPR:
2584 case POINTER_PLUS_EXPR:
2590 case REDUC_PLUS_EXPR:
2593 case WIDEN_SUM_EXPR:
2596 case WIDEN_MULT_EXPR:
2606 case TRUTH_NOT_EXPR:
2613 case ALIGN_INDIRECT_REF:
2616 case MISALIGNED_INDIRECT_REF:
2619 case TRUNC_DIV_EXPR:
2626 case FLOOR_DIV_EXPR:
2629 case ROUND_DIV_EXPR:
2632 case EXACT_DIV_EXPR:
2635 case TRUNC_MOD_EXPR:
2641 case FLOOR_MOD_EXPR:
2644 case ROUND_MOD_EXPR:
2647 case PREDECREMENT_EXPR:
2650 case PREINCREMENT_EXPR:
2653 case POSTDECREMENT_EXPR:
2656 case POSTINCREMENT_EXPR:
2666 return "<<< ??? >>>";
2670 /* Return the symbol associated with operator OP. */
2673 op_symbol (const_tree op)
2675 return op_symbol_code (TREE_CODE (op));
2678 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2679 the gimple_call_fn of a GIMPLE_CALL. */
2682 print_call_name (pretty_printer *buffer, tree node, int flags)
2686 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
2687 op0 = TREE_OPERAND (op0, 0);
2690 switch (TREE_CODE (op0))
2695 dump_function_name (buffer, op0, flags);
2701 op0 = TREE_OPERAND (op0, 0);
2705 pp_string (buffer, "(");
2706 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
2707 pp_string (buffer, ") ? ");
2708 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
2709 pp_string (buffer, " : ");
2710 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
2714 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
2715 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
2717 dump_generic_node (buffer, op0, 0, flags, false);
2723 dump_generic_node (buffer, op0, 0, flags, false);
2731 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2734 pretty_print_string (pretty_printer *buffer, const char *str)
2744 pp_string (buffer, "\\b");
2748 pp_string (buffer, "\\f");
2752 pp_string (buffer, "\\n");
2756 pp_string (buffer, "\\r");
2760 pp_string (buffer, "\\t");
2764 pp_string (buffer, "\\v");
2768 pp_string (buffer, "\\\\");
2772 pp_string (buffer, "\\\"");
2776 pp_string (buffer, "\\'");
2779 /* No need to handle \0; the loop terminates on \0. */
2782 pp_string (buffer, "\\1");
2786 pp_string (buffer, "\\2");
2790 pp_string (buffer, "\\3");
2794 pp_string (buffer, "\\4");
2798 pp_string (buffer, "\\5");
2802 pp_string (buffer, "\\6");
2806 pp_string (buffer, "\\7");
2810 pp_character (buffer, str[0]);
2818 maybe_init_pretty_print (FILE *file)
2822 pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
2823 pp_needs_newline (&buffer) = true;
2824 pp_translate_identifiers (&buffer) = false;
2828 buffer.buffer->stream = file;
2832 newline_and_indent (pretty_printer *buffer, int spc)
2834 pp_newline (buffer);