Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-pretty-print.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
38 #include "predict.h" | 38 #include "predict.h" |
39 | 39 |
40 /* Local functions, macros and variables. */ | 40 /* Local functions, macros and variables. */ |
41 static const char *op_symbol (const_tree); | 41 static const char *op_symbol (const_tree); |
42 static void pretty_print_string (pretty_printer *, const char*); | 42 static void pretty_print_string (pretty_printer *, const char*); |
43 static void print_call_name (pretty_printer *, const_tree); | |
44 static void newline_and_indent (pretty_printer *, int); | 43 static void newline_and_indent (pretty_printer *, int); |
45 static void maybe_init_pretty_print (FILE *); | 44 static void maybe_init_pretty_print (FILE *); |
46 static void print_struct_decl (pretty_printer *, const_tree, int, int); | 45 static void print_struct_decl (pretty_printer *, const_tree, int, int); |
47 static void do_niy (pretty_printer *, const_tree); | 46 static void do_niy (pretty_printer *, const_tree); |
48 | 47 |
49 #define INDENT(SPACE) do { \ | 48 #define INDENT(SPACE) do { \ |
50 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0) | 49 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0) |
51 | 50 |
52 #define NIY do_niy(buffer,node) | 51 #define NIY do_niy(buffer,node) |
53 | |
54 #define PRINT_FUNCTION_NAME(NODE) pp_printf \ | |
55 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \ | |
56 lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \ | |
57 lang_hooks.decl_printable_name (NODE, 1)) | |
58 | 52 |
59 static pretty_printer buffer; | 53 static pretty_printer buffer; |
60 static int initialized = 0; | 54 static int initialized = 0; |
61 | 55 |
62 /* Try to print something for an unknown tree code. */ | 56 /* Try to print something for an unknown tree code. */ |
103 /* Debugging function to print out a chain of trees . */ | 97 /* Debugging function to print out a chain of trees . */ |
104 | 98 |
105 void | 99 void |
106 debug_tree_chain (tree t) | 100 debug_tree_chain (tree t) |
107 { | 101 { |
102 struct pointer_set_t *seen = pointer_set_create (); | |
103 | |
108 while (t) | 104 while (t) |
109 { | 105 { |
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); | 106 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); |
111 fprintf(stderr, " "); | 107 fprintf (stderr, " "); |
112 t = TREE_CHAIN (t); | 108 t = TREE_CHAIN (t); |
113 } | 109 if (pointer_set_insert (seen, t)) |
110 { | |
111 fprintf (stderr, "... [cycled back to "); | |
112 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); | |
113 fprintf (stderr, "]"); | |
114 break; | |
115 } | |
116 } | |
114 fprintf (stderr, "\n"); | 117 fprintf (stderr, "\n"); |
118 | |
119 pointer_set_destroy (seen); | |
115 } | 120 } |
116 | 121 |
117 /* Prints declaration DECL to the FILE with details specified by FLAGS. */ | 122 /* Prints declaration DECL to the FILE with details specified by FLAGS. */ |
118 void | 123 void |
119 print_generic_decl (FILE *file, tree decl, int flags) | 124 print_generic_decl (FILE *file, tree decl, int flags) |
165 in FLAGS. */ | 170 in FLAGS. */ |
166 | 171 |
167 static void | 172 static void |
168 dump_decl_name (pretty_printer *buffer, tree node, int flags) | 173 dump_decl_name (pretty_printer *buffer, tree node, int flags) |
169 { | 174 { |
170 tree t = node; | 175 if (DECL_NAME (node)) |
171 | 176 { |
172 if (DECL_NAME (t)) | 177 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node)) |
173 pp_tree_identifier (buffer, DECL_NAME (t)); | 178 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node)); |
174 if ((flags & TDF_UID) | |
175 || DECL_NAME (t) == NULL_TREE) | |
176 { | |
177 if (TREE_CODE (t) == LABEL_DECL | |
178 && LABEL_DECL_UID (t) != -1) | |
179 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (t)); | |
180 else | 179 else |
181 { | 180 pp_tree_identifier (buffer, DECL_NAME (node)); |
182 char c = TREE_CODE (t) == CONST_DECL ? 'C' : 'D'; | 181 } |
183 pp_printf (buffer, "%c.%u", c, DECL_UID (t)); | 182 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE) |
183 { | |
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 { | |
188 if (flags & TDF_NOUID) | |
189 pp_string (buffer, "D#xxxx"); | |
190 else | |
191 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node)); | |
192 } | |
193 else | |
194 { | |
195 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D'; | |
196 if (flags & TDF_NOUID) | |
197 pp_printf (buffer, "%c.xxxx", c); | |
198 else | |
199 pp_printf (buffer, "%c.%u", c, DECL_UID (node)); | |
184 } | 200 } |
185 } | 201 } |
186 } | 202 } |
187 | 203 |
188 /* Like the above, but used for pretty printing function calls. */ | 204 /* Like the above, but used for pretty printing function calls. */ |
189 | 205 |
190 static void | 206 static void |
191 dump_function_name (pretty_printer *buffer, tree node) | 207 dump_function_name (pretty_printer *buffer, tree node, int flags) |
192 { | 208 { |
193 if (DECL_NAME (node)) | 209 if (TREE_CODE (node) == NOP_EXPR) |
194 PRINT_FUNCTION_NAME (node); | 210 node = TREE_OPERAND (node, 0); |
211 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0) | |
212 pp_string (buffer, lang_hooks.decl_printable_name (node, 1)); | |
195 else | 213 else |
196 dump_decl_name (buffer, node, 0); | 214 dump_decl_name (buffer, node, flags); |
197 } | 215 } |
198 | 216 |
199 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and | 217 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and |
200 FLAGS are as in dump_generic_node. */ | 218 FLAGS are as in dump_generic_node. */ |
201 | 219 |
421 pp_space (buffer); | 439 pp_space (buffer); |
422 } | 440 } |
423 } | 441 } |
424 | 442 |
425 | 443 |
444 /* Dump location LOC to BUFFER. */ | |
445 | |
446 static void | |
447 dump_location (pretty_printer *buffer, location_t loc) | |
448 { | |
449 expanded_location xloc = expand_location (loc); | |
450 | |
451 pp_character (buffer, '['); | |
452 if (xloc.file) | |
453 { | |
454 pp_string (buffer, xloc.file); | |
455 pp_string (buffer, " : "); | |
456 } | |
457 pp_decimal_int (buffer, xloc.line); | |
458 pp_string (buffer, "] "); | |
459 } | |
460 | |
461 | |
462 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in | |
463 dump_generic_node. */ | |
464 | |
465 static void | |
466 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags) | |
467 { | |
468 tree t; | |
469 | |
470 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block)); | |
471 | |
472 if (flags & TDF_ADDRESS) | |
473 pp_printf (buffer, "[%p] ", (void *) block); | |
474 | |
475 if (BLOCK_ABSTRACT (block)) | |
476 pp_string (buffer, "[abstract] "); | |
477 | |
478 if (TREE_ASM_WRITTEN (block)) | |
479 pp_string (buffer, "[written] "); | |
480 | |
481 if (flags & TDF_SLIM) | |
482 return; | |
483 | |
484 if (BLOCK_SOURCE_LOCATION (block)) | |
485 dump_location (buffer, BLOCK_SOURCE_LOCATION (block)); | |
486 | |
487 newline_and_indent (buffer, spc + 2); | |
488 | |
489 if (BLOCK_SUPERCONTEXT (block)) | |
490 { | |
491 pp_string (buffer, "SUPERCONTEXT: "); | |
492 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0, | |
493 flags | TDF_SLIM, false); | |
494 newline_and_indent (buffer, spc + 2); | |
495 } | |
496 | |
497 if (BLOCK_SUBBLOCKS (block)) | |
498 { | |
499 pp_string (buffer, "SUBBLOCKS: "); | |
500 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t)) | |
501 { | |
502 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false); | |
503 pp_string (buffer, " "); | |
504 } | |
505 newline_and_indent (buffer, spc + 2); | |
506 } | |
507 | |
508 if (BLOCK_CHAIN (block)) | |
509 { | |
510 pp_string (buffer, "SIBLINGS: "); | |
511 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t)) | |
512 { | |
513 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false); | |
514 pp_string (buffer, " "); | |
515 } | |
516 newline_and_indent (buffer, spc + 2); | |
517 } | |
518 | |
519 if (BLOCK_VARS (block)) | |
520 { | |
521 pp_string (buffer, "VARS: "); | |
522 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t)) | |
523 { | |
524 dump_generic_node (buffer, t, 0, flags, false); | |
525 pp_string (buffer, " "); | |
526 } | |
527 newline_and_indent (buffer, spc + 2); | |
528 } | |
529 | |
530 if (VEC_length (tree, BLOCK_NONLOCALIZED_VARS (block)) > 0) | |
531 { | |
532 unsigned i; | |
533 VEC(tree,gc) *nlv = BLOCK_NONLOCALIZED_VARS (block); | |
534 | |
535 pp_string (buffer, "NONLOCALIZED_VARS: "); | |
536 for (i = 0; VEC_iterate (tree, nlv, i, t); i++) | |
537 { | |
538 dump_generic_node (buffer, t, 0, flags, false); | |
539 pp_string (buffer, " "); | |
540 } | |
541 newline_and_indent (buffer, spc + 2); | |
542 } | |
543 | |
544 if (BLOCK_ABSTRACT_ORIGIN (block)) | |
545 { | |
546 pp_string (buffer, "ABSTRACT_ORIGIN: "); | |
547 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0, | |
548 flags | TDF_SLIM, false); | |
549 newline_and_indent (buffer, spc + 2); | |
550 } | |
551 | |
552 if (BLOCK_FRAGMENT_ORIGIN (block)) | |
553 { | |
554 pp_string (buffer, "FRAGMENT_ORIGIN: "); | |
555 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0, | |
556 flags | TDF_SLIM, false); | |
557 newline_and_indent (buffer, spc + 2); | |
558 } | |
559 | |
560 if (BLOCK_FRAGMENT_CHAIN (block)) | |
561 { | |
562 pp_string (buffer, "FRAGMENT_CHAIN: "); | |
563 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t)) | |
564 { | |
565 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false); | |
566 pp_string (buffer, " "); | |
567 } | |
568 newline_and_indent (buffer, spc + 2); | |
569 } | |
570 } | |
571 | |
572 | |
426 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of | 573 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of |
427 indent. FLAGS specifies details to show in the dump (see TDF_* in | 574 indent. FLAGS specifies details to show in the dump (see TDF_* in |
428 tree-pass.h). If IS_STMT is true, the object printed is considered | 575 tree-pass.h). If IS_STMT is true, the object printed is considered |
429 to be a statement and it is terminated by ';' if appropriate. */ | 576 to be a statement and it is terminated by ';' if appropriate. */ |
430 | 577 |
444 | 591 |
445 if (is_stmt && (flags & TDF_STMTADDR)) | 592 if (is_stmt && (flags & TDF_STMTADDR)) |
446 pp_printf (buffer, "<&%p> ", (void *)node); | 593 pp_printf (buffer, "<&%p> ", (void *)node); |
447 | 594 |
448 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node)) | 595 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node)) |
449 { | 596 dump_location (buffer, EXPR_LOCATION (node)); |
450 expanded_location xloc = expand_location (EXPR_LOCATION (node)); | |
451 pp_character (buffer, '['); | |
452 if (xloc.file) | |
453 { | |
454 pp_string (buffer, xloc.file); | |
455 pp_string (buffer, " : "); | |
456 } | |
457 pp_decimal_int (buffer, xloc.line); | |
458 pp_string (buffer, "] "); | |
459 } | |
460 | 597 |
461 switch (TREE_CODE (node)) | 598 switch (TREE_CODE (node)) |
462 { | 599 { |
463 case ERROR_MARK: | 600 case ERROR_MARK: |
464 pp_string (buffer, "<<< error >>>"); | 601 pp_string (buffer, "<<< error >>>"); |
486 } | 623 } |
487 break; | 624 break; |
488 | 625 |
489 case TREE_BINFO: | 626 case TREE_BINFO: |
490 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false); | 627 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false); |
628 break; | |
491 | 629 |
492 case TREE_VEC: | 630 case TREE_VEC: |
493 { | 631 { |
494 size_t i; | 632 size_t i; |
495 if (TREE_VEC_LENGTH (node) > 0) | 633 if (TREE_VEC_LENGTH (node) > 0) |
496 { | 634 { |
497 size_t len = TREE_VEC_LENGTH (node); | 635 size_t len = TREE_VEC_LENGTH (node); |
498 for (i = 0; i < len - 1; i++) | 636 for (i = 0; i < len - 1; i++) |
499 { | 637 { |
500 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags, | 638 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags, |
501 false); | 639 false); |
502 pp_character (buffer, ','); | 640 pp_character (buffer, ','); |
503 pp_space (buffer); | 641 pp_space (buffer); |
504 } | 642 } |
505 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc, | 643 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc, |
506 flags, false); | 644 flags, false); |
507 } | 645 } |
508 } | 646 } |
509 break; | 647 break; |
510 | 648 |
524 pp_string (buffer, "const "); | 662 pp_string (buffer, "const "); |
525 else if (quals & TYPE_QUAL_VOLATILE) | 663 else if (quals & TYPE_QUAL_VOLATILE) |
526 pp_string (buffer, "volatile "); | 664 pp_string (buffer, "volatile "); |
527 else if (quals & TYPE_QUAL_RESTRICT) | 665 else if (quals & TYPE_QUAL_RESTRICT) |
528 pp_string (buffer, "restrict "); | 666 pp_string (buffer, "restrict "); |
667 | |
668 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node))) | |
669 { | |
670 pp_string (buffer, "<address-space-"); | |
671 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node)); | |
672 pp_string (buffer, "> "); | |
673 } | |
529 | 674 |
530 tclass = TREE_CODE_CLASS (TREE_CODE (node)); | 675 tclass = TREE_CODE_CLASS (TREE_CODE (node)); |
531 | 676 |
532 if (tclass == tcc_declaration) | 677 if (tclass == tcc_declaration) |
533 { | 678 { |
549 pp_string (buffer, "<unnamed type>"); | 694 pp_string (buffer, "<unnamed type>"); |
550 } | 695 } |
551 else if (TREE_CODE (node) == VECTOR_TYPE) | 696 else if (TREE_CODE (node) == VECTOR_TYPE) |
552 { | 697 { |
553 pp_string (buffer, "vector "); | 698 pp_string (buffer, "vector "); |
554 dump_generic_node (buffer, TREE_TYPE (node), | 699 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); |
555 spc, flags, false); | |
556 } | 700 } |
557 else if (TREE_CODE (node) == INTEGER_TYPE) | 701 else if (TREE_CODE (node) == INTEGER_TYPE) |
558 { | 702 { |
559 pp_string (buffer, (TYPE_UNSIGNED (node) | 703 pp_string (buffer, (TYPE_UNSIGNED (node) |
560 ? "<unnamed-unsigned:" | 704 ? "<unnamed-unsigned:" |
561 : "<unnamed-signed:")); | 705 : "<unnamed-signed:")); |
562 pp_decimal_int (buffer, TYPE_PRECISION (node)); | 706 pp_decimal_int (buffer, TYPE_PRECISION (node)); |
563 pp_string (buffer, ">"); | 707 pp_string (buffer, ">"); |
564 } | 708 } |
709 else if (TREE_CODE (node) == COMPLEX_TYPE) | |
710 { | |
711 pp_string (buffer, "__complex__ "); | |
712 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); | |
713 } | |
714 else if (TREE_CODE (node) == REAL_TYPE) | |
715 { | |
716 pp_string (buffer, "<float:"); | |
717 pp_decimal_int (buffer, TYPE_PRECISION (node)); | |
718 pp_string (buffer, ">"); | |
719 } | |
720 else if (TREE_CODE (node) == FIXED_POINT_TYPE) | |
721 { | |
722 pp_string (buffer, "<fixed-point-"); | |
723 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:"); | |
724 pp_decimal_int (buffer, TYPE_PRECISION (node)); | |
725 pp_string (buffer, ">"); | |
726 } | |
565 else | 727 else |
566 pp_string (buffer, "<unnamed type>"); | 728 pp_string (buffer, "<unnamed type>"); |
567 } | 729 } |
568 break; | 730 break; |
569 } | 731 } |
570 | 732 |
571 case POINTER_TYPE: | 733 case POINTER_TYPE: |
572 case REFERENCE_TYPE: | 734 case REFERENCE_TYPE: |
573 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&"); | 735 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&"); |
574 | 736 |
575 if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE) | 737 if (TREE_TYPE (node) == NULL) |
738 { | |
739 pp_string (buffer, str); | |
740 pp_string (buffer, "<null type>"); | |
741 } | |
742 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE) | |
576 { | 743 { |
577 tree fnode = TREE_TYPE (node); | 744 tree fnode = TREE_TYPE (node); |
578 | 745 |
579 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false); | 746 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false); |
580 pp_space (buffer); | 747 pp_space (buffer); |
601 if (quals & TYPE_QUAL_VOLATILE) | 768 if (quals & TYPE_QUAL_VOLATILE) |
602 pp_string (buffer, " volatile"); | 769 pp_string (buffer, " volatile"); |
603 if (quals & TYPE_QUAL_RESTRICT) | 770 if (quals & TYPE_QUAL_RESTRICT) |
604 pp_string (buffer, " restrict"); | 771 pp_string (buffer, " restrict"); |
605 | 772 |
773 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node))) | |
774 { | |
775 pp_string (buffer, " <address-space-"); | |
776 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node)); | |
777 pp_string (buffer, ">"); | |
778 } | |
779 | |
606 if (TYPE_REF_CAN_ALIAS_ALL (node)) | 780 if (TYPE_REF_CAN_ALIAS_ALL (node)) |
607 pp_string (buffer, " {ref-all}"); | 781 pp_string (buffer, " {ref-all}"); |
608 } | 782 } |
609 break; | 783 break; |
610 | 784 |
611 case OFFSET_TYPE: | 785 case OFFSET_TYPE: |
612 NIY; | 786 NIY; |
613 break; | |
614 | |
615 case METHOD_TYPE: | |
616 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)), flags); | |
617 pp_string (buffer, "::"); | |
618 break; | 787 break; |
619 | 788 |
620 case TARGET_MEM_REF: | 789 case TARGET_MEM_REF: |
621 { | 790 { |
622 const char *sep = ""; | 791 const char *sep = ""; |
708 else if (TREE_CODE (node) == UNION_TYPE) | 877 else if (TREE_CODE (node) == UNION_TYPE) |
709 pp_string (buffer, "union "); | 878 pp_string (buffer, "union "); |
710 | 879 |
711 if (TYPE_NAME (node)) | 880 if (TYPE_NAME (node)) |
712 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false); | 881 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false); |
713 else | 882 else if (!(flags & TDF_SLIM)) |
883 /* FIXME: If we eliminate the 'else' above and attempt | |
884 to show the fields for named types, we may get stuck | |
885 following a cycle of pointers to structs. The alleged | |
886 self-reference check in print_struct_decl will not detect | |
887 cycles involving more than one pointer or struct type. */ | |
714 print_struct_decl (buffer, node, spc, flags); | 888 print_struct_decl (buffer, node, spc, flags); |
715 break; | 889 break; |
716 } | 890 } |
717 | 891 |
718 case LANG_TYPE: | 892 case LANG_TYPE: |
834 pp_string (buffer, " }"); | 1008 pp_string (buffer, " }"); |
835 } | 1009 } |
836 break; | 1010 break; |
837 | 1011 |
838 case FUNCTION_TYPE: | 1012 case FUNCTION_TYPE: |
1013 case METHOD_TYPE: | |
1014 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); | |
1015 pp_space (buffer); | |
1016 if (TREE_CODE (node) == METHOD_TYPE) | |
1017 { | |
1018 if (TYPE_METHOD_BASETYPE (node)) | |
1019 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)), | |
1020 flags); | |
1021 else | |
1022 pp_string (buffer, "<null method basetype>"); | |
1023 pp_string (buffer, "::"); | |
1024 } | |
1025 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node))) | |
1026 dump_decl_name (buffer, TYPE_NAME (node), flags); | |
1027 else | |
1028 pp_printf (buffer, "<T%x>", TYPE_UID (node)); | |
1029 dump_function_declaration (buffer, node, spc, flags); | |
839 break; | 1030 break; |
840 | 1031 |
841 case FUNCTION_DECL: | 1032 case FUNCTION_DECL: |
842 case CONST_DECL: | 1033 case CONST_DECL: |
843 dump_decl_name (buffer, node, flags); | 1034 dump_decl_name (buffer, node, flags); |
845 | 1036 |
846 case LABEL_DECL: | 1037 case LABEL_DECL: |
847 if (DECL_NAME (node)) | 1038 if (DECL_NAME (node)) |
848 dump_decl_name (buffer, node, flags); | 1039 dump_decl_name (buffer, node, flags); |
849 else if (LABEL_DECL_UID (node) != -1) | 1040 else if (LABEL_DECL_UID (node) != -1) |
850 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node)); | 1041 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node)); |
851 else | 1042 else |
852 pp_printf (buffer, "<D.%u>", DECL_UID (node)); | 1043 { |
1044 if (flags & TDF_NOUID) | |
1045 pp_string (buffer, "<D.xxxx>"); | |
1046 else | |
1047 pp_printf (buffer, "<D.%u>", DECL_UID (node)); | |
1048 } | |
853 break; | 1049 break; |
854 | 1050 |
855 case TYPE_DECL: | 1051 case TYPE_DECL: |
856 if (DECL_IS_BUILTIN (node)) | 1052 if (DECL_IS_BUILTIN (node)) |
857 { | 1053 { |
879 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); | 1075 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); |
880 } | 1076 } |
881 } | 1077 } |
882 break; | 1078 break; |
883 | 1079 |
884 case SYMBOL_MEMORY_TAG: | |
885 case NAME_MEMORY_TAG: | |
886 case VAR_DECL: | 1080 case VAR_DECL: |
887 case PARM_DECL: | 1081 case PARM_DECL: |
888 case FIELD_DECL: | 1082 case FIELD_DECL: |
1083 case DEBUG_EXPR_DECL: | |
889 case NAMESPACE_DECL: | 1084 case NAMESPACE_DECL: |
890 case MEMORY_PARTITION_TAG: | |
891 dump_decl_name (buffer, node, flags); | 1085 dump_decl_name (buffer, node, flags); |
892 break; | 1086 break; |
893 | 1087 |
894 case RESULT_DECL: | 1088 case RESULT_DECL: |
895 pp_string (buffer, "<retval>"); | 1089 pp_string (buffer, "<retval>"); |
896 break; | 1090 break; |
897 | 1091 |
898 case COMPONENT_REF: | 1092 case COMPONENT_REF: |
899 op0 = TREE_OPERAND (node, 0); | 1093 op0 = TREE_OPERAND (node, 0); |
900 str = "."; | 1094 str = "."; |
901 if (TREE_CODE (op0) == INDIRECT_REF) | 1095 if (op0 && TREE_CODE (op0) == INDIRECT_REF) |
902 { | 1096 { |
903 op0 = TREE_OPERAND (op0, 0); | 1097 op0 = TREE_OPERAND (op0, 0); |
904 str = "->"; | 1098 str = "->"; |
905 } | 1099 } |
906 if (op_prio (op0) < op_prio (node)) | 1100 if (op_prio (op0) < op_prio (node)) |
1171 } | 1365 } |
1172 is_expr = false; | 1366 is_expr = false; |
1173 break; | 1367 break; |
1174 | 1368 |
1175 case CALL_EXPR: | 1369 case CALL_EXPR: |
1176 print_call_name (buffer, node); | 1370 print_call_name (buffer, CALL_EXPR_FN (node), flags); |
1177 | 1371 |
1178 /* Print parameters. */ | 1372 /* Print parameters. */ |
1179 pp_space (buffer); | 1373 pp_space (buffer); |
1180 pp_character (buffer, '('); | 1374 pp_character (buffer, '('); |
1181 { | 1375 { |
1381 | 1575 |
1382 case RANGE_EXPR: | 1576 case RANGE_EXPR: |
1383 NIY; | 1577 NIY; |
1384 break; | 1578 break; |
1385 | 1579 |
1580 case ADDR_SPACE_CONVERT_EXPR: | |
1386 case FIXED_CONVERT_EXPR: | 1581 case FIXED_CONVERT_EXPR: |
1387 case FIX_TRUNC_EXPR: | 1582 case FIX_TRUNC_EXPR: |
1388 case FLOAT_EXPR: | 1583 case FLOAT_EXPR: |
1389 CASE_CONVERT: | 1584 CASE_CONVERT: |
1390 type = TREE_TYPE (node); | 1585 type = TREE_TYPE (node); |
1505 newline_and_indent (buffer, spc+2); | 1700 newline_and_indent (buffer, spc+2); |
1506 pp_string (buffer, "}"); | 1701 pp_string (buffer, "}"); |
1507 is_expr = false; | 1702 is_expr = false; |
1508 break; | 1703 break; |
1509 | 1704 |
1510 case CHANGE_DYNAMIC_TYPE_EXPR: | |
1511 pp_string (buffer, "<<<change_dynamic_type ("); | |
1512 dump_generic_node (buffer, CHANGE_DYNAMIC_TYPE_NEW_TYPE (node), spc + 2, | |
1513 flags, false); | |
1514 pp_string (buffer, ") "); | |
1515 dump_generic_node (buffer, CHANGE_DYNAMIC_TYPE_LOCATION (node), spc + 2, | |
1516 flags, false); | |
1517 pp_string (buffer, ")>>>"); | |
1518 is_expr = false; | |
1519 break; | |
1520 | |
1521 case LABEL_EXPR: | 1705 case LABEL_EXPR: |
1522 op0 = TREE_OPERAND (node, 0); | 1706 op0 = TREE_OPERAND (node, 0); |
1523 /* If this is for break or continue, don't bother printing it. */ | 1707 /* If this is for break or continue, don't bother printing it. */ |
1524 if (DECL_NAME (op0)) | 1708 if (DECL_NAME (op0)) |
1525 { | 1709 { |
1530 } | 1714 } |
1531 dump_generic_node (buffer, op0, spc, flags, false); | 1715 dump_generic_node (buffer, op0, spc, flags, false); |
1532 pp_character (buffer, ':'); | 1716 pp_character (buffer, ':'); |
1533 if (DECL_NONLOCAL (op0)) | 1717 if (DECL_NONLOCAL (op0)) |
1534 pp_string (buffer, " [non-local]"); | 1718 pp_string (buffer, " [non-local]"); |
1535 break; | |
1536 | |
1537 case EXC_PTR_EXPR: | |
1538 pp_string (buffer, "<<<exception object>>>"); | |
1539 break; | |
1540 | |
1541 case FILTER_EXPR: | |
1542 pp_string (buffer, "<<<filter object>>>"); | |
1543 break; | 1719 break; |
1544 | 1720 |
1545 case LOOP_EXPR: | 1721 case LOOP_EXPR: |
1546 pp_string (buffer, "while (1)"); | 1722 pp_string (buffer, "while (1)"); |
1547 if (!(flags & TDF_SLIM)) | 1723 if (!(flags & TDF_SLIM)) |
1640 } | 1816 } |
1641 pp_string (buffer, "goto "); | 1817 pp_string (buffer, "goto "); |
1642 dump_generic_node (buffer, op0, spc, flags, false); | 1818 dump_generic_node (buffer, op0, spc, flags, false); |
1643 break; | 1819 break; |
1644 | 1820 |
1645 case RESX_EXPR: | |
1646 pp_string (buffer, "resx "); | |
1647 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); | |
1648 break; | |
1649 | |
1650 case ASM_EXPR: | 1821 case ASM_EXPR: |
1651 pp_string (buffer, "__asm__"); | 1822 pp_string (buffer, "__asm__"); |
1652 if (ASM_VOLATILE_P (node)) | 1823 if (ASM_VOLATILE_P (node)) |
1653 pp_string (buffer, " __volatile__"); | 1824 pp_string (buffer, " __volatile__"); |
1654 pp_character (buffer, '('); | 1825 pp_character (buffer, '('); |
1745 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); | 1916 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); |
1746 pp_string (buffer, ", "); | 1917 pp_string (buffer, ", "); |
1747 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false); | 1918 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false); |
1748 pp_string (buffer, ">"); | 1919 pp_string (buffer, ">"); |
1749 break; | 1920 break; |
1750 | 1921 |
1751 case VEC_COND_EXPR: | 1922 case VEC_COND_EXPR: |
1752 pp_string (buffer, " VEC_COND_EXPR < "); | 1923 pp_string (buffer, " VEC_COND_EXPR < "); |
1753 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); | 1924 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); |
1754 pp_string (buffer, " , "); | 1925 pp_string (buffer, " , "); |
1755 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); | 1926 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); |
1850 goto dump_omp_body; | 2021 goto dump_omp_body; |
1851 | 2022 |
1852 case OMP_SECTION: | 2023 case OMP_SECTION: |
1853 pp_string (buffer, "#pragma omp section"); | 2024 pp_string (buffer, "#pragma omp section"); |
1854 goto dump_omp_body; | 2025 goto dump_omp_body; |
1855 | 2026 |
1856 case OMP_MASTER: | 2027 case OMP_MASTER: |
1857 pp_string (buffer, "#pragma omp master"); | 2028 pp_string (buffer, "#pragma omp master"); |
1858 goto dump_omp_body; | 2029 goto dump_omp_body; |
1859 | 2030 |
1860 case OMP_ORDERED: | 2031 case OMP_ORDERED: |
1974 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); | 2145 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); |
1975 pp_string (buffer, " > "); | 2146 pp_string (buffer, " > "); |
1976 break; | 2147 break; |
1977 | 2148 |
1978 case BLOCK: | 2149 case BLOCK: |
1979 { | 2150 dump_block_node (buffer, node, spc, flags); |
1980 tree t; | 2151 break; |
1981 pp_string (buffer, "BLOCK"); | |
1982 | |
1983 if (BLOCK_ABSTRACT (node)) | |
1984 pp_string (buffer, " [abstract]"); | |
1985 | |
1986 if (TREE_ASM_WRITTEN (node)) | |
1987 pp_string (buffer, " [written]"); | |
1988 | |
1989 newline_and_indent (buffer, spc + 2); | |
1990 | |
1991 if (BLOCK_SUPERCONTEXT (node)) | |
1992 { | |
1993 pp_string (buffer, "SUPERCONTEXT: "); | |
1994 if (TREE_CODE (BLOCK_SUPERCONTEXT (node)) == BLOCK) | |
1995 pp_printf (buffer, "BLOCK %p", | |
1996 (void *)BLOCK_SUPERCONTEXT (node)); | |
1997 else | |
1998 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (node), 0, flags, | |
1999 false); | |
2000 newline_and_indent (buffer, spc + 2); | |
2001 } | |
2002 | |
2003 if (BLOCK_SUBBLOCKS (node)) | |
2004 { | |
2005 pp_string (buffer, "SUBBLOCKS: "); | |
2006 for (t = BLOCK_SUBBLOCKS (node); t; t = BLOCK_CHAIN (t)) | |
2007 pp_printf (buffer, "%p ", (void *)t); | |
2008 newline_and_indent (buffer, spc + 2); | |
2009 } | |
2010 | |
2011 if (BLOCK_VARS (node)) | |
2012 { | |
2013 pp_string (buffer, "VARS: "); | |
2014 for (t = BLOCK_VARS (node); t; t = TREE_CHAIN (t)) | |
2015 { | |
2016 dump_generic_node (buffer, t, 0, flags, false); | |
2017 pp_string (buffer, " "); | |
2018 } | |
2019 newline_and_indent (buffer, spc + 2); | |
2020 } | |
2021 | |
2022 if (BLOCK_ABSTRACT_ORIGIN (node)) | |
2023 { | |
2024 pp_string (buffer, "ABSTRACT_ORIGIN: "); | |
2025 if (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (node)) == BLOCK) | |
2026 pp_printf (buffer, "BLOCK %p", | |
2027 (void *)BLOCK_ABSTRACT_ORIGIN (node)); | |
2028 else | |
2029 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (node), 0, flags, | |
2030 false); | |
2031 newline_and_indent (buffer, spc + 2); | |
2032 } | |
2033 } | |
2034 break; | |
2035 | 2152 |
2036 case VEC_EXTRACT_EVEN_EXPR: | 2153 case VEC_EXTRACT_EVEN_EXPR: |
2037 pp_string (buffer, " VEC_EXTRACT_EVEN_EXPR < "); | 2154 pp_string (buffer, " VEC_EXTRACT_EVEN_EXPR < "); |
2038 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); | 2155 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); |
2039 pp_string (buffer, ", "); | 2156 pp_string (buffer, ", "); |
2040 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); | 2157 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); |
2041 pp_string (buffer, " > "); | 2158 pp_string (buffer, " > "); |
2042 break; | 2159 break; |
2043 | 2160 |
2044 case VEC_EXTRACT_ODD_EXPR: | 2161 case VEC_EXTRACT_ODD_EXPR: |
2045 pp_string (buffer, " VEC_EXTRACT_ODD_EXPR < "); | 2162 pp_string (buffer, " VEC_EXTRACT_ODD_EXPR < "); |
2046 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); | 2163 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); |
2047 pp_string (buffer, ", "); | 2164 pp_string (buffer, ", "); |
2048 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); | 2165 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); |
2207 /* FIXME : Not implemented correctly..., | 2324 /* FIXME : Not implemented correctly..., |
2208 what about the case when we have a cycle in the contain graph? ... | 2325 what about the case when we have a cycle in the contain graph? ... |
2209 Maybe this could be solved by looking at the scope in which the | 2326 Maybe this could be solved by looking at the scope in which the |
2210 structure was declared. */ | 2327 structure was declared. */ |
2211 if (TREE_TYPE (tmp) != node | 2328 if (TREE_TYPE (tmp) != node |
2212 || (TREE_CODE (TREE_TYPE (tmp)) == POINTER_TYPE | 2329 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE |
2213 && TREE_TYPE (TREE_TYPE (tmp)) != node)) | 2330 || TREE_TYPE (TREE_TYPE (tmp)) != node)) |
2214 { | 2331 { |
2215 print_declaration (buffer, tmp, spc+2, flags); | 2332 print_declaration (buffer, tmp, spc+2, flags); |
2216 pp_newline (buffer); | 2333 pp_newline (buffer); |
2217 } | 2334 } |
2218 tmp = TREE_CHAIN (tmp); | 2335 tmp = TREE_CHAIN (tmp); |
2477 case VEC_RSHIFT_EXPR: | 2594 case VEC_RSHIFT_EXPR: |
2478 return "v>>"; | 2595 return "v>>"; |
2479 | 2596 |
2480 case POINTER_PLUS_EXPR: | 2597 case POINTER_PLUS_EXPR: |
2481 return "+"; | 2598 return "+"; |
2482 | 2599 |
2483 case PLUS_EXPR: | 2600 case PLUS_EXPR: |
2484 return "+"; | 2601 return "+"; |
2485 | 2602 |
2486 case REDUC_PLUS_EXPR: | 2603 case REDUC_PLUS_EXPR: |
2487 return "r+"; | 2604 return "r+"; |
2569 op_symbol (const_tree op) | 2686 op_symbol (const_tree op) |
2570 { | 2687 { |
2571 return op_symbol_code (TREE_CODE (op)); | 2688 return op_symbol_code (TREE_CODE (op)); |
2572 } | 2689 } |
2573 | 2690 |
2574 /* Prints the name of a CALL_EXPR. */ | 2691 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or |
2575 | 2692 the gimple_call_fn of a GIMPLE_CALL. */ |
2576 static void | 2693 |
2577 print_call_name (pretty_printer *buffer, const_tree node) | 2694 void |
2695 print_call_name (pretty_printer *buffer, tree node, int flags) | |
2578 { | 2696 { |
2579 tree op0; | 2697 tree op0 = node; |
2580 | |
2581 gcc_assert (TREE_CODE (node) == CALL_EXPR); | |
2582 | |
2583 op0 = CALL_EXPR_FN (node); | |
2584 | 2698 |
2585 if (TREE_CODE (op0) == NON_LVALUE_EXPR) | 2699 if (TREE_CODE (op0) == NON_LVALUE_EXPR) |
2586 op0 = TREE_OPERAND (op0, 0); | 2700 op0 = TREE_OPERAND (op0, 0); |
2587 | 2701 |
2702 again: | |
2588 switch (TREE_CODE (op0)) | 2703 switch (TREE_CODE (op0)) |
2589 { | 2704 { |
2590 case VAR_DECL: | 2705 case VAR_DECL: |
2591 case PARM_DECL: | 2706 case PARM_DECL: |
2592 dump_function_name (buffer, op0); | 2707 case FUNCTION_DECL: |
2708 dump_function_name (buffer, op0, flags); | |
2593 break; | 2709 break; |
2594 | 2710 |
2595 case ADDR_EXPR: | 2711 case ADDR_EXPR: |
2596 case INDIRECT_REF: | 2712 case INDIRECT_REF: |
2597 case NOP_EXPR: | 2713 case NOP_EXPR: |
2598 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false); | 2714 op0 = TREE_OPERAND (op0, 0); |
2599 break; | 2715 goto again; |
2600 | 2716 |
2601 case COND_EXPR: | 2717 case COND_EXPR: |
2602 pp_string (buffer, "("); | 2718 pp_string (buffer, "("); |
2603 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false); | 2719 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false); |
2604 pp_string (buffer, ") ? "); | 2720 pp_string (buffer, ") ? "); |
2605 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, 0, false); | 2721 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false); |
2606 pp_string (buffer, " : "); | 2722 pp_string (buffer, " : "); |
2607 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, 0, false); | 2723 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false); |
2608 break; | |
2609 | |
2610 case COMPONENT_REF: | |
2611 /* The function is a pointer contained in a structure. */ | |
2612 if (TREE_CODE (TREE_OPERAND (op0, 0)) == INDIRECT_REF || | |
2613 TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) | |
2614 dump_function_name (buffer, TREE_OPERAND (op0, 1)); | |
2615 else | |
2616 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false); | |
2617 /* else | |
2618 We can have several levels of structures and a function | |
2619 pointer inside. This is not implemented yet... */ | |
2620 /* NIY;*/ | |
2621 break; | 2724 break; |
2622 | 2725 |
2623 case ARRAY_REF: | 2726 case ARRAY_REF: |
2624 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) | 2727 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) |
2625 dump_function_name (buffer, TREE_OPERAND (op0, 0)); | 2728 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags); |
2626 else | 2729 else |
2627 dump_generic_node (buffer, op0, 0, 0, false); | 2730 dump_generic_node (buffer, op0, 0, flags, false); |
2628 break; | 2731 break; |
2629 | 2732 |
2733 case COMPONENT_REF: | |
2630 case SSA_NAME: | 2734 case SSA_NAME: |
2631 case OBJ_TYPE_REF: | 2735 case OBJ_TYPE_REF: |
2632 dump_generic_node (buffer, op0, 0, 0, false); | 2736 dump_generic_node (buffer, op0, 0, flags, false); |
2633 break; | 2737 break; |
2634 | 2738 |
2635 default: | 2739 default: |
2636 NIY; | 2740 NIY; |
2637 } | 2741 } |
2728 { | 2832 { |
2729 if (!initialized) | 2833 if (!initialized) |
2730 { | 2834 { |
2731 pp_construct (&buffer, /* prefix */NULL, /* line-width */0); | 2835 pp_construct (&buffer, /* prefix */NULL, /* line-width */0); |
2732 pp_needs_newline (&buffer) = true; | 2836 pp_needs_newline (&buffer) = true; |
2837 pp_translate_identifiers (&buffer) = false; | |
2733 initialized = 1; | 2838 initialized = 1; |
2734 } | 2839 } |
2735 | 2840 |
2736 buffer.buffer->stream = file; | 2841 buffer.buffer->stream = file; |
2737 } | 2842 } |