Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-ssa-operands.c @ 69:1b10fe6932e1
merge 69
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 07:53:12 +0900 |
parents | 326d9e06c2e3 f6334be47118 |
children | ab0bcb71f44d |
comparison
equal
deleted
inserted
replaced
66:b362627d71ba | 69:1b10fe6932e1 |
---|---|
1 /* SSA operands management for trees. | 1 /* SSA operands management for trees. |
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify | 7 GCC is free software; you can redistribute it and/or modify |
23 #include "coretypes.h" | 23 #include "coretypes.h" |
24 #include "tm.h" | 24 #include "tm.h" |
25 #include "tree.h" | 25 #include "tree.h" |
26 #include "flags.h" | 26 #include "flags.h" |
27 #include "function.h" | 27 #include "function.h" |
28 #include "diagnostic.h" | 28 #include "tree-pretty-print.h" |
29 #include "gimple-pretty-print.h" | |
29 #include "tree-flow.h" | 30 #include "tree-flow.h" |
30 #include "tree-inline.h" | 31 #include "tree-inline.h" |
31 #include "tree-pass.h" | 32 #include "tree-pass.h" |
32 #include "ggc.h" | 33 #include "ggc.h" |
33 #include "timevar.h" | 34 #include "timevar.h" |
34 #include "toplev.h" | |
35 #include "langhooks.h" | 35 #include "langhooks.h" |
36 #include "ipa-reference.h" | 36 #include "ipa-reference.h" |
37 #ifndef noCbC | 37 #ifndef noCbC |
38 #include "cbc-tree.h" | 38 #include "cbc-tree.h" |
39 #endif | 39 #endif |
126 | 126 |
127 /* Operand is an implicit reference. This is used to distinguish | 127 /* Operand is an implicit reference. This is used to distinguish |
128 explicit assignments in the form of MODIFY_EXPR from | 128 explicit assignments in the form of MODIFY_EXPR from |
129 clobbering sites like function calls or ASM_EXPRs. */ | 129 clobbering sites like function calls or ASM_EXPRs. */ |
130 #define opf_implicit (1 << 2) | 130 #define opf_implicit (1 << 2) |
131 | |
132 /* Operand is in a place where address-taken does not imply addressable. */ | |
133 #define opf_non_addressable (1 << 3) | |
134 | |
135 /* Operand is in a place where opf_non_addressable does not apply. */ | |
136 #define opf_not_non_addressable (1 << 4) | |
131 | 137 |
132 /* Array for building all the def operands. */ | 138 /* Array for building all the def operands. */ |
133 static VEC(tree,heap) *build_defs; | 139 static VEC(tree,heap) *build_defs; |
134 | 140 |
135 /* Array for building all the use operands. */ | 141 /* Array for building all the use operands. */ |
320 break; | 326 break; |
321 default: | 327 default: |
322 gcc_unreachable (); | 328 gcc_unreachable (); |
323 } | 329 } |
324 | 330 |
325 ptr = (struct ssa_operand_memory_d *) | 331 |
326 ggc_alloc (sizeof (void *) | 332 ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *) |
327 + gimple_ssa_operands (cfun)->ssa_operand_mem_size); | 333 + gimple_ssa_operands (cfun)->ssa_operand_mem_size); |
334 | |
328 ptr->next = gimple_ssa_operands (cfun)->operand_memory; | 335 ptr->next = gimple_ssa_operands (cfun)->operand_memory; |
329 gimple_ssa_operands (cfun)->operand_memory = ptr; | 336 gimple_ssa_operands (cfun)->operand_memory = ptr; |
330 gimple_ssa_operands (cfun)->operand_memory_index = 0; | 337 gimple_ssa_operands (cfun)->operand_memory_index = 0; |
331 } | 338 } |
332 | 339 |
692 as the only thing we take the address of. If VAR is a structure, | 699 as the only thing we take the address of. If VAR is a structure, |
693 taking the address of a field means that the whole structure may | 700 taking the address of a field means that the whole structure may |
694 be referenced using pointer arithmetic. See PR 21407 and the | 701 be referenced using pointer arithmetic. See PR 21407 and the |
695 ensuing mailing list discussion. */ | 702 ensuing mailing list discussion. */ |
696 var = get_base_address (ref); | 703 var = get_base_address (ref); |
697 if (var && DECL_P (var)) | 704 if (var) |
698 TREE_ADDRESSABLE (var) = 1; | 705 { |
699 } | 706 if (DECL_P (var)) |
700 | 707 TREE_ADDRESSABLE (var) = 1; |
701 | 708 else if (TREE_CODE (var) == MEM_REF |
702 /* A subroutine of get_expr_operands to handle INDIRECT_REF, | 709 && TREE_CODE (TREE_OPERAND (var, 0)) == ADDR_EXPR |
703 ALIGN_INDIRECT_REF and MISALIGNED_INDIRECT_REF. | 710 && DECL_P (TREE_OPERAND (TREE_OPERAND (var, 0), 0))) |
704 | 711 TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (var, 0), 0)) = 1; |
705 STMT is the statement being processed, EXPR is the INDIRECT_REF | 712 } |
713 } | |
714 | |
715 | |
716 /* A subroutine of get_expr_operands to handle MEM_REF. | |
717 | |
718 STMT is the statement being processed, EXPR is the MEM_REF | |
706 that got us here. | 719 that got us here. |
707 | 720 |
708 FLAGS is as in get_expr_operands. | 721 FLAGS is as in get_expr_operands. |
709 | 722 |
710 RECURSE_ON_BASE should be set to true if we want to continue | 723 RECURSE_ON_BASE should be set to true if we want to continue |
724 add_virtual_operand (stmt, flags); | 737 add_virtual_operand (stmt, flags); |
725 | 738 |
726 /* If requested, add a USE operand for the base pointer. */ | 739 /* If requested, add a USE operand for the base pointer. */ |
727 if (recurse_on_base) | 740 if (recurse_on_base) |
728 get_expr_operands (stmt, pptr, | 741 get_expr_operands (stmt, pptr, |
729 opf_use | (flags & opf_no_vops)); | 742 opf_non_addressable | opf_use |
743 | (flags & (opf_no_vops|opf_not_non_addressable))); | |
730 } | 744 } |
731 | 745 |
732 | 746 |
733 /* A subroutine of get_expr_operands to handle TARGET_MEM_REF. */ | 747 /* A subroutine of get_expr_operands to handle TARGET_MEM_REF. */ |
734 | 748 |
735 static void | 749 static void |
736 get_tmr_operands (gimple stmt, tree expr, int flags) | 750 get_tmr_operands (gimple stmt, tree expr, int flags) |
737 { | 751 { |
752 if (TREE_THIS_VOLATILE (expr)) | |
753 gimple_set_has_volatile_ops (stmt, true); | |
754 | |
738 /* First record the real operands. */ | 755 /* First record the real operands. */ |
739 get_expr_operands (stmt, &TMR_BASE (expr), opf_use | (flags & opf_no_vops)); | 756 get_expr_operands (stmt, &TMR_BASE (expr), opf_use | (flags & opf_no_vops)); |
740 get_expr_operands (stmt, &TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); | 757 get_expr_operands (stmt, &TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); |
741 | 758 get_expr_operands (stmt, &TMR_INDEX2 (expr), opf_use | (flags & opf_no_vops)); |
742 if (TMR_SYMBOL (expr)) | |
743 mark_address_taken (TMR_SYMBOL (expr)); | |
744 | 759 |
745 add_virtual_operand (stmt, flags); | 760 add_virtual_operand (stmt, flags); |
746 } | 761 } |
747 | 762 |
748 | 763 |
796 gcc_assert (!allows_reg || !is_inout); | 811 gcc_assert (!allows_reg || !is_inout); |
797 | 812 |
798 /* Memory operands are addressable. Note that STMT needs the | 813 /* Memory operands are addressable. Note that STMT needs the |
799 address of this operand. */ | 814 address of this operand. */ |
800 if (!allows_reg && allows_mem) | 815 if (!allows_reg && allows_mem) |
801 { | 816 mark_address_taken (TREE_VALUE (link)); |
802 tree t = get_base_address (TREE_VALUE (link)); | 817 |
803 if (t && DECL_P (t)) | 818 get_expr_operands (stmt, &TREE_VALUE (link), opf_def | opf_not_non_addressable); |
804 mark_address_taken (t); | |
805 } | |
806 | |
807 get_expr_operands (stmt, &TREE_VALUE (link), opf_def); | |
808 } | 819 } |
809 | 820 |
810 /* Gather all input operands. */ | 821 /* Gather all input operands. */ |
811 for (i = 0; i < gimple_asm_ninputs (stmt); i++) | 822 for (i = 0; i < gimple_asm_ninputs (stmt); i++) |
812 { | 823 { |
816 &allows_mem, &allows_reg); | 827 &allows_mem, &allows_reg); |
817 | 828 |
818 /* Memory operands are addressable. Note that STMT needs the | 829 /* Memory operands are addressable. Note that STMT needs the |
819 address of this operand. */ | 830 address of this operand. */ |
820 if (!allows_reg && allows_mem) | 831 if (!allows_reg && allows_mem) |
821 { | 832 mark_address_taken (TREE_VALUE (link)); |
822 tree t = get_base_address (TREE_VALUE (link)); | 833 |
823 if (t && DECL_P (t)) | 834 get_expr_operands (stmt, &TREE_VALUE (link), opf_not_non_addressable); |
824 mark_address_taken (t); | |
825 } | |
826 | |
827 get_expr_operands (stmt, &TREE_VALUE (link), 0); | |
828 } | 835 } |
829 | 836 |
830 /* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */ | 837 /* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */ |
831 for (i = 0; i < gimple_asm_nclobbers (stmt); i++) | 838 for (i = 0; i < gimple_asm_nclobbers (stmt); i++) |
832 { | 839 { |
866 case ADDR_EXPR: | 873 case ADDR_EXPR: |
867 /* Taking the address of a variable does not represent a | 874 /* Taking the address of a variable does not represent a |
868 reference to it, but the fact that the statement takes its | 875 reference to it, but the fact that the statement takes its |
869 address will be of interest to some passes (e.g. alias | 876 address will be of interest to some passes (e.g. alias |
870 resolution). */ | 877 resolution). */ |
871 if (!is_gimple_debug (stmt)) | 878 if ((!(flags & opf_non_addressable) |
879 || (flags & opf_not_non_addressable)) | |
880 && !is_gimple_debug (stmt)) | |
872 mark_address_taken (TREE_OPERAND (expr, 0)); | 881 mark_address_taken (TREE_OPERAND (expr, 0)); |
873 | 882 |
874 /* If the address is invariant, there may be no interesting | 883 /* If the address is invariant, there may be no interesting |
875 variable references inside. */ | 884 variable references inside. */ |
876 if (is_gimple_min_invariant (expr)) | 885 if (is_gimple_min_invariant (expr)) |
880 should be no VUSEs created, since the referenced objects are | 889 should be no VUSEs created, since the referenced objects are |
881 not really accessed. The only operands that we should find | 890 not really accessed. The only operands that we should find |
882 here are ARRAY_REF indices which will always be real operands | 891 here are ARRAY_REF indices which will always be real operands |
883 (GIMPLE does not allow non-registers as array indices). */ | 892 (GIMPLE does not allow non-registers as array indices). */ |
884 flags |= opf_no_vops; | 893 flags |= opf_no_vops; |
885 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); | 894 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), |
895 flags | opf_not_non_addressable); | |
886 return; | 896 return; |
887 | 897 |
888 case SSA_NAME: | 898 case SSA_NAME: |
889 add_stmt_operand (expr_p, stmt, flags); | 899 add_stmt_operand (expr_p, stmt, flags); |
890 return; | 900 return; |
897 | 907 |
898 case DEBUG_EXPR_DECL: | 908 case DEBUG_EXPR_DECL: |
899 gcc_assert (gimple_debug_bind_p (stmt)); | 909 gcc_assert (gimple_debug_bind_p (stmt)); |
900 return; | 910 return; |
901 | 911 |
902 case MISALIGNED_INDIRECT_REF: | 912 case MEM_REF: |
903 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); | |
904 /* fall through */ | |
905 | |
906 case ALIGN_INDIRECT_REF: | |
907 case INDIRECT_REF: | |
908 get_indirect_ref_operands (stmt, expr, flags, true); | 913 get_indirect_ref_operands (stmt, expr, flags, true); |
909 return; | 914 return; |
910 | 915 |
911 case TARGET_MEM_REF: | 916 case TARGET_MEM_REF: |
912 get_tmr_operands (stmt, expr, flags); | 917 get_tmr_operands (stmt, expr, flags); |
992 return; | 997 return; |
993 } | 998 } |
994 | 999 |
995 case DOT_PROD_EXPR: | 1000 case DOT_PROD_EXPR: |
996 case REALIGN_LOAD_EXPR: | 1001 case REALIGN_LOAD_EXPR: |
1002 case WIDEN_MULT_PLUS_EXPR: | |
1003 case WIDEN_MULT_MINUS_EXPR: | |
1004 case FMA_EXPR: | |
997 { | 1005 { |
998 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); | 1006 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); |
999 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); | 1007 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); |
1000 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), flags); | 1008 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), flags); |
1001 return; | 1009 return; |
1002 } | 1010 } |
1003 | 1011 |
1004 case FUNCTION_DECL: | 1012 case FUNCTION_DECL: |
1005 case LABEL_DECL: | 1013 case LABEL_DECL: |
1006 case CONST_DECL: | 1014 case CONST_DECL: |
1184 | 1192 |
1185 | 1193 |
1186 /* Scan the immediate_use list for VAR making sure its linked properly. | 1194 /* Scan the immediate_use list for VAR making sure its linked properly. |
1187 Return TRUE if there is a problem and emit an error message to F. */ | 1195 Return TRUE if there is a problem and emit an error message to F. */ |
1188 | 1196 |
1189 bool | 1197 DEBUG_FUNCTION bool |
1190 verify_imm_links (FILE *f, tree var) | 1198 verify_imm_links (FILE *f, tree var) |
1191 { | 1199 { |
1192 use_operand_p ptr, prev, list; | 1200 use_operand_p ptr, prev, list; |
1193 int count; | 1201 int count; |
1194 | 1202 |
1308 } | 1316 } |
1309 | 1317 |
1310 | 1318 |
1311 /* Dump def-use edges on stderr. */ | 1319 /* Dump def-use edges on stderr. */ |
1312 | 1320 |
1313 void | 1321 DEBUG_FUNCTION void |
1314 debug_immediate_uses (void) | 1322 debug_immediate_uses (void) |
1315 { | 1323 { |
1316 dump_immediate_uses (stderr); | 1324 dump_immediate_uses (stderr); |
1317 } | 1325 } |
1318 | 1326 |
1319 | 1327 |
1320 /* Dump def-use edges on stderr. */ | 1328 /* Dump def-use edges on stderr. */ |
1321 | 1329 |
1322 void | 1330 DEBUG_FUNCTION void |
1323 debug_immediate_uses_for (tree var) | 1331 debug_immediate_uses_for (tree var) |
1324 { | 1332 { |
1325 dump_immediate_uses_for (stderr, var); | 1333 dump_immediate_uses_for (stderr, var); |
1326 } | 1334 } |
1327 | 1335 |