Mercurial > hg > CbC > CbC_gcc
annotate 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 |
rev | line source |
---|---|
0 | 1 /* SSA operands management for trees. |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
0 | 3 Free Software Foundation, Inc. |
4 | |
5 This file is part of GCC. | |
6 | |
7 GCC is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 3, or (at your option) | |
10 any later version. | |
11 | |
12 GCC is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GCC; see the file COPYING3. If not see | |
19 <http://www.gnu.org/licenses/>. */ | |
20 | |
21 #include "config.h" | |
22 #include "system.h" | |
23 #include "coretypes.h" | |
24 #include "tm.h" | |
25 #include "tree.h" | |
26 #include "flags.h" | |
27 #include "function.h" | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
28 #include "tree-pretty-print.h" |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
29 #include "gimple-pretty-print.h" |
0 | 30 #include "tree-flow.h" |
31 #include "tree-inline.h" | |
32 #include "tree-pass.h" | |
33 #include "ggc.h" | |
34 #include "timevar.h" | |
35 #include "langhooks.h" | |
36 #include "ipa-reference.h" | |
1 | 37 #ifndef noCbC |
38 #include "cbc-tree.h" | |
39 #endif | |
0 | 40 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
41 /* This file contains the code required to manage the operands cache of the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
42 SSA optimizer. For every stmt, we maintain an operand cache in the stmt |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
43 annotation. This cache contains operands that will be of interest to |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
44 optimizers and other passes wishing to manipulate the IL. |
0 | 45 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
46 The operand type are broken up into REAL and VIRTUAL operands. The real |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
47 operands are represented as pointers into the stmt's operand tree. Thus |
0 | 48 any manipulation of the real operands will be reflected in the actual tree. |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
49 Virtual operands are represented solely in the cache, although the base |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
50 variable for the SSA_NAME may, or may not occur in the stmt's tree. |
0 | 51 Manipulation of the virtual operands will not be reflected in the stmt tree. |
52 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
53 The routines in this file are concerned with creating this operand cache |
0 | 54 from a stmt tree. |
55 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
56 The operand tree is the parsed by the various get_* routines which look |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
57 through the stmt tree for the occurrence of operands which may be of |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
58 interest, and calls are made to the append_* routines whenever one is |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
59 found. There are 4 of these routines, each representing one of the |
0 | 60 4 types of operands. Defs, Uses, Virtual Uses, and Virtual May Defs. |
61 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
62 The append_* routines check for duplication, and simply keep a list of |
0 | 63 unique objects for each operand type in the build_* extendable vectors. |
64 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
65 Once the stmt tree is completely parsed, the finalize_ssa_operands() |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
66 routine is called, which proceeds to perform the finalization routine |
0 | 67 on each of the 4 operand vectors which have been built up. |
68 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
69 If the stmt had a previous operand cache, the finalization routines |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
70 attempt to match up the new operands with the old ones. If it's a perfect |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
71 match, the old vector is simply reused. If it isn't a perfect match, then |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
72 a new vector is created and the new operands are placed there. For |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
73 virtual operands, if the previous cache had SSA_NAME version of a |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
74 variable, and that same variable occurs in the same operands cache, then |
0 | 75 the new cache vector will also get the same SSA_NAME. |
76 | |
77 i.e., if a stmt had a VUSE of 'a_5', and 'a' occurs in the new | |
78 operand vector for VUSE, then the new vector will also be modified | |
79 such that it contains 'a_5' rather than 'a'. */ | |
80 | |
81 /* Structure storing statistics on how many call clobbers we have, and | |
82 how many where avoided. */ | |
83 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
84 static struct |
0 | 85 { |
86 /* Number of call-clobbered ops we attempt to add to calls in | |
87 add_call_clobbered_mem_symbols. */ | |
88 unsigned int clobbered_vars; | |
89 | |
90 /* Number of write-clobbers (VDEFs) avoided by using | |
91 not_written information. */ | |
92 unsigned int static_write_clobbers_avoided; | |
93 | |
94 /* Number of reads (VUSEs) avoided by using not_read information. */ | |
95 unsigned int static_read_clobbers_avoided; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
96 |
0 | 97 /* Number of write-clobbers avoided because the variable can't escape to |
98 this call. */ | |
99 unsigned int unescapable_clobbers_avoided; | |
100 | |
101 /* Number of read-only uses we attempt to add to calls in | |
102 add_call_read_mem_symbols. */ | |
103 unsigned int readonly_clobbers; | |
104 | |
105 /* Number of read-only uses we avoid using not_read information. */ | |
106 unsigned int static_readonly_clobbers_avoided; | |
107 } clobber_stats; | |
108 | |
109 | |
110 /* Flags to describe operand properties in helpers. */ | |
111 | |
112 /* By default, operands are loaded. */ | |
113 #define opf_use 0 | |
114 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
115 /* Operand is the target of an assignment expression or a |
0 | 116 call-clobbered variable. */ |
117 #define opf_def (1 << 0) | |
118 | |
119 /* No virtual operands should be created in the expression. This is used | |
120 when traversing ADDR_EXPR nodes which have different semantics than | |
121 other expressions. Inside an ADDR_EXPR node, the only operands that we | |
122 need to consider are indices into arrays. For instance, &a.b[i] should | |
123 generate a USE of 'i' but it should not generate a VUSE for 'a' nor a | |
124 VUSE for 'b'. */ | |
125 #define opf_no_vops (1 << 1) | |
126 | |
127 /* Operand is an implicit reference. This is used to distinguish | |
128 explicit assignments in the form of MODIFY_EXPR from | |
129 clobbering sites like function calls or ASM_EXPRs. */ | |
130 #define opf_implicit (1 << 2) | |
131 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
132 /* Operand is in a place where address-taken does not imply addressable. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
133 #define opf_non_addressable (1 << 3) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
134 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
135 /* Operand is in a place where opf_non_addressable does not apply. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
136 #define opf_not_non_addressable (1 << 4) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
137 |
0 | 138 /* Array for building all the def operands. */ |
139 static VEC(tree,heap) *build_defs; | |
140 | |
141 /* Array for building all the use operands. */ | |
142 static VEC(tree,heap) *build_uses; | |
143 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
144 /* The built VDEF operand. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
145 static tree build_vdef; |
0 | 146 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
147 /* The built VUSE operand. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
148 static tree build_vuse; |
0 | 149 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
150 /* Bitmap obstack for our datastructures that needs to survive across |
0 | 151 compilations of multiple functions. */ |
152 static bitmap_obstack operands_bitmap_obstack; | |
153 | |
154 static void get_expr_operands (gimple, tree *, int); | |
155 | |
156 /* Number of functions with initialized ssa_operands. */ | |
157 static int n_initialized = 0; | |
158 | |
159 /* Return the DECL_UID of the base variable of T. */ | |
160 | |
161 static inline unsigned | |
162 get_name_decl (const_tree t) | |
163 { | |
164 if (TREE_CODE (t) != SSA_NAME) | |
165 return DECL_UID (t); | |
166 else | |
167 return DECL_UID (SSA_NAME_VAR (t)); | |
168 } | |
169 | |
170 | |
171 /* Return true if the SSA operands cache is active. */ | |
172 | |
173 bool | |
174 ssa_operands_active (void) | |
175 { | |
176 /* This function may be invoked from contexts where CFUN is NULL | |
177 (IPA passes), return false for now. FIXME: operands may be | |
178 active in each individual function, maybe this function should | |
179 take CFUN as a parameter. */ | |
180 if (cfun == NULL) | |
181 return false; | |
182 | |
183 return cfun->gimple_df && gimple_ssa_operands (cfun)->ops_active; | |
184 } | |
185 | |
186 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
187 /* Create the VOP variable, an artificial global variable to act as a |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
188 representative of all of the virtual operands FUD chain. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
189 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
190 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
191 create_vop_var (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
192 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
193 tree global_var; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
194 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
195 gcc_assert (cfun->gimple_df->vop == NULL_TREE); |
0 | 196 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
197 global_var = build_decl (BUILTINS_LOCATION, VAR_DECL, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
198 get_identifier (".MEM"), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
199 void_type_node); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
200 DECL_ARTIFICIAL (global_var) = 1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
201 TREE_READONLY (global_var) = 0; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
202 DECL_EXTERNAL (global_var) = 1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
203 TREE_STATIC (global_var) = 1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
204 TREE_USED (global_var) = 1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
205 DECL_CONTEXT (global_var) = NULL_TREE; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
206 TREE_THIS_VOLATILE (global_var) = 0; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
207 TREE_ADDRESSABLE (global_var) = 0; |
0 | 208 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
209 create_var_ann (global_var); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
210 add_referenced_var (global_var); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
211 cfun->gimple_df->vop = global_var; |
0 | 212 } |
213 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
214 /* These are the sizes of the operand memory buffer in bytes which gets |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
215 allocated each time more operands space is required. The final value is |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
216 the amount that is allocated every time after that. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
217 In 1k we can fit 25 use operands (or 63 def operands) on a host with |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
218 8 byte pointers, that would be 10 statements each with 1 def and 2 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
219 uses. */ |
0 | 220 |
221 #define OP_SIZE_INIT 0 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
222 #define OP_SIZE_1 (1024 - sizeof (void *)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
223 #define OP_SIZE_2 (1024 * 4 - sizeof (void *)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
224 #define OP_SIZE_3 (1024 * 16 - sizeof (void *)) |
0 | 225 |
226 /* Initialize the operand cache routines. */ | |
227 | |
228 void | |
229 init_ssa_operands (void) | |
230 { | |
231 if (!n_initialized++) | |
232 { | |
233 build_defs = VEC_alloc (tree, heap, 5); | |
234 build_uses = VEC_alloc (tree, heap, 10); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
235 build_vuse = NULL_TREE; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
236 build_vdef = NULL_TREE; |
0 | 237 bitmap_obstack_initialize (&operands_bitmap_obstack); |
238 } | |
239 | |
240 gcc_assert (gimple_ssa_operands (cfun)->operand_memory == NULL); | |
241 gimple_ssa_operands (cfun)->operand_memory_index | |
242 = gimple_ssa_operands (cfun)->ssa_operand_mem_size; | |
243 gimple_ssa_operands (cfun)->ops_active = true; | |
244 memset (&clobber_stats, 0, sizeof (clobber_stats)); | |
245 gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_INIT; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
246 create_vop_var (); |
0 | 247 } |
248 | |
249 | |
250 /* Dispose of anything required by the operand routines. */ | |
251 | |
252 void | |
253 fini_ssa_operands (void) | |
254 { | |
255 struct ssa_operand_memory_d *ptr; | |
256 | |
257 if (!--n_initialized) | |
258 { | |
259 VEC_free (tree, heap, build_defs); | |
260 VEC_free (tree, heap, build_uses); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
261 build_vdef = NULL_TREE; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
262 build_vuse = NULL_TREE; |
0 | 263 } |
264 | |
265 gimple_ssa_operands (cfun)->free_defs = NULL; | |
266 gimple_ssa_operands (cfun)->free_uses = NULL; | |
267 | |
268 while ((ptr = gimple_ssa_operands (cfun)->operand_memory) != NULL) | |
269 { | |
270 gimple_ssa_operands (cfun)->operand_memory | |
271 = gimple_ssa_operands (cfun)->operand_memory->next; | |
272 ggc_free (ptr); | |
273 } | |
274 | |
275 gimple_ssa_operands (cfun)->ops_active = false; | |
276 | |
277 if (!n_initialized) | |
278 bitmap_obstack_release (&operands_bitmap_obstack); | |
279 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
280 cfun->gimple_df->vop = NULL_TREE; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
281 |
0 | 282 if (dump_file && (dump_flags & TDF_STATS)) |
283 { | |
284 fprintf (dump_file, "Original clobbered vars: %d\n", | |
285 clobber_stats.clobbered_vars); | |
286 fprintf (dump_file, "Static write clobbers avoided: %d\n", | |
287 clobber_stats.static_write_clobbers_avoided); | |
288 fprintf (dump_file, "Static read clobbers avoided: %d\n", | |
289 clobber_stats.static_read_clobbers_avoided); | |
290 fprintf (dump_file, "Unescapable clobbers avoided: %d\n", | |
291 clobber_stats.unescapable_clobbers_avoided); | |
292 fprintf (dump_file, "Original read-only clobbers: %d\n", | |
293 clobber_stats.readonly_clobbers); | |
294 fprintf (dump_file, "Static read-only clobbers avoided: %d\n", | |
295 clobber_stats.static_readonly_clobbers_avoided); | |
296 } | |
297 } | |
298 | |
299 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
300 /* Return memory for an operand of size SIZE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
301 |
0 | 302 static inline void * |
303 ssa_operand_alloc (unsigned size) | |
304 { | |
305 char *ptr; | |
306 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
307 gcc_assert (size == sizeof (struct use_optype_d) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
308 || size == sizeof (struct def_optype_d)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
309 |
0 | 310 if (gimple_ssa_operands (cfun)->operand_memory_index + size |
311 >= gimple_ssa_operands (cfun)->ssa_operand_mem_size) | |
312 { | |
313 struct ssa_operand_memory_d *ptr; | |
314 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
315 switch (gimple_ssa_operands (cfun)->ssa_operand_mem_size) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
316 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
317 case OP_SIZE_INIT: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
318 gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
319 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
320 case OP_SIZE_1: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
321 gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_2; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
322 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
323 case OP_SIZE_2: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
324 case OP_SIZE_3: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
325 gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_3; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
326 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
327 default: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
328 gcc_unreachable (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
329 } |
0 | 330 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
331 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
332 ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
333 + gimple_ssa_operands (cfun)->ssa_operand_mem_size); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
334 |
0 | 335 ptr->next = gimple_ssa_operands (cfun)->operand_memory; |
336 gimple_ssa_operands (cfun)->operand_memory = ptr; | |
337 gimple_ssa_operands (cfun)->operand_memory_index = 0; | |
338 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
339 |
0 | 340 ptr = &(gimple_ssa_operands (cfun)->operand_memory |
341 ->mem[gimple_ssa_operands (cfun)->operand_memory_index]); | |
342 gimple_ssa_operands (cfun)->operand_memory_index += size; | |
343 return ptr; | |
344 } | |
345 | |
346 | |
347 /* Allocate a DEF operand. */ | |
348 | |
349 static inline struct def_optype_d * | |
350 alloc_def (void) | |
351 { | |
352 struct def_optype_d *ret; | |
353 if (gimple_ssa_operands (cfun)->free_defs) | |
354 { | |
355 ret = gimple_ssa_operands (cfun)->free_defs; | |
356 gimple_ssa_operands (cfun)->free_defs | |
357 = gimple_ssa_operands (cfun)->free_defs->next; | |
358 } | |
359 else | |
360 ret = (struct def_optype_d *) | |
361 ssa_operand_alloc (sizeof (struct def_optype_d)); | |
362 return ret; | |
363 } | |
364 | |
365 | |
366 /* Allocate a USE operand. */ | |
367 | |
368 static inline struct use_optype_d * | |
369 alloc_use (void) | |
370 { | |
371 struct use_optype_d *ret; | |
372 if (gimple_ssa_operands (cfun)->free_uses) | |
373 { | |
374 ret = gimple_ssa_operands (cfun)->free_uses; | |
375 gimple_ssa_operands (cfun)->free_uses | |
376 = gimple_ssa_operands (cfun)->free_uses->next; | |
377 } | |
378 else | |
379 ret = (struct use_optype_d *) | |
380 ssa_operand_alloc (sizeof (struct use_optype_d)); | |
381 return ret; | |
382 } | |
383 | |
384 | |
385 /* Adds OP to the list of defs after LAST. */ | |
386 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
387 static inline def_optype_p |
0 | 388 add_def_op (tree *op, def_optype_p last) |
389 { | |
390 def_optype_p new_def; | |
391 | |
392 new_def = alloc_def (); | |
393 DEF_OP_PTR (new_def) = op; | |
394 last->next = new_def; | |
395 new_def->next = NULL; | |
396 return new_def; | |
397 } | |
398 | |
399 | |
400 /* Adds OP to the list of uses of statement STMT after LAST. */ | |
401 | |
402 static inline use_optype_p | |
403 add_use_op (gimple stmt, tree *op, use_optype_p last) | |
404 { | |
405 use_optype_p new_use; | |
406 | |
407 new_use = alloc_use (); | |
408 USE_OP_PTR (new_use)->use = op; | |
409 link_imm_use_stmt (USE_OP_PTR (new_use), *op, stmt); | |
410 last->next = new_use; | |
411 new_use->next = NULL; | |
412 return new_use; | |
413 } | |
414 | |
415 | |
416 | |
417 /* Takes elements from build_defs and turns them into def operands of STMT. | |
418 TODO -- Make build_defs VEC of tree *. */ | |
419 | |
420 static inline void | |
421 finalize_ssa_defs (gimple stmt) | |
422 { | |
423 unsigned new_i; | |
424 struct def_optype_d new_list; | |
425 def_optype_p old_ops, last; | |
426 unsigned int num = VEC_length (tree, build_defs); | |
427 | |
428 /* There should only be a single real definition per assignment. */ | |
429 gcc_assert ((stmt && gimple_code (stmt) != GIMPLE_ASSIGN) || num <= 1); | |
430 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
431 /* Pre-pend the vdef we may have built. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
432 if (build_vdef != NULL_TREE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
433 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
434 tree oldvdef = gimple_vdef (stmt); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
435 if (oldvdef |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
436 && TREE_CODE (oldvdef) == SSA_NAME) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
437 oldvdef = SSA_NAME_VAR (oldvdef); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
438 if (oldvdef != build_vdef) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
439 gimple_set_vdef (stmt, build_vdef); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
440 VEC_safe_insert (tree, heap, build_defs, 0, (tree)gimple_vdef_ptr (stmt)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
441 ++num; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
442 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
443 |
0 | 444 new_list.next = NULL; |
445 last = &new_list; | |
446 | |
447 old_ops = gimple_def_ops (stmt); | |
448 | |
449 new_i = 0; | |
450 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
451 /* Clear and unlink a no longer necessary VDEF. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
452 if (build_vdef == NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
453 && gimple_vdef (stmt) != NULL_TREE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
454 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
455 if (TREE_CODE (gimple_vdef (stmt)) == SSA_NAME) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
456 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
457 unlink_stmt_vdef (stmt); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
458 release_ssa_name (gimple_vdef (stmt)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
459 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
460 gimple_set_vdef (stmt, NULL_TREE); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
461 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
462 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
463 /* If we have a non-SSA_NAME VDEF, mark it for renaming. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
464 if (gimple_vdef (stmt) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
465 && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
466 mark_sym_for_renaming (gimple_vdef (stmt)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
467 |
0 | 468 /* Check for the common case of 1 def that hasn't changed. */ |
469 if (old_ops && old_ops->next == NULL && num == 1 | |
470 && (tree *) VEC_index (tree, build_defs, 0) == DEF_OP_PTR (old_ops)) | |
471 return; | |
472 | |
473 /* If there is anything in the old list, free it. */ | |
474 if (old_ops) | |
475 { | |
476 old_ops->next = gimple_ssa_operands (cfun)->free_defs; | |
477 gimple_ssa_operands (cfun)->free_defs = old_ops; | |
478 } | |
479 | |
480 /* If there is anything remaining in the build_defs list, simply emit it. */ | |
481 for ( ; new_i < num; new_i++) | |
482 last = add_def_op ((tree *) VEC_index (tree, build_defs, new_i), last); | |
483 | |
484 /* Now set the stmt's operands. */ | |
485 gimple_set_def_ops (stmt, new_list.next); | |
486 } | |
487 | |
488 | |
489 /* Takes elements from build_uses and turns them into use operands of STMT. | |
490 TODO -- Make build_uses VEC of tree *. */ | |
491 | |
492 static inline void | |
493 finalize_ssa_uses (gimple stmt) | |
494 { | |
495 unsigned new_i; | |
496 struct use_optype_d new_list; | |
497 use_optype_p old_ops, ptr, last; | |
498 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
499 /* Pre-pend the VUSE we may have built. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
500 if (build_vuse != NULL_TREE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
501 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
502 tree oldvuse = gimple_vuse (stmt); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
503 if (oldvuse |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
504 && TREE_CODE (oldvuse) == SSA_NAME) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
505 oldvuse = SSA_NAME_VAR (oldvuse); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
506 if (oldvuse != (build_vuse != NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
507 ? build_vuse : build_vdef)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
508 gimple_set_vuse (stmt, NULL_TREE); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
509 VEC_safe_insert (tree, heap, build_uses, 0, (tree)gimple_vuse_ptr (stmt)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
510 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
511 |
0 | 512 new_list.next = NULL; |
513 last = &new_list; | |
514 | |
515 old_ops = gimple_use_ops (stmt); | |
516 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
517 /* Clear a no longer necessary VUSE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
518 if (build_vuse == NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
519 && gimple_vuse (stmt) != NULL_TREE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
520 gimple_set_vuse (stmt, NULL_TREE); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
521 |
0 | 522 /* If there is anything in the old list, free it. */ |
523 if (old_ops) | |
524 { | |
525 for (ptr = old_ops; ptr; ptr = ptr->next) | |
526 delink_imm_use (USE_OP_PTR (ptr)); | |
527 old_ops->next = gimple_ssa_operands (cfun)->free_uses; | |
528 gimple_ssa_operands (cfun)->free_uses = old_ops; | |
529 } | |
530 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
531 /* If we added a VUSE, make sure to set the operand if it is not already |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
532 present and mark it for renaming. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
533 if (build_vuse != NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
534 && gimple_vuse (stmt) == NULL_TREE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
535 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
536 gimple_set_vuse (stmt, gimple_vop (cfun)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
537 mark_sym_for_renaming (gimple_vop (cfun)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
538 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
539 |
0 | 540 /* Now create nodes for all the new nodes. */ |
541 for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
542 last = add_use_op (stmt, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
543 (tree *) VEC_index (tree, build_uses, new_i), |
0 | 544 last); |
545 | |
546 /* Now set the stmt's operands. */ | |
547 gimple_set_use_ops (stmt, new_list.next); | |
548 } | |
549 | |
550 | |
551 /* Clear the in_list bits and empty the build array for VDEFs and | |
552 VUSEs. */ | |
553 | |
554 static inline void | |
555 cleanup_build_arrays (void) | |
556 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
557 build_vdef = NULL_TREE; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
558 build_vuse = NULL_TREE; |
0 | 559 VEC_truncate (tree, build_defs, 0); |
560 VEC_truncate (tree, build_uses, 0); | |
561 } | |
562 | |
563 | |
564 /* Finalize all the build vectors, fill the new ones into INFO. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
565 |
0 | 566 static inline void |
567 finalize_ssa_stmt_operands (gimple stmt) | |
568 { | |
569 finalize_ssa_defs (stmt); | |
570 finalize_ssa_uses (stmt); | |
571 cleanup_build_arrays (); | |
572 } | |
573 | |
574 | |
575 /* Start the process of building up operands vectors in INFO. */ | |
576 | |
577 static inline void | |
578 start_ssa_stmt_operands (void) | |
579 { | |
580 gcc_assert (VEC_length (tree, build_defs) == 0); | |
581 gcc_assert (VEC_length (tree, build_uses) == 0); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
582 gcc_assert (build_vuse == NULL_TREE); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
583 gcc_assert (build_vdef == NULL_TREE); |
0 | 584 } |
585 | |
586 | |
587 /* Add DEF_P to the list of pointers to operands. */ | |
588 | |
589 static inline void | |
590 append_def (tree *def_p) | |
591 { | |
592 VEC_safe_push (tree, heap, build_defs, (tree) def_p); | |
593 } | |
594 | |
595 | |
596 /* Add USE_P to the list of pointers to operands. */ | |
597 | |
598 static inline void | |
599 append_use (tree *use_p) | |
600 { | |
601 VEC_safe_push (tree, heap, build_uses, (tree) use_p); | |
602 } | |
603 | |
604 | |
605 /* Add VAR to the set of variables that require a VDEF operator. */ | |
606 | |
607 static inline void | |
608 append_vdef (tree var) | |
609 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
610 if (!optimize) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
611 return; |
0 | 612 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
613 gcc_assert ((build_vdef == NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
614 || build_vdef == var) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
615 && (build_vuse == NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
616 || build_vuse == var)); |
0 | 617 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
618 build_vdef = var; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
619 build_vuse = var; |
0 | 620 } |
621 | |
622 | |
623 /* Add VAR to the set of variables that require a VUSE operator. */ | |
624 | |
625 static inline void | |
626 append_vuse (tree var) | |
627 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
628 if (!optimize) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
629 return; |
0 | 630 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
631 gcc_assert (build_vuse == NULL_TREE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
632 || build_vuse == var); |
0 | 633 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
634 build_vuse = var; |
0 | 635 } |
636 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
637 /* Add virtual operands for STMT. FLAGS is as in get_expr_operands. */ |
0 | 638 |
639 static void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
640 add_virtual_operand (gimple stmt ATTRIBUTE_UNUSED, int flags) |
0 | 641 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
642 /* Add virtual operands to the stmt, unless the caller has specifically |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
643 requested not to do that (used when adding operands inside an |
0 | 644 ADDR_EXPR expression). */ |
645 if (flags & opf_no_vops) | |
646 return; | |
647 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
648 gcc_assert (!is_gimple_debug (stmt)); |
0 | 649 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
650 if (flags & opf_def) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
651 append_vdef (gimple_vop (cfun)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
652 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
653 append_vuse (gimple_vop (cfun)); |
0 | 654 } |
655 | |
656 | |
657 /* Add *VAR_P to the appropriate operand array for statement STMT. | |
658 FLAGS is as in get_expr_operands. If *VAR_P is a GIMPLE register, | |
659 it will be added to the statement's real operands, otherwise it is | |
660 added to virtual operands. */ | |
661 | |
662 static void | |
663 add_stmt_operand (tree *var_p, gimple stmt, int flags) | |
664 { | |
665 tree var, sym; | |
666 | |
667 gcc_assert (SSA_VAR_P (*var_p)); | |
668 | |
669 var = *var_p; | |
670 sym = (TREE_CODE (var) == SSA_NAME ? SSA_NAME_VAR (var) : var); | |
671 | |
672 /* Mark statements with volatile operands. */ | |
673 if (TREE_THIS_VOLATILE (sym)) | |
674 gimple_set_has_volatile_ops (stmt, true); | |
675 | |
676 if (is_gimple_reg (sym)) | |
677 { | |
678 /* The variable is a GIMPLE register. Add it to real operands. */ | |
679 if (flags & opf_def) | |
680 append_def (var_p); | |
681 else | |
682 append_use (var_p); | |
683 } | |
684 else | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
685 add_virtual_operand (stmt, flags); |
0 | 686 } |
687 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
688 /* Mark the base address of REF as having its address taken. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
689 REF may be a single variable whose address has been taken or any |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
690 other valid GIMPLE memory reference (structure reference, array, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
691 etc). */ |
0 | 692 |
693 static void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
694 mark_address_taken (tree ref) |
0 | 695 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
696 tree var; |
0 | 697 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
698 /* Note that it is *NOT OKAY* to use the target of a COMPONENT_REF |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
699 as the only thing we take the address of. If VAR is a structure, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
700 taking the address of a field means that the whole structure may |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
701 be referenced using pointer arithmetic. See PR 21407 and the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
702 ensuing mailing list discussion. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
703 var = get_base_address (ref); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
704 if (var) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
705 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
706 if (DECL_P (var)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
707 TREE_ADDRESSABLE (var) = 1; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
708 else if (TREE_CODE (var) == MEM_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
709 && TREE_CODE (TREE_OPERAND (var, 0)) == ADDR_EXPR |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
710 && DECL_P (TREE_OPERAND (TREE_OPERAND (var, 0), 0))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
711 TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (var, 0), 0)) = 1; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
712 } |
0 | 713 } |
714 | |
715 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
716 /* A subroutine of get_expr_operands to handle MEM_REF. |
0 | 717 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
718 STMT is the statement being processed, EXPR is the MEM_REF |
0 | 719 that got us here. |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
720 |
0 | 721 FLAGS is as in get_expr_operands. |
722 | |
723 RECURSE_ON_BASE should be set to true if we want to continue | |
724 calling get_expr_operands on the base pointer, and false if | |
725 something else will do it for us. */ | |
726 | |
727 static void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
728 get_indirect_ref_operands (gimple stmt, tree expr, int flags, |
0 | 729 bool recurse_on_base) |
730 { | |
731 tree *pptr = &TREE_OPERAND (expr, 0); | |
732 | |
733 if (TREE_THIS_VOLATILE (expr)) | |
734 gimple_set_has_volatile_ops (stmt, true); | |
735 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
736 /* Add the VOP. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
737 add_virtual_operand (stmt, flags); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
738 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
739 /* If requested, add a USE operand for the base pointer. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
740 if (recurse_on_base) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
741 get_expr_operands (stmt, pptr, |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
742 opf_non_addressable | opf_use |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
743 | (flags & (opf_no_vops|opf_not_non_addressable))); |
0 | 744 } |
745 | |
746 | |
747 /* A subroutine of get_expr_operands to handle TARGET_MEM_REF. */ | |
748 | |
749 static void | |
750 get_tmr_operands (gimple stmt, tree expr, int flags) | |
751 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
752 if (TREE_THIS_VOLATILE (expr)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
753 gimple_set_has_volatile_ops (stmt, true); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
754 |
0 | 755 /* First record the real operands. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
756 get_expr_operands (stmt, &TMR_BASE (expr), opf_use | (flags & opf_no_vops)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
757 get_expr_operands (stmt, &TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
758 get_expr_operands (stmt, &TMR_INDEX2 (expr), opf_use | (flags & opf_no_vops)); |
0 | 759 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
760 add_virtual_operand (stmt, flags); |
0 | 761 } |
762 | |
763 | |
764 /* If STMT is a call that may clobber globals and other symbols that | |
765 escape, add them to the VDEF/VUSE lists for it. */ | |
766 | |
767 static void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
768 maybe_add_call_vops (gimple stmt) |
0 | 769 { |
770 int call_flags = gimple_call_flags (stmt); | |
771 | |
772 /* If aliases have been computed already, add VDEF or VUSE | |
773 operands for all the symbols that have been found to be | |
774 call-clobbered. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
775 if (!(call_flags & ECF_NOVOPS)) |
0 | 776 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
777 /* A 'pure' or a 'const' function never call-clobbers anything. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
778 A 'noreturn' function might, but since we don't return anyway |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
779 there is no point in recording that. */ |
0 | 780 if (!(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN))) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
781 add_virtual_operand (stmt, opf_def); |
0 | 782 else if (!(call_flags & ECF_CONST)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
783 add_virtual_operand (stmt, opf_use); |
0 | 784 } |
785 } | |
786 | |
787 | |
788 /* Scan operands in the ASM_EXPR stmt referred to in INFO. */ | |
789 | |
790 static void | |
791 get_asm_expr_operands (gimple stmt) | |
792 { | |
793 size_t i, noutputs; | |
794 const char **oconstraints; | |
795 const char *constraint; | |
796 bool allows_mem, allows_reg, is_inout; | |
797 | |
798 noutputs = gimple_asm_noutputs (stmt); | |
799 oconstraints = (const char **) alloca ((noutputs) * sizeof (const char *)); | |
800 | |
801 /* Gather all output operands. */ | |
802 for (i = 0; i < gimple_asm_noutputs (stmt); i++) | |
803 { | |
804 tree link = gimple_asm_output_op (stmt, i); | |
805 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); | |
806 oconstraints[i] = constraint; | |
807 parse_output_constraint (&constraint, i, 0, 0, &allows_mem, | |
808 &allows_reg, &is_inout); | |
809 | |
810 /* This should have been split in gimplify_asm_expr. */ | |
811 gcc_assert (!allows_reg || !is_inout); | |
812 | |
813 /* Memory operands are addressable. Note that STMT needs the | |
814 address of this operand. */ | |
815 if (!allows_reg && allows_mem) | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
816 mark_address_taken (TREE_VALUE (link)); |
0 | 817 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
818 get_expr_operands (stmt, &TREE_VALUE (link), opf_def | opf_not_non_addressable); |
0 | 819 } |
820 | |
821 /* Gather all input operands. */ | |
822 for (i = 0; i < gimple_asm_ninputs (stmt); i++) | |
823 { | |
824 tree link = gimple_asm_input_op (stmt, i); | |
825 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); | |
826 parse_input_constraint (&constraint, 0, 0, noutputs, 0, oconstraints, | |
827 &allows_mem, &allows_reg); | |
828 | |
829 /* Memory operands are addressable. Note that STMT needs the | |
830 address of this operand. */ | |
831 if (!allows_reg && allows_mem) | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
832 mark_address_taken (TREE_VALUE (link)); |
0 | 833 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
834 get_expr_operands (stmt, &TREE_VALUE (link), opf_not_non_addressable); |
0 | 835 } |
836 | |
837 /* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */ | |
838 for (i = 0; i < gimple_asm_nclobbers (stmt); i++) | |
839 { | |
840 tree link = gimple_asm_clobber_op (stmt, i); | |
841 if (strcmp (TREE_STRING_POINTER (TREE_VALUE (link)), "memory") == 0) | |
842 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
843 add_virtual_operand (stmt, opf_def); |
0 | 844 break; |
845 } | |
846 } | |
847 } | |
848 | |
849 | |
850 /* Recursively scan the expression pointed to by EXPR_P in statement | |
851 STMT. FLAGS is one of the OPF_* constants modifying how to | |
852 interpret the operands found. */ | |
853 | |
854 static void | |
855 get_expr_operands (gimple stmt, tree *expr_p, int flags) | |
856 { | |
857 enum tree_code code; | |
858 enum tree_code_class codeclass; | |
859 tree expr = *expr_p; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
860 int uflags = opf_use; |
0 | 861 |
862 if (expr == NULL) | |
863 return; | |
864 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
865 if (is_gimple_debug (stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
866 uflags |= (flags & opf_no_vops); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
867 |
0 | 868 code = TREE_CODE (expr); |
869 codeclass = TREE_CODE_CLASS (code); | |
870 | |
871 switch (code) | |
872 { | |
873 case ADDR_EXPR: | |
874 /* Taking the address of a variable does not represent a | |
875 reference to it, but the fact that the statement takes its | |
876 address will be of interest to some passes (e.g. alias | |
877 resolution). */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
878 if ((!(flags & opf_non_addressable) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
879 || (flags & opf_not_non_addressable)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
880 && !is_gimple_debug (stmt)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
881 mark_address_taken (TREE_OPERAND (expr, 0)); |
0 | 882 |
883 /* If the address is invariant, there may be no interesting | |
884 variable references inside. */ | |
885 if (is_gimple_min_invariant (expr)) | |
886 return; | |
887 | |
888 /* Otherwise, there may be variables referenced inside but there | |
889 should be no VUSEs created, since the referenced objects are | |
890 not really accessed. The only operands that we should find | |
891 here are ARRAY_REF indices which will always be real operands | |
892 (GIMPLE does not allow non-registers as array indices). */ | |
893 flags |= opf_no_vops; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
894 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
895 flags | opf_not_non_addressable); |
0 | 896 return; |
897 | |
898 case SSA_NAME: | |
899 add_stmt_operand (expr_p, stmt, flags); | |
900 return; | |
901 | |
902 case VAR_DECL: | |
903 case PARM_DECL: | |
904 case RESULT_DECL: | |
905 add_stmt_operand (expr_p, stmt, flags); | |
906 return; | |
907 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
908 case DEBUG_EXPR_DECL: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
909 gcc_assert (gimple_debug_bind_p (stmt)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
910 return; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
911 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
912 case MEM_REF: |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
913 get_indirect_ref_operands (stmt, expr, flags, true); |
0 | 914 return; |
915 | |
916 case TARGET_MEM_REF: | |
917 get_tmr_operands (stmt, expr, flags); | |
918 return; | |
919 | |
920 case ARRAY_REF: | |
921 case ARRAY_RANGE_REF: | |
922 case COMPONENT_REF: | |
923 case REALPART_EXPR: | |
924 case IMAGPART_EXPR: | |
925 { | |
926 if (TREE_THIS_VOLATILE (expr)) | |
927 gimple_set_has_volatile_ops (stmt, true); | |
928 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
929 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); |
0 | 930 |
931 if (code == COMPONENT_REF) | |
932 { | |
933 if (TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1))) | |
934 gimple_set_has_volatile_ops (stmt, true); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
935 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); |
0 | 936 } |
937 else if (code == ARRAY_REF || code == ARRAY_RANGE_REF) | |
938 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
939 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
940 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
941 get_expr_operands (stmt, &TREE_OPERAND (expr, 3), uflags); |
0 | 942 } |
943 | |
944 return; | |
945 } | |
946 | |
947 case WITH_SIZE_EXPR: | |
948 /* WITH_SIZE_EXPR is a pass-through reference to its first argument, | |
949 and an rvalue reference to its second argument. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
950 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); |
0 | 951 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); |
952 return; | |
953 | |
954 case COND_EXPR: | |
955 case VEC_COND_EXPR: | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
956 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), uflags); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
957 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
958 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); |
0 | 959 return; |
960 | |
961 case CONSTRUCTOR: | |
962 { | |
963 /* General aggregate CONSTRUCTORs have been decomposed, but they | |
964 are still in use as the COMPLEX_EXPR equivalent for vectors. */ | |
965 constructor_elt *ce; | |
966 unsigned HOST_WIDE_INT idx; | |
967 | |
968 for (idx = 0; | |
969 VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (expr), idx, ce); | |
970 idx++) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
971 get_expr_operands (stmt, &ce->value, uflags); |
0 | 972 |
973 return; | |
974 } | |
975 | |
976 case BIT_FIELD_REF: | |
977 if (TREE_THIS_VOLATILE (expr)) | |
978 gimple_set_has_volatile_ops (stmt, true); | |
979 /* FALLTHRU */ | |
980 | |
981 case TRUTH_NOT_EXPR: | |
982 case VIEW_CONVERT_EXPR: | |
983 do_unary: | |
984 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); | |
985 return; | |
986 | |
987 case TRUTH_AND_EXPR: | |
988 case TRUTH_OR_EXPR: | |
989 case TRUTH_XOR_EXPR: | |
990 case COMPOUND_EXPR: | |
991 case OBJ_TYPE_REF: | |
992 case ASSERT_EXPR: | |
993 do_binary: | |
994 { | |
995 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); | |
996 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); | |
997 return; | |
998 } | |
999 | |
1000 case DOT_PROD_EXPR: | |
1001 case REALIGN_LOAD_EXPR: | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1002 case WIDEN_MULT_PLUS_EXPR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1003 case WIDEN_MULT_MINUS_EXPR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1004 case FMA_EXPR: |
0 | 1005 { |
1006 get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1007 get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1008 get_expr_operands (stmt, &TREE_OPERAND (expr, 2), flags); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1009 return; |
0 | 1010 } |
1011 | |
1012 case FUNCTION_DECL: | |
1013 case LABEL_DECL: | |
1014 case CONST_DECL: | |
1015 case CASE_LABEL_EXPR: | |
1016 /* Expressions that make no memory references. */ | |
1017 return; | |
1018 | |
1019 default: | |
1020 if (codeclass == tcc_unary) | |
1021 goto do_unary; | |
1022 if (codeclass == tcc_binary || codeclass == tcc_comparison) | |
1023 goto do_binary; | |
1024 if (codeclass == tcc_constant || codeclass == tcc_type) | |
1025 return; | |
1026 } | |
1027 | |
1028 /* If we get here, something has gone wrong. */ | |
1029 #ifdef ENABLE_CHECKING | |
1030 fprintf (stderr, "unhandled expression in get_expr_operands():\n"); | |
1031 debug_tree (expr); | |
1032 fputs ("\n", stderr); | |
1033 #endif | |
1034 gcc_unreachable (); | |
1035 } | |
1036 | |
1037 | |
1038 /* Parse STMT looking for operands. When finished, the various | |
1039 build_* operand vectors will have potential operands in them. */ | |
1040 | |
1041 static void | |
1042 parse_ssa_operands (gimple stmt) | |
1043 { | |
1044 enum gimple_code code = gimple_code (stmt); | |
1045 | |
1046 if (code == GIMPLE_ASM) | |
1047 get_asm_expr_operands (stmt); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1048 else if (is_gimple_debug (stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1049 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1050 if (gimple_debug_bind_p (stmt) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1051 && gimple_debug_bind_has_value_p (stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1052 get_expr_operands (stmt, gimple_debug_bind_get_value_ptr (stmt), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1053 opf_use | opf_no_vops); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1054 } |
0 | 1055 else |
1056 { | |
1057 size_t i, start = 0; | |
1058 | |
1059 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL) | |
1060 { | |
1061 get_expr_operands (stmt, gimple_op_ptr (stmt, 0), opf_def); | |
1062 start = 1; | |
1063 } | |
1064 | |
1065 for (i = start; i < gimple_num_ops (stmt); i++) | |
1066 get_expr_operands (stmt, gimple_op_ptr (stmt, i), opf_use); | |
1067 | |
1068 /* Add call-clobbered operands, if needed. */ | |
1069 if (code == GIMPLE_CALL) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1070 maybe_add_call_vops (stmt); |
0 | 1071 } |
1072 } | |
1073 | |
1074 | |
1075 /* Create an operands cache for STMT. */ | |
1076 | |
1077 static void | |
1078 build_ssa_operands (gimple stmt) | |
1079 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1080 /* Initially assume that the statement has no volatile operands. */ |
0 | 1081 gimple_set_has_volatile_ops (stmt, false); |
1082 | |
1083 start_ssa_stmt_operands (); | |
1084 parse_ssa_operands (stmt); | |
1085 finalize_ssa_stmt_operands (stmt); | |
1086 } | |
1087 | |
1088 | |
1089 /* Releases the operands of STMT back to their freelists, and clears | |
1090 the stmt operand lists. */ | |
1091 | |
1092 void | |
1093 free_stmt_operands (gimple stmt) | |
1094 { | |
1095 def_optype_p defs = gimple_def_ops (stmt), last_def; | |
1096 use_optype_p uses = gimple_use_ops (stmt), last_use; | |
1097 | |
1098 if (defs) | |
1099 { | |
1100 for (last_def = defs; last_def->next; last_def = last_def->next) | |
1101 continue; | |
1102 last_def->next = gimple_ssa_operands (cfun)->free_defs; | |
1103 gimple_ssa_operands (cfun)->free_defs = defs; | |
1104 gimple_set_def_ops (stmt, NULL); | |
1105 } | |
1106 | |
1107 if (uses) | |
1108 { | |
1109 for (last_use = uses; last_use->next; last_use = last_use->next) | |
1110 delink_imm_use (USE_OP_PTR (last_use)); | |
1111 delink_imm_use (USE_OP_PTR (last_use)); | |
1112 last_use->next = gimple_ssa_operands (cfun)->free_uses; | |
1113 gimple_ssa_operands (cfun)->free_uses = uses; | |
1114 gimple_set_use_ops (stmt, NULL); | |
1115 } | |
1116 | |
1117 if (gimple_has_mem_ops (stmt)) | |
1118 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1119 gimple_set_vuse (stmt, NULL_TREE); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1120 gimple_set_vdef (stmt, NULL_TREE); |
0 | 1121 } |
1122 } | |
1123 | |
1124 | |
1125 /* Get the operands of statement STMT. */ | |
1126 | |
1127 void | |
1128 update_stmt_operands (gimple stmt) | |
1129 { | |
1130 /* If update_stmt_operands is called before SSA is initialized, do | |
1131 nothing. */ | |
1132 if (!ssa_operands_active ()) | |
1133 return; | |
1134 | |
1135 timevar_push (TV_TREE_OPS); | |
1136 | |
1137 gcc_assert (gimple_modified_p (stmt)); | |
1138 build_ssa_operands (stmt); | |
1139 gimple_set_modified (stmt, false); | |
1140 | |
1141 timevar_pop (TV_TREE_OPS); | |
1142 } | |
1143 | |
1144 | |
1145 /* Swap operands EXP0 and EXP1 in statement STMT. No attempt is done | |
1146 to test the validity of the swap operation. */ | |
1147 | |
1148 void | |
1149 swap_tree_operands (gimple stmt, tree *exp0, tree *exp1) | |
1150 { | |
1151 tree op0, op1; | |
1152 op0 = *exp0; | |
1153 op1 = *exp1; | |
1154 | |
1155 /* If the operand cache is active, attempt to preserve the relative | |
1156 positions of these two operands in their respective immediate use | |
1157 lists. */ | |
1158 if (ssa_operands_active () && op0 != op1) | |
1159 { | |
1160 use_optype_p use0, use1, ptr; | |
1161 use0 = use1 = NULL; | |
1162 | |
1163 /* Find the 2 operands in the cache, if they are there. */ | |
1164 for (ptr = gimple_use_ops (stmt); ptr; ptr = ptr->next) | |
1165 if (USE_OP_PTR (ptr)->use == exp0) | |
1166 { | |
1167 use0 = ptr; | |
1168 break; | |
1169 } | |
1170 | |
1171 for (ptr = gimple_use_ops (stmt); ptr; ptr = ptr->next) | |
1172 if (USE_OP_PTR (ptr)->use == exp1) | |
1173 { | |
1174 use1 = ptr; | |
1175 break; | |
1176 } | |
1177 | |
1178 /* If both uses don't have operand entries, there isn't much we can do | |
1179 at this point. Presumably we don't need to worry about it. */ | |
1180 if (use0 && use1) | |
1181 { | |
1182 tree *tmp = USE_OP_PTR (use1)->use; | |
1183 USE_OP_PTR (use1)->use = USE_OP_PTR (use0)->use; | |
1184 USE_OP_PTR (use0)->use = tmp; | |
1185 } | |
1186 } | |
1187 | |
1188 /* Now swap the data. */ | |
1189 *exp0 = op1; | |
1190 *exp1 = op0; | |
1191 } | |
1192 | |
1193 | |
1194 /* Scan the immediate_use list for VAR making sure its linked properly. | |
1195 Return TRUE if there is a problem and emit an error message to F. */ | |
1196 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1197 DEBUG_FUNCTION bool |
0 | 1198 verify_imm_links (FILE *f, tree var) |
1199 { | |
1200 use_operand_p ptr, prev, list; | |
1201 int count; | |
1202 | |
1203 gcc_assert (TREE_CODE (var) == SSA_NAME); | |
1204 | |
1205 list = &(SSA_NAME_IMM_USE_NODE (var)); | |
1206 gcc_assert (list->use == NULL); | |
1207 | |
1208 if (list->prev == NULL) | |
1209 { | |
1210 gcc_assert (list->next == NULL); | |
1211 return false; | |
1212 } | |
1213 | |
1214 prev = list; | |
1215 count = 0; | |
1216 for (ptr = list->next; ptr != list; ) | |
1217 { | |
1218 if (prev != ptr->prev) | |
1219 goto error; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1220 |
0 | 1221 if (ptr->use == NULL) |
1222 goto error; /* 2 roots, or SAFE guard node. */ | |
1223 else if (*(ptr->use) != var) | |
1224 goto error; | |
1225 | |
1226 prev = ptr; | |
1227 ptr = ptr->next; | |
1228 | |
1229 /* Avoid infinite loops. 50,000,000 uses probably indicates a | |
1230 problem. */ | |
1231 if (count++ > 50000000) | |
1232 goto error; | |
1233 } | |
1234 | |
1235 /* Verify list in the other direction. */ | |
1236 prev = list; | |
1237 for (ptr = list->prev; ptr != list; ) | |
1238 { | |
1239 if (prev != ptr->next) | |
1240 goto error; | |
1241 prev = ptr; | |
1242 ptr = ptr->prev; | |
1243 if (count-- < 0) | |
1244 goto error; | |
1245 } | |
1246 | |
1247 if (count != 0) | |
1248 goto error; | |
1249 | |
1250 return false; | |
1251 | |
1252 error: | |
1253 if (ptr->loc.stmt && gimple_modified_p (ptr->loc.stmt)) | |
1254 { | |
1255 fprintf (f, " STMT MODIFIED. - <%p> ", (void *)ptr->loc.stmt); | |
1256 print_gimple_stmt (f, ptr->loc.stmt, 0, TDF_SLIM); | |
1257 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1258 fprintf (f, " IMM ERROR : (use_p : tree - %p:%p)", (void *)ptr, |
0 | 1259 (void *)ptr->use); |
1260 print_generic_expr (f, USE_FROM_PTR (ptr), TDF_SLIM); | |
1261 fprintf(f, "\n"); | |
1262 return true; | |
1263 } | |
1264 | |
1265 | |
1266 /* Dump all the immediate uses to FILE. */ | |
1267 | |
1268 void | |
1269 dump_immediate_uses_for (FILE *file, tree var) | |
1270 { | |
1271 imm_use_iterator iter; | |
1272 use_operand_p use_p; | |
1273 | |
1274 gcc_assert (var && TREE_CODE (var) == SSA_NAME); | |
1275 | |
1276 print_generic_expr (file, var, TDF_SLIM); | |
1277 fprintf (file, " : -->"); | |
1278 if (has_zero_uses (var)) | |
1279 fprintf (file, " no uses.\n"); | |
1280 else | |
1281 if (has_single_use (var)) | |
1282 fprintf (file, " single use.\n"); | |
1283 else | |
1284 fprintf (file, "%d uses.\n", num_imm_uses (var)); | |
1285 | |
1286 FOR_EACH_IMM_USE_FAST (use_p, iter, var) | |
1287 { | |
1288 if (use_p->loc.stmt == NULL && use_p->use == NULL) | |
1289 fprintf (file, "***end of stmt iterator marker***\n"); | |
1290 else | |
1291 if (!is_gimple_reg (USE_FROM_PTR (use_p))) | |
1292 print_gimple_stmt (file, USE_STMT (use_p), 0, TDF_VOPS|TDF_MEMSYMS); | |
1293 else | |
1294 print_gimple_stmt (file, USE_STMT (use_p), 0, TDF_SLIM); | |
1295 } | |
1296 fprintf(file, "\n"); | |
1297 } | |
1298 | |
1299 | |
1300 /* Dump all the immediate uses to FILE. */ | |
1301 | |
1302 void | |
1303 dump_immediate_uses (FILE *file) | |
1304 { | |
1305 tree var; | |
1306 unsigned int x; | |
1307 | |
1308 fprintf (file, "Immediate_uses: \n\n"); | |
1309 for (x = 1; x < num_ssa_names; x++) | |
1310 { | |
1311 var = ssa_name(x); | |
1312 if (!var) | |
1313 continue; | |
1314 dump_immediate_uses_for (file, var); | |
1315 } | |
1316 } | |
1317 | |
1318 | |
1319 /* Dump def-use edges on stderr. */ | |
1320 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1321 DEBUG_FUNCTION void |
0 | 1322 debug_immediate_uses (void) |
1323 { | |
1324 dump_immediate_uses (stderr); | |
1325 } | |
1326 | |
1327 | |
1328 /* Dump def-use edges on stderr. */ | |
1329 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1330 DEBUG_FUNCTION void |
0 | 1331 debug_immediate_uses_for (tree var) |
1332 { | |
1333 dump_immediate_uses_for (stderr, var); | |
1334 } | |
1335 | |
1336 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1337 /* Unlink STMTs virtual definition from the IL by propagating its use. */ |
0 | 1338 |
1339 void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1340 unlink_stmt_vdef (gimple stmt) |
0 | 1341 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1342 use_operand_p use_p; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1343 imm_use_iterator iter; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1344 gimple use_stmt; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1345 tree vdef = gimple_vdef (stmt); |
0 | 1346 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1347 if (!vdef |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1348 || TREE_CODE (vdef) != SSA_NAME) |
0 | 1349 return; |
1350 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1351 FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_vdef (stmt)) |
0 | 1352 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1353 FOR_EACH_IMM_USE_ON_STMT (use_p, iter) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1354 SET_USE (use_p, gimple_vuse (stmt)); |
0 | 1355 } |
1356 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1357 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vdef (stmt))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1358 SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vuse (stmt)) = 1; |
0 | 1359 } |
1360 |