1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "coretypes.h"
28 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "langhooks.h"
33 #include "tree-iterator.h"
35 /* Local functions, macros and variables. */
36 static int op_prio (tree
);
37 static const char *op_symbol (tree
);
38 static void pretty_print_string (pretty_printer
*, const char*);
39 static void print_call_name (pretty_printer
*, tree
);
40 static void newline_and_indent (pretty_printer
*, int);
41 static void maybe_init_pretty_print (FILE *);
42 static void print_declaration (pretty_printer
*, tree
, int, int);
43 static void print_struct_decl (pretty_printer
*, tree
, int);
44 static void dump_block_info (pretty_printer
*, basic_block
, int);
45 static void do_niy (pretty_printer
*, tree
);
46 static void dump_vops (pretty_printer
*, tree
, int);
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 #define PRINT_FUNCTION_NAME(NODE) pp_printf \
54 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \
55 (*lang_hooks.decl_printable_name) (TREE_OPERAND (NODE, 0), 1) : \
56 (*lang_hooks.decl_printable_name) (NODE, 1))
58 #define MASK_POINTER(P) ((unsigned)((unsigned long)(P) & 0xffff))
60 static pretty_printer buffer
;
61 static int initialized
= 0;
62 static basic_block last_bb
;
63 static bool dumping_stmts
;
65 /* Try to print something for an unknown tree code. */
68 do_niy (pretty_printer
*buffer
, tree node
)
72 pp_string (buffer
, "<<< Unknown tree: ");
73 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
75 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (node
))))
77 len
= first_rtl_op (TREE_CODE (node
));
78 for (i
= 0; i
< len
; ++i
)
80 newline_and_indent (buffer
, 2);
81 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0);
85 pp_string (buffer
, " >>>\n");
89 debug_generic_expr (tree t
)
91 print_generic_expr (stderr
, t
, TDF_VOPS
);
92 fprintf (stderr
, "\n");
96 debug_generic_stmt (tree t
)
98 print_generic_stmt (stderr
, t
, TDF_VOPS
);
99 fprintf (stderr
, "\n");
102 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
103 to show in the dump. See TDF_* in tree.h. */
106 print_generic_stmt (FILE *file
, tree t
, int flags
)
108 maybe_init_pretty_print (file
);
109 dumping_stmts
= true;
110 dump_generic_node (&buffer
, t
, 0, flags
);
115 /* Print a single expression T on file FILE. FLAGS specifies details to show
116 in the dump. See TDF_* in tree.h. */
119 print_generic_expr (FILE *file
, tree t
, int flags
)
121 maybe_init_pretty_print (file
);
122 dumping_stmts
= false;
123 dump_generic_node (&buffer
, t
, 0, flags
);
127 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent.
128 FLAGS specifies details to show in the dump (see TDF_* in tree.h). */
131 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
)
136 tree_stmt_iterator si
;
138 if (node
== NULL_TREE
)
141 if (TREE_CODE (node
) != ERROR_MARK
142 && is_gimple_stmt (node
))
144 basic_block curr_bb
= bb_for_stmt (node
);
146 if ((flags
& TDF_BLOCKS
) && curr_bb
&& curr_bb
!= last_bb
)
147 dump_block_info (buffer
, curr_bb
, spc
);
149 if ((flags
& TDF_VOPS
) && stmt_ann (node
))
150 dump_vops (buffer
, node
, spc
);
152 if (curr_bb
&& curr_bb
!= last_bb
)
156 switch (TREE_CODE (node
))
159 pp_string (buffer
, "<<< error >>>");
162 case IDENTIFIER_NODE
:
163 pp_tree_identifier (buffer
, node
);
167 while (node
&& node
!= error_mark_node
)
169 if (TREE_PURPOSE (node
))
171 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
);
174 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
);
175 node
= TREE_CHAIN (node
);
176 if (node
&& TREE_CODE (node
) == TREE_LIST
)
178 pp_character (buffer
, ',');
185 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
);
201 unsigned int quals
= TYPE_QUALS (node
);
204 if (quals
& TYPE_QUAL_CONST
)
205 pp_string (buffer
, "const ");
206 else if (quals
& TYPE_QUAL_VOLATILE
)
207 pp_string (buffer
, "volatile ");
208 else if (quals
& TYPE_QUAL_RESTRICT
)
209 pp_string (buffer
, "restrict ");
211 class = TREE_CODE_CLASS (TREE_CODE (node
));
215 if (DECL_NAME (node
))
216 pp_tree_identifier (buffer
, DECL_NAME (node
));
218 pp_string (buffer
, "<unnamed type decl>");
220 else if (class == 't')
222 if (TYPE_NAME (node
))
224 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
226 IDENTIFIER_POINTER (TYPE_NAME (node
)));
227 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
228 && DECL_NAME (TYPE_NAME (node
)))
230 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
232 pp_string (buffer
, "<unnamed type>");
235 pp_string (buffer
, "<unnamed type>");
242 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
244 if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
246 tree fnode
= TREE_TYPE (node
);
247 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
);
249 pp_character (buffer
, '(');
250 pp_string (buffer
, str
);
251 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
252 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
254 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
256 pp_character (buffer
, ')');
258 pp_character (buffer
, '(');
259 /* Print the argument types. The last element in the list is a
260 VOID_TYPE. The following avoid to print the last element. */
262 tree tmp
= TYPE_ARG_TYPES (fnode
);
263 while (tmp
&& TREE_CHAIN (tmp
) && tmp
!= error_mark_node
)
265 dump_generic_node (buffer
, TREE_VALUE (tmp
), spc
, flags
);
266 tmp
= TREE_CHAIN (tmp
);
267 if (TREE_CHAIN (tmp
) && TREE_CODE (TREE_CHAIN (tmp
)) == TREE_LIST
)
269 pp_character (buffer
, ',');
274 pp_character (buffer
, ')');
278 unsigned int quals
= TYPE_QUALS (node
);
280 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
);
282 pp_string (buffer
, str
);
284 if (quals
& TYPE_QUAL_CONST
)
285 pp_string (buffer
, " const");
286 else if (quals
& TYPE_QUAL_VOLATILE
)
287 pp_string (buffer
, "volatile");
288 else if (quals
& TYPE_QUAL_RESTRICT
)
289 pp_string (buffer
, " restrict");
298 pp_string (buffer
, IDENTIFIER_POINTER
299 (DECL_NAME (TYPE_NAME (TYPE_METHOD_BASETYPE (node
)))));
300 pp_string (buffer
, "::");
311 /* Print the array type. */
312 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
);
314 /* Print the dimensions. */
316 while (tmp
&& TREE_CODE (tmp
) == ARRAY_TYPE
)
318 pp_character (buffer
, '[');
321 tree size
= TYPE_SIZE (tmp
);
322 if (TREE_CODE (size
) == INTEGER_CST
)
323 pp_wide_integer (buffer
,
324 TREE_INT_CST_LOW (TYPE_SIZE (tmp
)) /
325 TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tmp
))));
326 else if (TREE_CODE (size
) == MULT_EXPR
)
327 dump_generic_node (buffer
, TREE_OPERAND (size
, 0), spc
, flags
);
330 pp_character (buffer
, ']');
331 tmp
= TREE_TYPE (tmp
);
342 /* Print the name of the structure. */
343 if (TREE_CODE (node
) == RECORD_TYPE
)
344 pp_string (buffer
, "struct ");
345 else if (TREE_CODE (node
) == UNION_TYPE
)
346 pp_string (buffer
, "union ");
348 if (TYPE_NAME (node
))
349 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
);
351 print_struct_decl (buffer
, node
, spc
);
354 case QUAL_UNION_TYPE
:
364 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
366 /* In the case of a pointer, one may want to divide by the
367 size of the pointed-to type. Unfortunately, this not
368 straightforward. The C front-end maps expressions
373 in such a way that the two INTEGER_CST nodes for "5" have
374 different values but identical types. In the latter
375 case, the 5 is multipled by sizeof (int) in c-common.c
376 (pointer_int_sum) to convert it to a byte address, and
377 yet the type of the node is left unchanged. Argh. What
378 is consistent though is that the number value corresponds
379 to bytes (UNITS) offset.
381 NB: Neither of the following divisors can be trivially
382 used to recover the original literal:
384 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
385 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
386 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
387 pp_string (buffer
, "B"); /* pseudo-unit */
389 else if (! host_integerp (node
, 0))
393 if (tree_int_cst_sgn (val
) < 0)
395 pp_character (buffer
, '-');
396 val
= build_int_2 (-TREE_INT_CST_LOW (val
),
397 ~TREE_INT_CST_HIGH (val
)
398 + !TREE_INT_CST_LOW (val
));
400 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
403 static char format
[10]; /* "%x%09999x\0" */
405 sprintf (format
, "%%x%%0%dx", HOST_BITS_PER_INT
/ 4);
406 sprintf (pp_buffer (buffer
)->digit_buffer
, format
,
407 TREE_INT_CST_HIGH (val
),
408 TREE_INT_CST_LOW (val
));
409 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
413 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
417 /* Code copied from print_node. */
420 if (TREE_OVERFLOW (node
))
421 pp_string (buffer
, " overflow");
423 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
424 d
= TREE_REAL_CST (node
);
425 if (REAL_VALUE_ISINF (d
))
426 pp_string (buffer
, " Inf");
427 else if (REAL_VALUE_ISNAN (d
))
428 pp_string (buffer
, " Nan");
432 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
433 pp_string (buffer
, string
);
438 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
439 pp_string (buffer
, "0x");
440 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
441 output_formatted_integer (buffer
, "%02x", *p
++);
448 pp_string (buffer
, "__complex__ (");
449 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
);
450 pp_string (buffer
, ", ");
451 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
);
452 pp_string (buffer
, ")");
456 pp_string (buffer
, "\"");
457 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
458 pp_string (buffer
, "\"");
464 pp_string (buffer
, "{ ");
465 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
467 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
);
468 if (TREE_CHAIN (elt
))
469 pp_string (buffer
, ", ");
471 pp_string (buffer
, " }");
479 pp_tree_identifier (buffer
, DECL_NAME (node
));
483 if (DECL_NAME (node
))
484 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
486 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
490 if (DECL_NAME (node
))
491 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
493 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
497 if (strcmp (DECL_SOURCE_FILE (node
), "<built-in>") == 0)
499 /* Don't print the declaration of built-in types. */
502 if (DECL_NAME (node
))
504 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
508 if (TYPE_METHODS (TREE_TYPE (node
)))
510 /* The type is a c++ class: all structures have at least
512 pp_string (buffer
, "class ");
513 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
);
517 pp_string (buffer
, "struct ");
518 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
);
519 pp_character (buffer
, ';');
527 if (DECL_NAME (node
))
528 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
530 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
534 pp_string (buffer
, "<retval>");
538 if (DECL_NAME (node
))
539 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
541 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
545 if (DECL_NAME (node
))
546 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (node
)));
548 pp_printf (buffer
, "<U%x>", MASK_POINTER (node
));
552 op0
= TREE_OPERAND (node
, 0);
554 if (TREE_CODE (op0
) == INDIRECT_REF
)
556 op0
= TREE_OPERAND (op0
, 0);
559 if (op_prio (op0
) < op_prio (node
))
560 pp_character (buffer
, '(');
561 dump_generic_node (buffer
, op0
, spc
, flags
);
562 if (op_prio (op0
) < op_prio (node
))
563 pp_character (buffer
, ')');
564 pp_string (buffer
, str
);
565 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
569 pp_string (buffer
, "BIT_FIELD_REF <");
570 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
571 pp_string (buffer
, ", ");
572 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
573 pp_string (buffer
, ", ");
574 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
);
575 pp_string (buffer
, ">");
583 op0
= TREE_OPERAND (node
, 0);
584 if (op_prio (op0
) < op_prio (node
))
585 pp_character (buffer
, '(');
586 dump_generic_node (buffer
, op0
, spc
, flags
);
587 if (op_prio (op0
) < op_prio (node
))
588 pp_character (buffer
, ')');
589 pp_character (buffer
, '[');
590 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
591 pp_character (buffer
, ']');
594 case ARRAY_RANGE_REF
:
601 bool is_struct_init
= FALSE
;
602 pp_character (buffer
, '{');
603 lnode
= CONSTRUCTOR_ELTS (node
);
604 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
605 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
606 is_struct_init
= TRUE
;
607 while (lnode
&& lnode
!= error_mark_node
)
610 if (TREE_PURPOSE (lnode
) && is_struct_init
)
612 pp_character (buffer
, '.');
613 dump_generic_node (buffer
, TREE_PURPOSE (lnode
), spc
, flags
);
614 pp_string (buffer
, "=");
616 val
= TREE_VALUE (lnode
);
617 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
618 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
619 val
= TREE_OPERAND (val
, 0);
620 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
623 pp_string (buffer
, IDENTIFIER_POINTER (DECL_NAME (val
)));
625 pp_printf (buffer
, "<U%x>", MASK_POINTER (val
));
629 dump_generic_node (buffer
, TREE_VALUE (lnode
), spc
, flags
);
631 lnode
= TREE_CHAIN (lnode
);
632 if (lnode
&& TREE_CODE (lnode
) == TREE_LIST
)
634 pp_character (buffer
, ',');
638 pp_character (buffer
, '}');
645 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
646 if (flags
& TDF_SLIM
)
648 pp_character (buffer
, ';');
650 for (si
= tsi_start (&TREE_OPERAND (node
, 1));
654 newline_and_indent (buffer
, spc
);
655 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
);
656 pp_character (buffer
, ';');
661 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
663 for (si
= tsi_start (&TREE_OPERAND (node
, 1));
667 pp_character (buffer
, ',');
669 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
);
676 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
678 pp_character (buffer
, '=');
680 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
684 dump_generic_node (buffer
, TYPE_NAME (TREE_TYPE (node
)), spc
, flags
);
685 pp_character (buffer
, '(');
686 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
);
687 pp_character (buffer
, ')');
691 if (TREE_TYPE (node
) == void_type_node
)
693 pp_string (buffer
, "if (");
694 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
);
695 pp_character (buffer
, ')');
696 if (!(flags
& TDF_SLIM
))
698 /* Output COND_EXPR_THEN. */
699 if (COND_EXPR_THEN (node
))
701 newline_and_indent (buffer
, spc
+2);
702 pp_character (buffer
, '{');
703 newline_and_indent (buffer
, spc
+4);
704 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
706 newline_and_indent (buffer
, spc
+2);
707 pp_character (buffer
, '}');
710 /* Output COND_EXPR_ELSE. */
711 if (COND_EXPR_ELSE (node
))
713 newline_and_indent (buffer
, spc
);
714 pp_string (buffer
, "else");
715 newline_and_indent (buffer
, spc
+2);
716 pp_character (buffer
, '{');
717 newline_and_indent (buffer
, spc
+4);
718 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
720 newline_and_indent (buffer
, spc
+2);
721 pp_character (buffer
, '}');
727 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
729 pp_character (buffer
, '?');
731 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
733 pp_character (buffer
, ':');
735 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
);
740 pp_character (buffer
, '{');
741 if (!(flags
& TDF_SLIM
))
743 if (BIND_EXPR_VARS (node
))
747 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
748 print_declaration (buffer
, op0
, spc
+2, flags
);
751 newline_and_indent (buffer
, spc
+2);
752 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
);
753 newline_and_indent (buffer
, spc
);
754 pp_character (buffer
, '}');
759 print_call_name (buffer
, node
);
761 /* Print parameters. */
763 pp_character (buffer
, '(');
764 op1
= TREE_OPERAND (node
, 1);
766 dump_generic_node (buffer
, op1
, spc
, flags
);
767 pp_character (buffer
, ')');
770 case WITH_CLEANUP_EXPR
:
774 case CLEANUP_POINT_EXPR
:
775 pp_string (buffer
, "<<cleanup_point ");
776 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
777 pp_string (buffer
, ">>");
780 case PLACEHOLDER_EXPR
:
784 case WITH_RECORD_EXPR
:
788 /* Binary arithmetic and logic expressions. */
809 case TRUTH_ANDIF_EXPR
:
810 case TRUTH_ORIF_EXPR
:
826 const char *op
= op_symbol (node
);
827 op0
= TREE_OPERAND (node
, 0);
828 op1
= TREE_OPERAND (node
, 1);
830 /* When the operands are expressions with less priority,
831 keep semantics of the tree representation. */
832 if (op_prio (op0
) < op_prio (node
))
834 pp_character (buffer
, '(');
835 dump_generic_node (buffer
, op0
, spc
, flags
);
836 pp_character (buffer
, ')');
839 dump_generic_node (buffer
, op0
, spc
, flags
);
842 pp_string (buffer
, op
);
845 /* When the operands are expressions with less priority,
846 keep semantics of the tree representation. */
847 if (op_prio (op1
) < op_prio (node
))
849 pp_character (buffer
, '(');
850 dump_generic_node (buffer
, op1
, spc
, flags
);
851 pp_character (buffer
, ')');
854 dump_generic_node (buffer
, op1
, spc
, flags
);
858 /* Unary arithmetic and logic expressions. */
864 case PREDECREMENT_EXPR
:
865 case PREINCREMENT_EXPR
:
867 if (TREE_CODE (node
) == ADDR_EXPR
868 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
869 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
870 ; /* Do not output '&' for strings and function pointers. */
872 pp_string (buffer
, op_symbol (node
));
874 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
876 pp_character (buffer
, '(');
877 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
878 pp_character (buffer
, ')');
881 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
884 case POSTDECREMENT_EXPR
:
885 case POSTINCREMENT_EXPR
:
886 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
888 pp_character (buffer
, '(');
889 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
890 pp_character (buffer
, ')');
893 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
894 pp_string (buffer
, op_symbol (node
));
898 pp_string (buffer
, "MIN_EXPR <");
899 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
900 pp_string (buffer
, ", ");
901 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
902 pp_character (buffer
, '>');
906 pp_string (buffer
, "MAX_EXPR <");
907 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
908 pp_string (buffer
, ", ");
909 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
910 pp_character (buffer
, '>');
914 pp_string (buffer
, "ABS_EXPR <");
915 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
916 pp_character (buffer
, '>');
950 type
= TREE_TYPE (node
);
951 op0
= TREE_OPERAND (node
, 0);
952 if (type
!= TREE_TYPE (op0
))
954 pp_character (buffer
, '(');
955 dump_generic_node (buffer
, type
, spc
, flags
);
956 pp_string (buffer
, ")");
958 if (op_prio (op0
) < op_prio (node
))
959 pp_character (buffer
, '(');
960 dump_generic_node (buffer
, op0
, spc
, flags
);
961 if (op_prio (op0
) < op_prio (node
))
962 pp_character (buffer
, ')');
965 case NON_LVALUE_EXPR
:
966 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
970 pp_string (buffer
, "SAVE_EXPR <");
971 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
972 pp_character (buffer
, '>');
976 pp_string (buffer
, "UNSAVE_EXPR <");
977 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
978 pp_character (buffer
, '>');
985 case ENTRY_VALUE_EXPR
:
990 pp_string (buffer
, "COMPLEX_EXPR <");
991 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
992 pp_string (buffer
, ", ");
993 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
994 pp_string (buffer
, ">");
998 pp_string (buffer
, "CONJ_EXPR <");
999 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1000 pp_string (buffer
, ">");
1004 pp_string (buffer
, "REALPART_EXPR <");
1005 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1006 pp_string (buffer
, ">");
1010 pp_string (buffer
, "IMAGPART_EXPR <");
1011 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1012 pp_string (buffer
, ">");
1016 pp_string (buffer
, "VA_ARG_EXPR <");
1017 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1018 pp_string (buffer
, ">");
1021 case TRY_FINALLY_EXPR
:
1022 case TRY_CATCH_EXPR
:
1023 pp_string (buffer
, "try");
1024 newline_and_indent (buffer
, spc
+2);
1025 pp_string (buffer
, "{");
1026 newline_and_indent (buffer
, spc
+4);
1027 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
);
1028 newline_and_indent (buffer
, spc
+2);
1029 pp_string (buffer
, "}");
1030 newline_and_indent (buffer
, spc
);
1032 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1033 newline_and_indent (buffer
, spc
+2);
1034 pp_string (buffer
, "{");
1035 newline_and_indent (buffer
, spc
+4);
1036 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
);
1037 newline_and_indent (buffer
, spc
+2);
1038 pp_string (buffer
, "}");
1042 pp_string (buffer
, "catch (");
1043 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
);
1044 pp_string (buffer
, ")");
1045 newline_and_indent (buffer
, spc
+2);
1046 pp_string (buffer
, "{");
1047 newline_and_indent (buffer
, spc
+4);
1048 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
);
1049 newline_and_indent (buffer
, spc
+2);
1050 pp_string (buffer
, "}");
1053 case EH_FILTER_EXPR
:
1054 pp_string (buffer
, "<<<eh_filter (");
1055 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
);
1056 pp_string (buffer
, ")>>>");
1057 newline_and_indent (buffer
, spc
+2);
1058 pp_string (buffer
, "{");
1059 newline_and_indent (buffer
, spc
+4);
1060 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
);
1061 newline_and_indent (buffer
, spc
+2);
1062 pp_string (buffer
, "}");
1065 case GOTO_SUBROUTINE_EXPR
:
1070 op0
= TREE_OPERAND (node
, 0);
1071 /* If this is for break or continue, don't bother printing it. */
1072 if (DECL_NAME (op0
))
1074 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1075 if (strcmp (name
, "break") == 0
1076 || strcmp (name
, "continue") == 0)
1079 dump_generic_node (buffer
, op0
, spc
, flags
);
1080 pp_character (buffer
, ':');
1081 pp_character (buffer
, ';');
1084 case LABELED_BLOCK_EXPR
:
1085 op0
= LABELED_BLOCK_LABEL (node
);
1086 /* If this is for break or continue, don't bother printing it. */
1087 if (DECL_NAME (op0
))
1089 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1090 if (strcmp (name
, "break") == 0
1091 || strcmp (name
, "continue") == 0)
1093 dump_generic_node (buffer
, LABELED_BLOCK_BODY (node
), spc
, flags
);
1097 dump_generic_node (buffer
, LABELED_BLOCK_LABEL (node
), spc
, flags
);
1098 pp_string (buffer
, ": {");
1099 if (!(flags
& TDF_SLIM
))
1100 newline_and_indent (buffer
, spc
+2);
1101 dump_generic_node (buffer
, LABELED_BLOCK_BODY (node
), spc
+2, flags
);
1103 newline_and_indent (buffer
, spc
);
1104 pp_character (buffer
, '}');
1107 case EXIT_BLOCK_EXPR
:
1108 op0
= LABELED_BLOCK_LABEL (EXIT_BLOCK_LABELED_BLOCK (node
));
1109 /* If this is for a break or continue, print it accordingly. */
1110 if (DECL_NAME (op0
))
1112 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1113 if (strcmp (name
, "break") == 0
1114 || strcmp (name
, "continue") == 0)
1116 pp_string (buffer
, name
);
1120 pp_string (buffer
, "<<<exit block ");
1121 dump_generic_node (buffer
, op0
, spc
, flags
);
1122 pp_string (buffer
, ">>>");
1126 pp_string (buffer
, "<<<exception object>>>");
1130 pp_string (buffer
, "<<<filter object>>>");
1134 pp_string (buffer
, "while (1)");
1135 if (!(flags
& TDF_SLIM
))
1137 newline_and_indent (buffer
, spc
+2);
1138 pp_character (buffer
, '{');
1139 newline_and_indent (buffer
, spc
+4);
1140 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
);
1141 newline_and_indent (buffer
, spc
+2);
1142 pp_character (buffer
, '}');
1147 pp_string (buffer
, "break;");
1151 pp_string (buffer
, "continue;");
1155 pp_string (buffer
, "return");
1156 op0
= TREE_OPERAND (node
, 0);
1160 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1161 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), spc
, flags
);
1163 dump_generic_node (buffer
, op0
, spc
, flags
);
1165 pp_character (buffer
, ';');
1169 pp_string (buffer
, "if (");
1170 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1171 pp_string (buffer
, ") break;");
1175 pp_string (buffer
, "switch (");
1176 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
);
1177 pp_character (buffer
, ')');
1178 if (!(flags
& TDF_SLIM
))
1180 newline_and_indent (buffer
, spc
+2);
1181 pp_character (buffer
, '{');
1182 newline_and_indent (buffer
, spc
+4);
1183 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
);
1184 newline_and_indent (buffer
, spc
+2);
1185 pp_character (buffer
, '}');
1190 op0
= GOTO_DESTINATION (node
);
1191 if (TREE_CODE (op0
) != SSA_NAME
1195 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1196 if (strcmp (name
, "break") == 0
1197 || strcmp (name
, "continue") == 0)
1199 pp_string (buffer
, name
);
1203 pp_string (buffer
, "goto ");
1204 dump_generic_node (buffer
, op0
, spc
, flags
);
1205 pp_character (buffer
, ';');
1209 pp_string (buffer
, "resx;");
1210 /* ??? Any sensible way to present the eh region? */
1214 pp_string (buffer
, "__asm__");
1215 if (ASM_VOLATILE_P (node
))
1216 pp_string (buffer
, " __volatile__");
1217 pp_character (buffer
, '(');
1218 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
);
1219 pp_character (buffer
, ':');
1220 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
);
1221 pp_character (buffer
, ':');
1222 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
);
1223 if (ASM_CLOBBERS (node
))
1225 pp_character (buffer
, ':');
1226 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
);
1228 pp_string (buffer
, ");");
1229 if (!(flags
& TDF_SLIM
))
1230 pp_newline (buffer
);
1233 case CASE_LABEL_EXPR
:
1234 if (CASE_LOW (node
) && CASE_HIGH (node
))
1236 pp_string (buffer
, "case ");
1237 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
);
1238 pp_string (buffer
, " ... ");
1239 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
);
1241 else if (CASE_LOW (node
))
1243 pp_string (buffer
, "case ");
1244 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
);
1247 pp_string (buffer
, "default ");
1248 pp_character (buffer
, ':');
1252 pp_string (buffer
, "VTABLE_REF <(");
1253 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
);
1254 pp_string (buffer
, "),");
1255 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
);
1256 pp_character (buffer
, ',');
1257 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
);
1258 pp_character (buffer
, '>');
1265 pp_string (buffer
, " EPHI (");
1266 dump_generic_node (buffer
, EREF_NAME (node
), spc
, flags
);
1267 pp_string (buffer
, ") ");
1268 pp_character (buffer
, '[');
1269 pp_string (buffer
, " class:");
1270 pp_decimal_int (buffer
, EREF_CLASS (node
));
1271 if (EPHI_DOWNSAFE (node
))
1272 pp_string (buffer
, " downsafe");
1273 if (EPHI_CANT_BE_AVAIL (node
))
1274 pp_string (buffer
, " cant_be_avail");
1275 if (EPHI_STOPS (node
))
1276 pp_string (buffer
, " stops");
1277 pp_string (buffer
, " bb:");
1278 pp_decimal_int (buffer
, bb_for_stmt (node
)->index
);
1279 pp_character (buffer
, ']');
1280 if (! (flags
& TDF_SLIM
))
1282 pp_string (buffer
, " <");
1283 for (i
= 0; i
< EPHI_NUM_ARGS (node
); i
++)
1285 if (EPHI_ARG_DEF (node
, i
))
1287 newline_and_indent (buffer
, spc
+ 2);
1288 pp_string (buffer
, " edge ");
1289 pp_decimal_int (buffer
, EPHI_ARG_EDGE (node
, i
)->src
->index
);
1290 pp_string (buffer
, "->");
1291 pp_decimal_int (buffer
, EPHI_ARG_EDGE (node
, i
)->dest
->index
);
1292 pp_string (buffer
, " [ ");
1293 if (EPHI_ARG_HAS_REAL_USE (node
, i
))
1294 pp_string (buffer
, " real use");
1295 if (EPHI_ARG_INJURED (node
, i
))
1296 pp_string (buffer
, " injured");
1297 if (EPHI_ARG_STOPS (node
, i
))
1298 pp_string (buffer
, " stops");
1299 pp_string (buffer
, " ] ");
1300 pp_string (buffer
, " defined by:");
1301 dump_generic_node (buffer
, EPHI_ARG_DEF (node
, i
),
1302 spc
+ 4, flags
| TDF_SLIM
);
1306 pp_string (buffer
, " >");
1312 if (TREE_CODE (node
) == EEXIT_NODE
)
1313 pp_string (buffer
, "EEXIT (");
1314 else if (TREE_CODE (node
) == ELEFT_NODE
)
1315 pp_string (buffer
, "ELEFT (");
1316 else if (TREE_CODE (node
) == EKILL_NODE
)
1317 pp_string (buffer
, "EKILL (");
1318 dump_generic_node (buffer
, EREF_NAME (node
), spc
, flags
);
1319 pp_string (buffer
, ") ");
1320 pp_character (buffer
, '[');
1321 pp_string (buffer
, "class:");
1322 pp_decimal_int (buffer
, EREF_CLASS (node
));
1323 pp_string (buffer
, " bb:");
1324 pp_decimal_int (buffer
, bb_for_stmt (node
)->index
);
1325 pp_character (buffer
, ']');
1328 pp_string (buffer
, " EUSE (");
1329 dump_generic_node (buffer
, EREF_NAME (node
), spc
, flags
);
1331 pp_string (buffer
, ") ");
1332 pp_character (buffer
, '[');
1333 pp_string (buffer
, "class:");
1334 pp_decimal_int (buffer
, EREF_CLASS (node
));
1335 pp_string (buffer
, " phiop:");
1336 pp_decimal_int (buffer
, EUSE_PHIOP (node
));
1337 pp_string (buffer
, " bb:");
1338 pp_decimal_int (buffer
, bb_for_stmt (node
)->index
);
1339 pp_string (buffer
, " ]");
1345 dump_generic_node (buffer
, PHI_RESULT (node
), spc
, flags
);
1346 pp_string (buffer
, " = PHI <");
1347 for (i
= 0; i
< PHI_NUM_ARGS (node
); i
++)
1349 dump_generic_node (buffer
, PHI_ARG_DEF (node
, i
), spc
, flags
);
1350 pp_string (buffer
, "(");
1351 pp_decimal_int (buffer
, PHI_ARG_EDGE (node
, i
)->src
->index
);
1352 pp_string (buffer
, ")");
1353 if (i
< PHI_NUM_ARGS (node
) - 1)
1354 pp_string (buffer
, ", ");
1356 pp_string (buffer
, ">;");
1361 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
);
1362 pp_string (buffer
, "_");
1363 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1367 dump_generic_node (buffer
, VDEF_RESULT (node
), spc
, flags
);
1368 pp_string (buffer
, " = VDEF <");
1369 dump_generic_node (buffer
, VDEF_OP (node
), spc
, flags
);
1370 pp_string (buffer
, ">;");
1371 pp_newline (buffer
);
1378 pp_write_text_to_stream (buffer
);
1383 /* Print the declaration of a variable. */
1386 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
1388 /* Don't print type declarations. */
1389 if (TREE_CODE (t
) == TYPE_DECL
)
1394 if (DECL_REGISTER (t
))
1395 pp_string (buffer
, "register ");
1397 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
1398 pp_string (buffer
, "extern ");
1399 else if (TREE_STATIC (t
))
1400 pp_string (buffer
, "static ");
1402 /* Print the type and name. */
1403 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
1407 /* Print array's type. */
1408 tmp
= TREE_TYPE (t
);
1409 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
1410 tmp
= TREE_TYPE (tmp
);
1411 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, 0);
1413 /* Print variable's name. */
1415 dump_generic_node (buffer
, t
, spc
, 0);
1417 /* Print the dimensions. */
1418 tmp
= TREE_TYPE (t
);
1419 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
1421 pp_character (buffer
, '[');
1422 if (TYPE_DOMAIN (tmp
))
1424 if (TREE_CODE (TYPE_SIZE (tmp
)) == INTEGER_CST
)
1425 pp_wide_integer (buffer
,
1426 TREE_INT_CST_LOW (TYPE_SIZE (tmp
)) /
1427 TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tmp
))));
1429 dump_generic_node (buffer
, TYPE_SIZE_UNIT (tmp
), spc
, 0);
1431 pp_character (buffer
, ']');
1432 tmp
= TREE_TYPE (tmp
);
1437 /* Print type declaration. */
1438 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, 0);
1440 /* Print variable's name. */
1442 dump_generic_node (buffer
, t
, spc
, 0);
1445 /* The initial value of a function serves to determine wether the function
1446 is declared or defined. So the following does not apply to function
1448 if (TREE_CODE (t
) != FUNCTION_DECL
)
1450 /* Print the initial value. */
1451 if (DECL_INITIAL (t
))
1454 pp_character (buffer
, '=');
1456 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, 0);
1460 pp_character (buffer
, ';');
1461 if (!(flags
& TDF_SLIM
))
1462 pp_newline (buffer
);
1466 /* Prints a structure: name, fields, and methods.
1467 FIXME: Still incomplete. */
1470 print_struct_decl (pretty_printer
*buffer
, tree node
, int spc
)
1472 /* Print the name of the structure. */
1473 if (TYPE_NAME (node
))
1476 if (TREE_CODE (node
) == RECORD_TYPE
)
1477 pp_string (buffer
, "struct ");
1478 else if (TREE_CODE (node
) == UNION_TYPE
)
1479 pp_string (buffer
, "union ");
1482 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0);
1485 /* Print the contents of the structure. */
1486 pp_newline (buffer
);
1488 pp_character (buffer
, '{');
1489 pp_newline (buffer
);
1491 /* Print the fields of the structure. */
1494 tmp
= TYPE_FIELDS (node
);
1497 /* Avoid to print recursively the structure. */
1498 /* FIXME : Not implemented correctly...,
1499 what about the case when we have a cycle in the contain graph? ...
1500 Maybe this could be solved by looking at the scope in which the structure
1502 if (TREE_TYPE (tmp
) != node
1503 || (TREE_CODE (TREE_TYPE (tmp
)) == POINTER_TYPE
&&
1504 TREE_TYPE (TREE_TYPE (tmp
)) != node
))
1505 print_declaration (buffer
, tmp
, spc
+2, 0);
1510 tmp
= TREE_CHAIN (tmp
);
1514 pp_character (buffer
, '}');
1517 /* Return the priority of the operator OP.
1519 From lowest to highest precedence with either left-to-right (L-R)
1520 or right-to-left (R-L) associativity]:
1523 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
1535 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
1536 15 [L-R] fn() [] -> .
1538 unary +, - and * have higher precedence than the corresponding binary
1547 switch (TREE_CODE (op
))
1562 case TRUTH_ORIF_EXPR
:
1565 case TRUTH_AND_EXPR
:
1566 case TRUTH_ANDIF_EXPR
:
1573 case TRUTH_XOR_EXPR
:
1600 case TRUNC_DIV_EXPR
:
1602 case FLOOR_DIV_EXPR
:
1603 case ROUND_DIV_EXPR
:
1605 case EXACT_DIV_EXPR
:
1606 case TRUNC_MOD_EXPR
:
1608 case FLOOR_MOD_EXPR
:
1609 case ROUND_MOD_EXPR
:
1612 case TRUTH_NOT_EXPR
:
1614 case POSTINCREMENT_EXPR
:
1615 case POSTDECREMENT_EXPR
:
1616 case PREINCREMENT_EXPR
:
1617 case PREDECREMENT_EXPR
:
1624 case FIX_TRUNC_EXPR
:
1626 case FIX_FLOOR_EXPR
:
1627 case FIX_ROUND_EXPR
:
1636 /* Special expressions. */
1645 case NON_LVALUE_EXPR
:
1646 return op_prio (TREE_OPERAND (op
, 0));
1649 /* Return an arbitrarily high precedence to avoid surrounding single
1650 VAR_DECLs in ()s. */
1656 /* Return the symbol associated with operator OP. */
1664 switch (TREE_CODE (op
))
1670 case TRUTH_ORIF_EXPR
:
1673 case TRUTH_AND_EXPR
:
1674 case TRUTH_ANDIF_EXPR
:
1680 case TRUTH_XOR_EXPR
:
1727 case TRUTH_NOT_EXPR
:
1734 case TRUNC_DIV_EXPR
:
1736 case FLOOR_DIV_EXPR
:
1737 case ROUND_DIV_EXPR
:
1739 case EXACT_DIV_EXPR
:
1742 case TRUNC_MOD_EXPR
:
1744 case FLOOR_MOD_EXPR
:
1745 case ROUND_MOD_EXPR
:
1748 case PREDECREMENT_EXPR
:
1751 case PREINCREMENT_EXPR
:
1754 case POSTDECREMENT_EXPR
:
1757 case POSTINCREMENT_EXPR
:
1760 case REFERENCE_EXPR
:
1764 return "<<< ??? >>>";
1768 /* Prints the name of a CALL_EXPR. */
1771 print_call_name (pretty_printer
*buffer
, tree node
)
1775 if (TREE_CODE (node
) != CALL_EXPR
)
1778 op0
= TREE_OPERAND (node
, 0);
1780 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
1781 op0
= TREE_OPERAND (op0
, 0);
1783 switch (TREE_CODE (op0
))
1787 PRINT_FUNCTION_NAME (op0
);
1793 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0);
1797 pp_string (buffer
, "(");
1798 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0);
1799 pp_string (buffer
, ") ? ");
1800 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0);
1801 pp_string (buffer
, " : ");
1802 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0);
1806 /* The function is a pointer contained in a structure. */
1807 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
1808 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
1809 PRINT_FUNCTION_NAME (TREE_OPERAND (op0
, 1));
1811 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0);
1813 We can have several levels of structures and a function
1814 pointer inside. This is not implemented yet... */
1819 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
1820 PRINT_FUNCTION_NAME (TREE_OPERAND (op0
, 0));
1822 PRINT_FUNCTION_NAME (TREE_OPERAND (op0
, 1));
1826 dump_generic_node (buffer
, op0
, 0, 0);
1834 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
1837 pretty_print_string (pretty_printer
*buffer
, const char *str
)
1847 pp_string (buffer
, "\\b");
1851 pp_string (buffer
, "\\f");
1855 pp_string (buffer
, "\\n");
1859 pp_string (buffer
, "\\r");
1863 pp_string (buffer
, "\\t");
1867 pp_string (buffer
, "\\v");
1871 pp_string (buffer
, "\\\\");
1875 pp_string (buffer
, "\\\"");
1879 pp_string (buffer
, "\\'");
1883 pp_string (buffer
, "\\0");
1887 pp_string (buffer
, "\\1");
1891 pp_string (buffer
, "\\2");
1895 pp_string (buffer
, "\\3");
1899 pp_string (buffer
, "\\4");
1903 pp_string (buffer
, "\\5");
1907 pp_string (buffer
, "\\6");
1911 pp_string (buffer
, "\\7");
1915 pp_character (buffer
, str
[0]);
1923 maybe_init_pretty_print (FILE *file
)
1929 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
1930 pp_needs_newline (&buffer
) = true;
1934 buffer
.buffer
->stream
= file
;
1938 newline_and_indent (pretty_printer
*buffer
, int spc
)
1940 pp_newline (buffer
);
1946 dump_block_info (pretty_printer
*buffer
, basic_block bb
, int spc
)
1951 tree stmt
= first_stmt (bb
);
1954 newline_and_indent (buffer
, spc
);
1955 pp_scalar (buffer
, "# BLOCK %d", bb
->index
);
1958 && is_exec_stmt (stmt
)
1959 && (lineno
= get_lineno (stmt
)) > 0)
1961 pp_string (buffer
, " (");
1962 pp_string (buffer
, get_filename (stmt
));
1963 pp_scalar (buffer
, ":%d", lineno
);
1964 pp_string (buffer
, ")");
1967 pp_string (buffer
, ". PRED:");
1968 for (e
= bb
->pred
; e
; e
= e
->pred_next
)
1971 pp_scalar (buffer
, " %d", e
->src
->index
);
1972 if (e
->flags
& EDGE_ABNORMAL
)
1973 pp_string (buffer
, "(ab)");
1976 pp_string (buffer
, ". SUCC:");
1977 for (e
= bb
->succ
; e
; e
= e
->succ_next
)
1980 pp_scalar (buffer
, " %d", e
->dest
->index
);
1981 if (e
->flags
& EDGE_ABNORMAL
)
1982 pp_string (buffer
, "(ab)");
1985 pp_character (buffer
, '.');
1987 newline_and_indent (buffer
, spc
);
1993 dump_vops (pretty_printer
*buffer
, tree stmt
, int spc
)
1997 varray_type vdefs
= vdef_ops (stmt
);
1998 varray_type vuses
= vuse_ops (stmt
);
2000 bb
= bb_for_stmt (stmt
);
2001 if (bb
&& bb
!= last_bb
&& bb
->tree_annotations
)
2005 for (phi
= phi_nodes (bb
); phi
; phi
= TREE_CHAIN (phi
))
2007 pp_string (buffer
, "# ");
2008 dump_generic_node (buffer
, phi
, spc
, 0);
2009 newline_and_indent (buffer
, spc
);
2014 newline_and_indent (buffer
, spc
);
2017 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (vdefs
); i
++)
2019 tree vdef
= VARRAY_TREE (vdefs
, i
);
2020 pp_string (buffer
, "# ");
2021 dump_generic_node (buffer
, vdef
, spc
, 0);
2026 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (vuses
); i
++)
2028 tree vuse
= VARRAY_TREE (vuses
, i
);
2029 pp_string (buffer
, "# VUSE <");
2030 dump_generic_node (buffer
, vuse
, spc
, 0);
2031 pp_string (buffer
, ">;");
2032 newline_and_indent (buffer
, spc
);