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 tclass = TREE_CODE_CLASS (TREE_CODE (node));
662 if (tclass == tcc_declaration)
664 if (DECL_NAME (node))
665 dump_decl_name (buffer, node, flags);
667 pp_string (buffer, "<unnamed type decl>");
669 else if (tclass == tcc_type)
671 if (TYPE_NAME (node))
673 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
674 pp_tree_identifier (buffer, TYPE_NAME (node));
675 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
676 && DECL_NAME (TYPE_NAME (node)))
677 dump_decl_name (buffer, TYPE_NAME (node), flags);
679 pp_string (buffer, "<unnamed type>");
681 else if (TREE_CODE (node) == VECTOR_TYPE)
683 pp_string (buffer, "vector ");
684 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
686 else if (TREE_CODE (node) == INTEGER_TYPE)
688 pp_string (buffer, (TYPE_UNSIGNED (node)
689 ? "<unnamed-unsigned:"
690 : "<unnamed-signed:"));
691 pp_decimal_int (buffer, TYPE_PRECISION (node));
692 pp_string (buffer, ">");
694 else if (TREE_CODE (node) == COMPLEX_TYPE)
696 pp_string (buffer, "__complex__ ");
697 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
699 else if (TREE_CODE (node) == REAL_TYPE)
701 pp_string (buffer, "<float:");
702 pp_decimal_int (buffer, TYPE_PRECISION (node));
703 pp_string (buffer, ">");
705 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
707 pp_string (buffer, "<fixed-point-");
708 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
709 pp_decimal_int (buffer, TYPE_PRECISION (node));
710 pp_string (buffer, ">");
713 pp_string (buffer, "<unnamed type>");
720 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
722 if (TREE_TYPE (node) == NULL)
724 pp_string (buffer, str);
725 pp_string (buffer, "<null type>");
727 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
729 tree fnode = TREE_TYPE (node);
731 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
733 pp_character (buffer, '(');
734 pp_string (buffer, str);
735 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
736 dump_decl_name (buffer, TYPE_NAME (node), flags);
738 pp_printf (buffer, "<T%x>", TYPE_UID (node));
740 pp_character (buffer, ')');
741 dump_function_declaration (buffer, fnode, spc, flags);
745 unsigned int quals = TYPE_QUALS (node);
747 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
749 pp_string (buffer, str);
751 if (quals & TYPE_QUAL_CONST)
752 pp_string (buffer, " const");
753 if (quals & TYPE_QUAL_VOLATILE)
754 pp_string (buffer, " volatile");
755 if (quals & TYPE_QUAL_RESTRICT)
756 pp_string (buffer, " restrict");
758 if (TYPE_REF_CAN_ALIAS_ALL (node))
759 pp_string (buffer, " {ref-all}");
769 const char *sep = "";
772 pp_string (buffer, "MEM[");
774 tmp = TMR_SYMBOL (node);
777 pp_string (buffer, sep);
779 pp_string (buffer, "symbol: ");
780 dump_generic_node (buffer, tmp, spc, flags, false);
782 tmp = TMR_BASE (node);
785 pp_string (buffer, sep);
787 pp_string (buffer, "base: ");
788 dump_generic_node (buffer, tmp, spc, flags, false);
790 tmp = TMR_INDEX (node);
793 pp_string (buffer, sep);
795 pp_string (buffer, "index: ");
796 dump_generic_node (buffer, tmp, spc, flags, false);
798 tmp = TMR_STEP (node);
801 pp_string (buffer, sep);
803 pp_string (buffer, "step: ");
804 dump_generic_node (buffer, tmp, spc, flags, false);
806 tmp = TMR_OFFSET (node);
809 pp_string (buffer, sep);
811 pp_string (buffer, "offset: ");
812 dump_generic_node (buffer, tmp, spc, flags, false);
814 pp_string (buffer, "]");
815 if (flags & TDF_DETAILS)
817 pp_string (buffer, "{");
818 dump_generic_node (buffer, TMR_ORIGINAL (node), spc, flags,
820 pp_string (buffer, "}");
829 /* Print the innermost component type. */
830 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
831 tmp = TREE_TYPE (tmp))
833 dump_generic_node (buffer, tmp, spc, flags, false);
835 /* Print the dimensions. */
836 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
837 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
843 case QUAL_UNION_TYPE:
845 unsigned int quals = TYPE_QUALS (node);
847 if (quals & TYPE_QUAL_CONST)
848 pp_string (buffer, "const ");
849 if (quals & TYPE_QUAL_VOLATILE)
850 pp_string (buffer, "volatile ");
852 /* Print the name of the structure. */
853 if (TREE_CODE (node) == RECORD_TYPE)
854 pp_string (buffer, "struct ");
855 else if (TREE_CODE (node) == UNION_TYPE)
856 pp_string (buffer, "union ");
858 if (TYPE_NAME (node))
859 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
860 else if (!(flags & TDF_SLIM))
861 /* FIXME: If we eliminate the 'else' above and attempt
862 to show the fields for named types, we may get stuck
863 following a cycle of pointers to structs. The alleged
864 self-reference check in print_struct_decl will not detect
865 cycles involving more than one pointer or struct type. */
866 print_struct_decl (buffer, node, spc, flags);
875 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
877 /* In the case of a pointer, one may want to divide by the
878 size of the pointed-to type. Unfortunately, this not
879 straightforward. The C front-end maps expressions
884 in such a way that the two INTEGER_CST nodes for "5" have
885 different values but identical types. In the latter
886 case, the 5 is multiplied by sizeof (int) in c-common.c
887 (pointer_int_sum) to convert it to a byte address, and
888 yet the type of the node is left unchanged. Argh. What
889 is consistent though is that the number value corresponds
890 to bytes (UNITS) offset.
892 NB: Neither of the following divisors can be trivially
893 used to recover the original literal:
895 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
896 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
897 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
898 pp_string (buffer, "B"); /* pseudo-unit */
900 else if (! host_integerp (node, 0))
903 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val);
904 HOST_WIDE_INT high = TREE_INT_CST_HIGH (val);
906 if (tree_int_cst_sgn (val) < 0)
908 pp_character (buffer, '-');
912 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
914 sprintf (pp_buffer (buffer)->digit_buffer,
915 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
916 (unsigned HOST_WIDE_INT) high, low);
917 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
920 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
924 /* Code copied from print_node. */
927 if (TREE_OVERFLOW (node))
928 pp_string (buffer, " overflow");
930 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
931 d = TREE_REAL_CST (node);
932 if (REAL_VALUE_ISINF (d))
933 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
934 else if (REAL_VALUE_ISNAN (d))
935 pp_string (buffer, " Nan");
939 real_to_decimal (string, &d, sizeof (string), 0, 1);
940 pp_string (buffer, string);
945 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
946 pp_string (buffer, "0x");
947 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
948 output_formatted_integer (buffer, "%02x", *p++);
957 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
958 pp_string (buffer, string);
963 pp_string (buffer, "__complex__ (");
964 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
965 pp_string (buffer, ", ");
966 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
967 pp_string (buffer, ")");
971 pp_string (buffer, "\"");
972 pretty_print_string (buffer, TREE_STRING_POINTER (node));
973 pp_string (buffer, "\"");
979 pp_string (buffer, "{ ");
980 for (elt = TREE_VECTOR_CST_ELTS (node); elt; elt = TREE_CHAIN (elt))
982 dump_generic_node (buffer, TREE_VALUE (elt), spc, flags, false);
983 if (TREE_CHAIN (elt))
984 pp_string (buffer, ", ");
986 pp_string (buffer, " }");
992 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
994 if (TREE_CODE (node) == METHOD_TYPE)
996 if (TYPE_METHOD_BASETYPE (node))
997 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1000 pp_string (buffer, "<null method basetype>");
1001 pp_string (buffer, "::");
1003 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1004 dump_decl_name (buffer, TYPE_NAME (node), flags);
1006 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1007 dump_function_declaration (buffer, node, spc, flags);
1012 dump_decl_name (buffer, node, flags);
1016 if (DECL_NAME (node))
1017 dump_decl_name (buffer, node, flags);
1018 else if (LABEL_DECL_UID (node) != -1)
1019 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1021 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1025 if (DECL_IS_BUILTIN (node))
1027 /* Don't print the declaration of built-in types. */
1030 if (DECL_NAME (node))
1031 dump_decl_name (buffer, node, flags);
1034 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1035 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1036 && TYPE_METHODS (TREE_TYPE (node)))
1038 /* The type is a c++ class: all structures have at least
1040 pp_string (buffer, "class ");
1041 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1046 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1047 ? "union" : "struct "));
1048 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1056 case DEBUG_EXPR_DECL:
1057 case NAMESPACE_DECL:
1058 dump_decl_name (buffer, node, flags);
1062 pp_string (buffer, "<retval>");
1066 op0 = TREE_OPERAND (node, 0);
1068 if (op0 && TREE_CODE (op0) == INDIRECT_REF)
1070 op0 = TREE_OPERAND (op0, 0);
1073 if (op_prio (op0) < op_prio (node))
1074 pp_character (buffer, '(');
1075 dump_generic_node (buffer, op0, spc, flags, false);
1076 if (op_prio (op0) < op_prio (node))
1077 pp_character (buffer, ')');
1078 pp_string (buffer, str);
1079 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1080 op0 = component_ref_field_offset (node);
1081 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1083 pp_string (buffer, "{off: ");
1084 dump_generic_node (buffer, op0, spc, flags, false);
1085 pp_character (buffer, '}');
1090 pp_string (buffer, "BIT_FIELD_REF <");
1091 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1092 pp_string (buffer, ", ");
1093 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1094 pp_string (buffer, ", ");
1095 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1096 pp_string (buffer, ">");
1100 case ARRAY_RANGE_REF:
1101 op0 = TREE_OPERAND (node, 0);
1102 if (op_prio (op0) < op_prio (node))
1103 pp_character (buffer, '(');
1104 dump_generic_node (buffer, op0, spc, flags, false);
1105 if (op_prio (op0) < op_prio (node))
1106 pp_character (buffer, ')');
1107 pp_character (buffer, '[');
1108 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1109 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1110 pp_string (buffer, " ...");
1111 pp_character (buffer, ']');
1113 op0 = array_ref_low_bound (node);
1114 op1 = array_ref_element_size (node);
1116 if (!integer_zerop (op0)
1117 || TREE_OPERAND (node, 2)
1118 || TREE_OPERAND (node, 3))
1120 pp_string (buffer, "{lb: ");
1121 dump_generic_node (buffer, op0, spc, flags, false);
1122 pp_string (buffer, " sz: ");
1123 dump_generic_node (buffer, op1, spc, flags, false);
1124 pp_character (buffer, '}');
1130 unsigned HOST_WIDE_INT ix;
1132 bool is_struct_init = FALSE;
1133 pp_character (buffer, '{');
1134 if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1135 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1136 is_struct_init = TRUE;
1137 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1139 if (field && is_struct_init)
1141 pp_character (buffer, '.');
1142 dump_generic_node (buffer, field, spc, flags, false);
1143 pp_string (buffer, "=");
1145 if (val && TREE_CODE (val) == ADDR_EXPR)
1146 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1147 val = TREE_OPERAND (val, 0);
1148 if (val && TREE_CODE (val) == FUNCTION_DECL)
1149 dump_decl_name (buffer, val, flags);
1151 dump_generic_node (buffer, val, spc, flags, false);
1152 if (ix != VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node)) - 1)
1154 pp_character (buffer, ',');
1158 pp_character (buffer, '}');
1165 if (flags & TDF_SLIM)
1167 pp_string (buffer, "<COMPOUND_EXPR>");
1171 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1172 spc, flags, !(flags & TDF_SLIM));
1173 if (flags & TDF_SLIM)
1174 newline_and_indent (buffer, spc);
1177 pp_character (buffer, ',');
1181 for (tp = &TREE_OPERAND (node, 1);
1182 TREE_CODE (*tp) == COMPOUND_EXPR;
1183 tp = &TREE_OPERAND (*tp, 1))
1185 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1186 spc, flags, !(flags & TDF_SLIM));
1187 if (flags & TDF_SLIM)
1188 newline_and_indent (buffer, spc);
1191 pp_character (buffer, ',');
1196 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1200 case STATEMENT_LIST:
1202 tree_stmt_iterator si;
1205 if (flags & TDF_SLIM)
1207 pp_string (buffer, "<STATEMENT_LIST>");
1211 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1214 newline_and_indent (buffer, spc);
1217 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1224 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1227 pp_character (buffer, '=');
1228 if (TREE_CODE (node) == MODIFY_EXPR
1229 && MOVE_NONTEMPORAL (node))
1230 pp_string (buffer, "{nt}");
1232 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1237 pp_string (buffer, "TARGET_EXPR <");
1238 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1239 pp_character (buffer, ',');
1241 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1242 pp_character (buffer, '>');
1246 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1251 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1253 pp_string (buffer, "if (");
1254 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1255 pp_character (buffer, ')');
1256 /* The lowered cond_exprs should always be printed in full. */
1257 if (COND_EXPR_THEN (node)
1258 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1259 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1260 && COND_EXPR_ELSE (node)
1261 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1262 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1265 dump_generic_node (buffer, COND_EXPR_THEN (node),
1267 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1269 pp_string (buffer, " else ");
1270 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1274 else if (!(flags & TDF_SLIM))
1276 /* Output COND_EXPR_THEN. */
1277 if (COND_EXPR_THEN (node))
1279 newline_and_indent (buffer, spc+2);
1280 pp_character (buffer, '{');
1281 newline_and_indent (buffer, spc+4);
1282 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1284 newline_and_indent (buffer, spc+2);
1285 pp_character (buffer, '}');
1288 /* Output COND_EXPR_ELSE. */
1289 if (COND_EXPR_ELSE (node)
1290 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1292 newline_and_indent (buffer, spc);
1293 pp_string (buffer, "else");
1294 newline_and_indent (buffer, spc+2);
1295 pp_character (buffer, '{');
1296 newline_and_indent (buffer, spc+4);
1297 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1299 newline_and_indent (buffer, spc+2);
1300 pp_character (buffer, '}');
1307 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1309 pp_character (buffer, '?');
1311 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1313 pp_character (buffer, ':');
1315 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1320 pp_character (buffer, '{');
1321 if (!(flags & TDF_SLIM))
1323 if (BIND_EXPR_VARS (node))
1325 pp_newline (buffer);
1327 for (op0 = BIND_EXPR_VARS (node); op0; op0 = TREE_CHAIN (op0))
1329 print_declaration (buffer, op0, spc+2, flags);
1330 pp_newline (buffer);
1334 newline_and_indent (buffer, spc+2);
1335 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1336 newline_and_indent (buffer, spc);
1337 pp_character (buffer, '}');
1343 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1345 /* Print parameters. */
1347 pp_character (buffer, '(');
1350 call_expr_arg_iterator iter;
1351 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1353 dump_generic_node (buffer, arg, spc, flags, false);
1354 if (more_call_expr_args_p (&iter))
1356 pp_character (buffer, ',');
1361 if (CALL_EXPR_VA_ARG_PACK (node))
1363 if (call_expr_nargs (node) > 0)
1365 pp_character (buffer, ',');
1368 pp_string (buffer, "__builtin_va_arg_pack ()");
1370 pp_character (buffer, ')');
1372 op1 = CALL_EXPR_STATIC_CHAIN (node);
1375 pp_string (buffer, " [static-chain: ");
1376 dump_generic_node (buffer, op1, spc, flags, false);
1377 pp_character (buffer, ']');
1380 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1381 pp_string (buffer, " [return slot optimization]");
1382 if (CALL_EXPR_TAILCALL (node))
1383 pp_string (buffer, " [tail call]");
1386 case WITH_CLEANUP_EXPR:
1390 case CLEANUP_POINT_EXPR:
1391 pp_string (buffer, "<<cleanup_point ");
1392 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1393 pp_string (buffer, ">>");
1396 case PLACEHOLDER_EXPR:
1397 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1398 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1399 pp_character (buffer, '>');
1402 /* Binary arithmetic and logic expressions. */
1403 case WIDEN_SUM_EXPR:
1404 case WIDEN_MULT_EXPR:
1407 case POINTER_PLUS_EXPR:
1409 case TRUNC_DIV_EXPR:
1411 case FLOOR_DIV_EXPR:
1412 case ROUND_DIV_EXPR:
1413 case TRUNC_MOD_EXPR:
1415 case FLOOR_MOD_EXPR:
1416 case ROUND_MOD_EXPR:
1418 case EXACT_DIV_EXPR:
1423 case VEC_LSHIFT_EXPR:
1424 case VEC_RSHIFT_EXPR:
1428 case TRUTH_ANDIF_EXPR:
1429 case TRUTH_ORIF_EXPR:
1430 case TRUTH_AND_EXPR:
1432 case TRUTH_XOR_EXPR:
1446 case UNORDERED_EXPR:
1448 const char *op = op_symbol (node);
1449 op0 = TREE_OPERAND (node, 0);
1450 op1 = TREE_OPERAND (node, 1);
1452 /* When the operands are expressions with less priority,
1453 keep semantics of the tree representation. */
1454 if (op_prio (op0) <= op_prio (node))
1456 pp_character (buffer, '(');
1457 dump_generic_node (buffer, op0, spc, flags, false);
1458 pp_character (buffer, ')');
1461 dump_generic_node (buffer, op0, spc, flags, false);
1464 pp_string (buffer, op);
1467 /* When the operands are expressions with less priority,
1468 keep semantics of the tree representation. */
1469 if (op_prio (op1) <= op_prio (node))
1471 pp_character (buffer, '(');
1472 dump_generic_node (buffer, op1, spc, flags, false);
1473 pp_character (buffer, ')');
1476 dump_generic_node (buffer, op1, spc, flags, false);
1480 /* Unary arithmetic and logic expressions. */
1483 case TRUTH_NOT_EXPR:
1485 case PREDECREMENT_EXPR:
1486 case PREINCREMENT_EXPR:
1487 case ALIGN_INDIRECT_REF:
1488 case MISALIGNED_INDIRECT_REF:
1490 if (TREE_CODE (node) == ADDR_EXPR
1491 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1492 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1493 ; /* Do not output '&' for strings and function pointers. */
1495 pp_string (buffer, op_symbol (node));
1497 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1499 pp_character (buffer, '(');
1500 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1501 pp_character (buffer, ')');
1504 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1506 if (TREE_CODE (node) == MISALIGNED_INDIRECT_REF)
1508 pp_string (buffer, "{misalignment: ");
1509 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1510 pp_character (buffer, '}');
1514 case POSTDECREMENT_EXPR:
1515 case POSTINCREMENT_EXPR:
1516 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1518 pp_character (buffer, '(');
1519 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1520 pp_character (buffer, ')');
1523 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1524 pp_string (buffer, op_symbol (node));
1528 pp_string (buffer, "MIN_EXPR <");
1529 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1530 pp_string (buffer, ", ");
1531 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1532 pp_character (buffer, '>');
1536 pp_string (buffer, "MAX_EXPR <");
1537 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1538 pp_string (buffer, ", ");
1539 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1540 pp_character (buffer, '>');
1544 pp_string (buffer, "ABS_EXPR <");
1545 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1546 pp_character (buffer, '>');
1553 case FIXED_CONVERT_EXPR:
1554 case FIX_TRUNC_EXPR:
1557 type = TREE_TYPE (node);
1558 op0 = TREE_OPERAND (node, 0);
1559 if (type != TREE_TYPE (op0))
1561 pp_character (buffer, '(');
1562 dump_generic_node (buffer, type, spc, flags, false);
1563 pp_string (buffer, ") ");
1565 if (op_prio (op0) < op_prio (node))
1566 pp_character (buffer, '(');
1567 dump_generic_node (buffer, op0, spc, flags, false);
1568 if (op_prio (op0) < op_prio (node))
1569 pp_character (buffer, ')');
1572 case VIEW_CONVERT_EXPR:
1573 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1574 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1575 pp_string (buffer, ">(");
1576 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1577 pp_character (buffer, ')');
1581 pp_string (buffer, "((");
1582 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1583 pp_string (buffer, "))");
1586 case NON_LVALUE_EXPR:
1587 pp_string (buffer, "NON_LVALUE_EXPR <");
1588 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1589 pp_character (buffer, '>');
1593 pp_string (buffer, "SAVE_EXPR <");
1594 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1595 pp_character (buffer, '>');
1599 pp_string (buffer, "COMPLEX_EXPR <");
1600 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1601 pp_string (buffer, ", ");
1602 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1603 pp_string (buffer, ">");
1607 pp_string (buffer, "CONJ_EXPR <");
1608 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1609 pp_string (buffer, ">");
1613 pp_string (buffer, "REALPART_EXPR <");
1614 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1615 pp_string (buffer, ">");
1619 pp_string (buffer, "IMAGPART_EXPR <");
1620 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1621 pp_string (buffer, ">");
1625 pp_string (buffer, "VA_ARG_EXPR <");
1626 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1627 pp_string (buffer, ">");
1630 case TRY_FINALLY_EXPR:
1631 case TRY_CATCH_EXPR:
1632 pp_string (buffer, "try");
1633 newline_and_indent (buffer, spc+2);
1634 pp_string (buffer, "{");
1635 newline_and_indent (buffer, spc+4);
1636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
1637 newline_and_indent (buffer, spc+2);
1638 pp_string (buffer, "}");
1639 newline_and_indent (buffer, spc);
1641 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
1642 newline_and_indent (buffer, spc+2);
1643 pp_string (buffer, "{");
1644 newline_and_indent (buffer, spc+4);
1645 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
1646 newline_and_indent (buffer, spc+2);
1647 pp_string (buffer, "}");
1652 pp_string (buffer, "catch (");
1653 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
1654 pp_string (buffer, ")");
1655 newline_and_indent (buffer, spc+2);
1656 pp_string (buffer, "{");
1657 newline_and_indent (buffer, spc+4);
1658 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
1659 newline_and_indent (buffer, spc+2);
1660 pp_string (buffer, "}");
1664 case EH_FILTER_EXPR:
1665 pp_string (buffer, "<<<eh_filter (");
1666 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
1667 pp_string (buffer, ")>>>");
1668 newline_and_indent (buffer, spc+2);
1669 pp_string (buffer, "{");
1670 newline_and_indent (buffer, spc+4);
1671 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
1672 newline_and_indent (buffer, spc+2);
1673 pp_string (buffer, "}");
1678 op0 = TREE_OPERAND (node, 0);
1679 /* If this is for break or continue, don't bother printing it. */
1680 if (DECL_NAME (op0))
1682 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1683 if (strcmp (name, "break") == 0
1684 || strcmp (name, "continue") == 0)
1687 dump_generic_node (buffer, op0, spc, flags, false);
1688 pp_character (buffer, ':');
1689 if (DECL_NONLOCAL (op0))
1690 pp_string (buffer, " [non-local]");
1694 pp_string (buffer, "while (1)");
1695 if (!(flags & TDF_SLIM))
1697 newline_and_indent (buffer, spc+2);
1698 pp_character (buffer, '{');
1699 newline_and_indent (buffer, spc+4);
1700 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
1701 newline_and_indent (buffer, spc+2);
1702 pp_character (buffer, '}');
1708 pp_string (buffer, "// predicted ");
1709 if (PREDICT_EXPR_OUTCOME (node))
1710 pp_string (buffer, "likely by ");
1712 pp_string (buffer, "unlikely by ");
1713 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
1714 pp_string (buffer, " predictor.");
1718 pp_string (buffer, "return");
1719 op0 = TREE_OPERAND (node, 0);
1723 if (TREE_CODE (op0) == MODIFY_EXPR)
1724 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
1727 dump_generic_node (buffer, op0, spc, flags, false);
1732 pp_string (buffer, "if (");
1733 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1734 pp_string (buffer, ") break");
1738 pp_string (buffer, "switch (");
1739 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
1740 pp_character (buffer, ')');
1741 if (!(flags & TDF_SLIM))
1743 newline_and_indent (buffer, spc+2);
1744 pp_character (buffer, '{');
1745 if (SWITCH_BODY (node))
1747 newline_and_indent (buffer, spc+4);
1748 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
1753 tree vec = SWITCH_LABELS (node);
1754 size_t i, n = TREE_VEC_LENGTH (vec);
1755 for (i = 0; i < n; ++i)
1757 tree elt = TREE_VEC_ELT (vec, i);
1758 newline_and_indent (buffer, spc+4);
1761 dump_generic_node (buffer, elt, spc+4, flags, false);
1762 pp_string (buffer, " goto ");
1763 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
1765 pp_semicolon (buffer);
1768 pp_string (buffer, "case ???: goto ???;");
1771 newline_and_indent (buffer, spc+2);
1772 pp_character (buffer, '}');
1778 op0 = GOTO_DESTINATION (node);
1779 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
1781 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1782 if (strcmp (name, "break") == 0
1783 || strcmp (name, "continue") == 0)
1785 pp_string (buffer, name);
1789 pp_string (buffer, "goto ");
1790 dump_generic_node (buffer, op0, spc, flags, false);
1794 pp_string (buffer, "__asm__");
1795 if (ASM_VOLATILE_P (node))
1796 pp_string (buffer, " __volatile__");
1797 pp_character (buffer, '(');
1798 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
1799 pp_character (buffer, ':');
1800 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
1801 pp_character (buffer, ':');
1802 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
1803 if (ASM_CLOBBERS (node))
1805 pp_character (buffer, ':');
1806 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
1808 pp_string (buffer, ")");
1811 case CASE_LABEL_EXPR:
1812 if (CASE_LOW (node) && CASE_HIGH (node))
1814 pp_string (buffer, "case ");
1815 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1816 pp_string (buffer, " ... ");
1817 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
1819 else if (CASE_LOW (node))
1821 pp_string (buffer, "case ");
1822 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
1825 pp_string (buffer, "default");
1826 pp_character (buffer, ':');
1830 pp_string (buffer, "OBJ_TYPE_REF(");
1831 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
1832 pp_character (buffer, ';');
1833 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
1834 pp_character (buffer, '-');
1835 pp_character (buffer, '>');
1836 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
1837 pp_character (buffer, ')');
1841 dump_generic_node (buffer, SSA_NAME_VAR (node), spc, flags, false);
1842 pp_string (buffer, "_");
1843 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
1844 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
1845 pp_string (buffer, "(ab)");
1846 else if (SSA_NAME_IS_DEFAULT_DEF (node))
1847 pp_string (buffer, "(D)");
1850 case WITH_SIZE_EXPR:
1851 pp_string (buffer, "WITH_SIZE_EXPR <");
1852 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1853 pp_string (buffer, ", ");
1854 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1855 pp_string (buffer, ">");
1859 pp_string (buffer, "ASSERT_EXPR <");
1860 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
1861 pp_string (buffer, ", ");
1862 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
1863 pp_string (buffer, ">");
1867 pp_string (buffer, "scev_known");
1870 case SCEV_NOT_KNOWN:
1871 pp_string (buffer, "scev_not_known");
1874 case POLYNOMIAL_CHREC:
1875 pp_string (buffer, "{");
1876 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
1877 pp_string (buffer, ", +, ");
1878 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
1879 pp_string (buffer, "}_");
1880 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
1884 case REALIGN_LOAD_EXPR:
1885 pp_string (buffer, "REALIGN_LOAD <");
1886 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1887 pp_string (buffer, ", ");
1888 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1889 pp_string (buffer, ", ");
1890 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1891 pp_string (buffer, ">");
1895 pp_string (buffer, " VEC_COND_EXPR < ");
1896 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1897 pp_string (buffer, " , ");
1898 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1899 pp_string (buffer, " , ");
1900 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1901 pp_string (buffer, " > ");
1905 pp_string (buffer, " DOT_PROD_EXPR < ");
1906 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1907 pp_string (buffer, ", ");
1908 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1909 pp_string (buffer, ", ");
1910 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1911 pp_string (buffer, " > ");
1915 pp_string (buffer, "#pragma omp parallel");
1916 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
1919 if (!(flags & TDF_SLIM) && OMP_BODY (node))
1921 newline_and_indent (buffer, spc + 2);
1922 pp_character (buffer, '{');
1923 newline_and_indent (buffer, spc + 4);
1924 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
1925 newline_and_indent (buffer, spc + 2);
1926 pp_character (buffer, '}');
1932 pp_string (buffer, "#pragma omp task");
1933 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
1937 pp_string (buffer, "#pragma omp for");
1938 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
1940 if (!(flags & TDF_SLIM))
1944 if (OMP_FOR_PRE_BODY (node))
1946 newline_and_indent (buffer, spc + 2);
1947 pp_character (buffer, '{');
1949 newline_and_indent (buffer, spc);
1950 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
1954 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
1957 newline_and_indent (buffer, spc);
1958 pp_string (buffer, "for (");
1959 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INIT (node), i),
1961 pp_string (buffer, "; ");
1962 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_COND (node), i),
1964 pp_string (buffer, "; ");
1965 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INCR (node), i),
1967 pp_string (buffer, ")");
1969 if (OMP_FOR_BODY (node))
1971 newline_and_indent (buffer, spc + 2);
1972 pp_character (buffer, '{');
1973 newline_and_indent (buffer, spc + 4);
1974 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
1976 newline_and_indent (buffer, spc + 2);
1977 pp_character (buffer, '}');
1979 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
1980 if (OMP_FOR_PRE_BODY (node))
1983 newline_and_indent (buffer, spc + 2);
1984 pp_character (buffer, '}');
1991 pp_string (buffer, "#pragma omp sections");
1992 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
1996 pp_string (buffer, "#pragma omp section");
2000 pp_string (buffer, "#pragma omp master");
2004 pp_string (buffer, "#pragma omp ordered");
2008 pp_string (buffer, "#pragma omp critical");
2009 if (OMP_CRITICAL_NAME (node))
2012 pp_character (buffer, '(');
2013 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2015 pp_character (buffer, ')');
2020 pp_string (buffer, "#pragma omp atomic");
2021 newline_and_indent (buffer, spc + 2);
2022 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2024 pp_character (buffer, '=');
2026 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2030 pp_string (buffer, "#pragma omp single");
2031 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2035 dump_omp_clause (buffer, node, spc, flags);
2039 case REDUC_MAX_EXPR:
2040 pp_string (buffer, " REDUC_MAX_EXPR < ");
2041 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2042 pp_string (buffer, " > ");
2045 case REDUC_MIN_EXPR:
2046 pp_string (buffer, " REDUC_MIN_EXPR < ");
2047 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2048 pp_string (buffer, " > ");
2051 case REDUC_PLUS_EXPR:
2052 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2053 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2054 pp_string (buffer, " > ");
2057 case VEC_WIDEN_MULT_HI_EXPR:
2058 pp_string (buffer, " VEC_WIDEN_MULT_HI_EXPR < ");
2059 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2060 pp_string (buffer, ", ");
2061 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2062 pp_string (buffer, " > ");
2065 case VEC_WIDEN_MULT_LO_EXPR:
2066 pp_string (buffer, " VEC_WIDEN_MULT_LO_EXPR < ");
2067 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2068 pp_string (buffer, ", ");
2069 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2070 pp_string (buffer, " > ");
2073 case VEC_UNPACK_HI_EXPR:
2074 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2075 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2076 pp_string (buffer, " > ");
2079 case VEC_UNPACK_LO_EXPR:
2080 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2081 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2082 pp_string (buffer, " > ");
2085 case VEC_UNPACK_FLOAT_HI_EXPR:
2086 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2087 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2088 pp_string (buffer, " > ");
2091 case VEC_UNPACK_FLOAT_LO_EXPR:
2092 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2093 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2094 pp_string (buffer, " > ");
2097 case VEC_PACK_TRUNC_EXPR:
2098 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2099 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2100 pp_string (buffer, ", ");
2101 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2102 pp_string (buffer, " > ");
2105 case VEC_PACK_SAT_EXPR:
2106 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2107 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2108 pp_string (buffer, ", ");
2109 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2110 pp_string (buffer, " > ");
2113 case VEC_PACK_FIX_TRUNC_EXPR:
2114 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2115 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2116 pp_string (buffer, ", ");
2117 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2118 pp_string (buffer, " > ");
2122 dump_block_node (buffer, node, spc, flags);
2125 case VEC_EXTRACT_EVEN_EXPR:
2126 pp_string (buffer, " VEC_EXTRACT_EVEN_EXPR < ");
2127 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2128 pp_string (buffer, ", ");
2129 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2130 pp_string (buffer, " > ");
2133 case VEC_EXTRACT_ODD_EXPR:
2134 pp_string (buffer, " VEC_EXTRACT_ODD_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, " > ");
2141 case VEC_INTERLEAVE_HIGH_EXPR:
2142 pp_string (buffer, " VEC_INTERLEAVE_HIGH_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, " > ");
2149 case VEC_INTERLEAVE_LOW_EXPR:
2150 pp_string (buffer, " VEC_INTERLEAVE_LOW_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, " > ");
2161 if (is_stmt && is_expr)
2162 pp_semicolon (buffer);
2164 /* If we're building a diagnostic, the formatted text will be written
2165 into BUFFER's stream by the caller; otherwise, write it now. */
2166 if (!(flags & TDF_DIAGNOSTIC))
2167 pp_write_text_to_stream (buffer);
2172 /* Print the declaration of a variable. */
2175 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2179 if (TREE_CODE (t) == TYPE_DECL)
2180 pp_string (buffer, "typedef ");
2182 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2183 pp_string (buffer, "register ");
2185 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2186 pp_string (buffer, "extern ");
2187 else if (TREE_STATIC (t))
2188 pp_string (buffer, "static ");
2190 /* Print the type and name. */
2191 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2195 /* Print array's type. */
2196 tmp = TREE_TYPE (t);
2197 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2198 tmp = TREE_TYPE (tmp);
2199 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2201 /* Print variable's name. */
2203 dump_generic_node (buffer, t, spc, flags, false);
2205 /* Print the dimensions. */
2206 tmp = TREE_TYPE (t);
2207 while (TREE_CODE (tmp) == ARRAY_TYPE)
2209 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2210 tmp = TREE_TYPE (tmp);
2213 else if (TREE_CODE (t) == FUNCTION_DECL)
2215 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2217 dump_decl_name (buffer, t, flags);
2218 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2222 /* Print type declaration. */
2223 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2225 /* Print variable's name. */
2227 dump_generic_node (buffer, t, spc, flags, false);
2230 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2232 pp_string (buffer, " __asm__ ");
2233 pp_character (buffer, '(');
2234 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2235 pp_character (buffer, ')');
2238 /* The initial value of a function serves to determine whether the function
2239 is declared or defined. So the following does not apply to function
2241 if (TREE_CODE (t) != FUNCTION_DECL)
2243 /* Print the initial value. */
2244 if (DECL_INITIAL (t))
2247 pp_character (buffer, '=');
2249 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2253 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2255 pp_string (buffer, " [value-expr: ");
2256 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2257 pp_character (buffer, ']');
2260 pp_character (buffer, ';');
2264 /* Prints a structure: name, fields, and methods.
2265 FIXME: Still incomplete. */
2268 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2270 /* Print the name of the structure. */
2271 if (TYPE_NAME (node))
2274 if (TREE_CODE (node) == RECORD_TYPE)
2275 pp_string (buffer, "struct ");
2276 else if ((TREE_CODE (node) == UNION_TYPE
2277 || TREE_CODE (node) == QUAL_UNION_TYPE))
2278 pp_string (buffer, "union ");
2280 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2283 /* Print the contents of the structure. */
2284 pp_newline (buffer);
2286 pp_character (buffer, '{');
2287 pp_newline (buffer);
2289 /* Print the fields of the structure. */
2292 tmp = TYPE_FIELDS (node);
2295 /* Avoid to print recursively the structure. */
2296 /* FIXME : Not implemented correctly...,
2297 what about the case when we have a cycle in the contain graph? ...
2298 Maybe this could be solved by looking at the scope in which the
2299 structure was declared. */
2300 if (TREE_TYPE (tmp) != node
2301 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2302 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2304 print_declaration (buffer, tmp, spc+2, flags);
2305 pp_newline (buffer);
2307 tmp = TREE_CHAIN (tmp);
2311 pp_character (buffer, '}');
2314 /* Return the priority of the operator CODE.
2316 From lowest to highest precedence with either left-to-right (L-R)
2317 or right-to-left (R-L) associativity]:
2320 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2332 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2333 15 [L-R] fn() [] -> .
2335 unary +, - and * have higher precedence than the corresponding binary
2339 op_code_prio (enum tree_code code)
2356 case TRUTH_ORIF_EXPR:
2359 case TRUTH_AND_EXPR:
2360 case TRUTH_ANDIF_EXPR:
2367 case TRUTH_XOR_EXPR:
2384 case UNORDERED_EXPR:
2397 case WIDEN_SUM_EXPR:
2399 case POINTER_PLUS_EXPR:
2403 case VEC_WIDEN_MULT_HI_EXPR:
2404 case VEC_WIDEN_MULT_LO_EXPR:
2405 case WIDEN_MULT_EXPR:
2408 case TRUNC_DIV_EXPR:
2410 case FLOOR_DIV_EXPR:
2411 case ROUND_DIV_EXPR:
2413 case EXACT_DIV_EXPR:
2414 case TRUNC_MOD_EXPR:
2416 case FLOOR_MOD_EXPR:
2417 case ROUND_MOD_EXPR:
2420 case TRUTH_NOT_EXPR:
2422 case POSTINCREMENT_EXPR:
2423 case POSTDECREMENT_EXPR:
2424 case PREINCREMENT_EXPR:
2425 case PREDECREMENT_EXPR:
2427 case ALIGN_INDIRECT_REF:
2428 case MISALIGNED_INDIRECT_REF:
2433 case FIX_TRUNC_EXPR:
2439 case ARRAY_RANGE_REF:
2443 /* Special expressions. */
2449 case REDUC_MAX_EXPR:
2450 case REDUC_MIN_EXPR:
2451 case REDUC_PLUS_EXPR:
2452 case VEC_LSHIFT_EXPR:
2453 case VEC_RSHIFT_EXPR:
2454 case VEC_UNPACK_HI_EXPR:
2455 case VEC_UNPACK_LO_EXPR:
2456 case VEC_UNPACK_FLOAT_HI_EXPR:
2457 case VEC_UNPACK_FLOAT_LO_EXPR:
2458 case VEC_PACK_TRUNC_EXPR:
2459 case VEC_PACK_SAT_EXPR:
2463 /* Return an arbitrarily high precedence to avoid surrounding single
2464 VAR_DECLs in ()s. */
2469 /* Return the priority of the operator OP. */
2472 op_prio (const_tree op)
2474 enum tree_code code;
2479 code = TREE_CODE (op);
2480 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
2481 return op_prio (TREE_OPERAND (op, 0));
2483 return op_code_prio (code);
2486 /* Return the symbol associated with operator CODE. */
2489 op_symbol_code (enum tree_code code)
2497 case TRUTH_ORIF_EXPR:
2500 case TRUTH_AND_EXPR:
2501 case TRUTH_ANDIF_EXPR:
2507 case TRUTH_XOR_EXPR:
2517 case UNORDERED_EXPR:
2563 case VEC_LSHIFT_EXPR:
2566 case VEC_RSHIFT_EXPR:
2569 case POINTER_PLUS_EXPR:
2575 case REDUC_PLUS_EXPR:
2578 case WIDEN_SUM_EXPR:
2581 case WIDEN_MULT_EXPR:
2591 case TRUTH_NOT_EXPR:
2598 case ALIGN_INDIRECT_REF:
2601 case MISALIGNED_INDIRECT_REF:
2604 case TRUNC_DIV_EXPR:
2611 case FLOOR_DIV_EXPR:
2614 case ROUND_DIV_EXPR:
2617 case EXACT_DIV_EXPR:
2620 case TRUNC_MOD_EXPR:
2626 case FLOOR_MOD_EXPR:
2629 case ROUND_MOD_EXPR:
2632 case PREDECREMENT_EXPR:
2635 case PREINCREMENT_EXPR:
2638 case POSTDECREMENT_EXPR:
2641 case POSTINCREMENT_EXPR:
2651 return "<<< ??? >>>";
2655 /* Return the symbol associated with operator OP. */
2658 op_symbol (const_tree op)
2660 return op_symbol_code (TREE_CODE (op));
2663 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2664 the gimple_call_fn of a GIMPLE_CALL. */
2667 print_call_name (pretty_printer *buffer, tree node, int flags)
2671 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
2672 op0 = TREE_OPERAND (op0, 0);
2675 switch (TREE_CODE (op0))
2680 dump_function_name (buffer, op0, flags);
2686 op0 = TREE_OPERAND (op0, 0);
2690 pp_string (buffer, "(");
2691 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
2692 pp_string (buffer, ") ? ");
2693 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
2694 pp_string (buffer, " : ");
2695 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
2699 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
2700 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
2702 dump_generic_node (buffer, op0, 0, flags, false);
2708 dump_generic_node (buffer, op0, 0, flags, false);
2716 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2719 pretty_print_string (pretty_printer *buffer, const char *str)
2729 pp_string (buffer, "\\b");
2733 pp_string (buffer, "\\f");
2737 pp_string (buffer, "\\n");
2741 pp_string (buffer, "\\r");
2745 pp_string (buffer, "\\t");
2749 pp_string (buffer, "\\v");
2753 pp_string (buffer, "\\\\");
2757 pp_string (buffer, "\\\"");
2761 pp_string (buffer, "\\'");
2764 /* No need to handle \0; the loop terminates on \0. */
2767 pp_string (buffer, "\\1");
2771 pp_string (buffer, "\\2");
2775 pp_string (buffer, "\\3");
2779 pp_string (buffer, "\\4");
2783 pp_string (buffer, "\\5");
2787 pp_string (buffer, "\\6");
2791 pp_string (buffer, "\\7");
2795 pp_character (buffer, str[0]);
2803 maybe_init_pretty_print (FILE *file)
2807 pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
2808 pp_needs_newline (&buffer) = true;
2809 pp_translate_identifiers (&buffer) = false;
2813 buffer.buffer->stream = file;
2817 newline_and_indent (pretty_printer *buffer, int spc)
2819 pp_newline (buffer);