Mercurial > hg > CbC > CbC_gcc
annotate gcc/function.c @ 104:46ee985e4f0e
fix implementation of rectype in c-decl.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 Apr 2012 19:01:21 +0900 (2012-04-09) |
parents | 6fb1a677d0b5 |
children | ab0bcb71f44d |
rev | line source |
---|---|
0 | 1 /* Expands front end tree to back end RTL for GCC. |
2 Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
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
|
4 2010, 2011 Free Software Foundation, Inc. |
0 | 5 |
6 This file is part of GCC. | |
7 | |
8 GCC is free software; you can redistribute it and/or modify it under | |
9 the terms of the GNU General Public License as published by the Free | |
10 Software Foundation; either version 3, or (at your option) any later | |
11 version. | |
12 | |
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GCC; see the file COPYING3. If not see | |
20 <http://www.gnu.org/licenses/>. */ | |
21 | |
22 /* This file handles the generation of rtl code from tree structure | |
23 at the level of the function as a whole. | |
24 It creates the rtl expressions for parameters and auto variables | |
25 and has full responsibility for allocating stack slots. | |
26 | |
27 `expand_function_start' is called at the beginning of a function, | |
28 before the function body is parsed, and `expand_function_end' is | |
29 called after parsing the body. | |
30 | |
31 Call `assign_stack_local' to allocate a stack slot for a local variable. | |
32 This is usually done during the RTL generation for the function body, | |
33 but it can also be done in the reload pass when a pseudo-register does | |
34 not get a hard register. */ | |
35 | |
36 #include "config.h" | |
37 #include "system.h" | |
38 #include "coretypes.h" | |
39 #include "tm.h" | |
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
|
40 #include "rtl-error.h" |
0 | 41 #include "tree.h" |
42 #include "flags.h" | |
43 #include "except.h" | |
44 #include "function.h" | |
45 #include "expr.h" | |
46 #include "optabs.h" | |
47 #include "libfuncs.h" | |
48 #include "regs.h" | |
49 #include "hard-reg-set.h" | |
50 #include "insn-config.h" | |
51 #include "recog.h" | |
52 #include "output.h" | |
53 #include "basic-block.h" | |
54 #include "hashtab.h" | |
55 #include "ggc.h" | |
56 #include "tm_p.h" | |
57 #include "integrate.h" | |
58 #include "langhooks.h" | |
59 #include "target.h" | |
60 #include "cfglayout.h" | |
61 #include "gimple.h" | |
62 #include "tree-pass.h" | |
63 #include "predict.h" | |
64 #include "df.h" | |
65 #include "timevar.h" | |
66 #include "vecprim.h" | |
67 | |
82
895e19fe9c22
modify calls.c
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
68 |
895e19fe9c22
modify calls.c
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
69 |
0 | 70 /* So we can assign to cfun in this file. */ |
71 #undef cfun | |
72 | |
73 #ifndef STACK_ALIGNMENT_NEEDED | |
74 #define STACK_ALIGNMENT_NEEDED 1 | |
75 #endif | |
76 | |
77 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) | |
78 | |
79 /* Some systems use __main in a way incompatible with its use in gcc, in these | |
80 cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to | |
81 give the same symbol without quotes for an alternative entry point. You | |
82 must define both, or neither. */ | |
83 #ifndef NAME__MAIN | |
84 #define NAME__MAIN "__main" | |
85 #endif | |
86 | |
87 /* Round a value to the lowest integer less than it that is a multiple of | |
88 the required alignment. Avoid using division in case the value is | |
89 negative. Assume the alignment is a power of two. */ | |
90 #define FLOOR_ROUND(VALUE,ALIGN) ((VALUE) & ~((ALIGN) - 1)) | |
91 | |
92 /* Similar, but round to the next highest integer that meets the | |
93 alignment. */ | |
94 #define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1)) | |
95 | |
96 /* Nonzero if function being compiled doesn't contain any calls | |
97 (ignoring the prologue and epilogue). This is set prior to | |
98 local register allocation and is valid for the remaining | |
99 compiler passes. */ | |
100 int current_function_is_leaf; | |
101 | |
102 /* Nonzero if function being compiled doesn't modify the stack pointer | |
103 (ignoring the prologue and epilogue). This is only valid after | |
104 pass_stack_ptr_mod has run. */ | |
105 int current_function_sp_is_unchanging; | |
106 | |
107 /* Nonzero if the function being compiled is a leaf function which only | |
108 uses leaf registers. This is valid after reload (specifically after | |
109 sched2) and is useful only if the port defines LEAF_REGISTERS. */ | |
110 int current_function_uses_only_leaf_regs; | |
111 | |
112 /* Nonzero once virtual register instantiation has been done. | |
113 assign_stack_local uses frame_pointer_rtx when this is nonzero. | |
114 calls.c:emit_library_call_value_1 uses it to set up | |
115 post-instantiation libcalls. */ | |
116 int virtuals_instantiated; | |
117 | |
118 /* Assign unique numbers to labels generated for profiling, debugging, etc. */ | |
119 static GTY(()) int funcdef_no; | |
120 | |
121 /* These variables hold pointers to functions to create and destroy | |
122 target specific, per-function data structures. */ | |
123 struct machine_function * (*init_machine_status) (void); | |
124 | |
125 /* The currently compiled function. */ | |
126 struct function *cfun = 0; | |
127 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
128 /* These hashes record the prologue and epilogue insns. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
129 static GTY((if_marked ("ggc_marked_p"), param_is (struct rtx_def))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
130 htab_t prologue_insn_hash; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
131 static GTY((if_marked ("ggc_marked_p"), param_is (struct rtx_def))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
132 htab_t epilogue_insn_hash; |
0 | 133 |
36 | 134 |
135 htab_t types_used_by_vars_hash = NULL; | |
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
|
136 VEC(tree,gc) *types_used_by_cur_var_decl; |
36 | 137 |
0 | 138 /* Forward declarations. */ |
139 | |
140 static struct temp_slot *find_temp_slot_from_address (rtx); | |
141 static void pad_to_arg_alignment (struct args_size *, int, struct args_size *); | |
142 static void pad_below (struct args_size *, enum machine_mode, tree); | |
143 static void reorder_blocks_1 (rtx, tree, VEC(tree,heap) **); | |
144 static int all_blocks (tree, tree *); | |
145 static tree *get_block_vector (tree, int *); | |
146 extern tree debug_find_var_in_block_tree (tree, tree); | |
147 /* We always define `record_insns' even if it's not used so that we | |
148 can always export `prologue_epilogue_contains'. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
149 static void record_insns (rtx, rtx, htab_t *) ATTRIBUTE_UNUSED; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
150 static bool contains (const_rtx, htab_t); |
0 | 151 #ifdef HAVE_return |
152 static void emit_return_into_block (basic_block); | |
153 #endif | |
154 static void prepare_function_start (void); | |
155 static void do_clobber_return_reg (rtx, void *); | |
156 static void do_use_return_reg (rtx, void *); | |
157 static void set_insn_locators (rtx, int) ATTRIBUTE_UNUSED; | |
158 | |
159 /* Stack of nested functions. */ | |
160 /* Keep track of the cfun stack. */ | |
161 | |
162 typedef struct function *function_p; | |
163 | |
164 DEF_VEC_P(function_p); | |
165 DEF_VEC_ALLOC_P(function_p,heap); | |
166 static VEC(function_p,heap) *function_context_stack; | |
167 | |
168 /* Save the current context for compilation of a nested function. | |
169 This is called from language-specific code. */ | |
170 | |
171 void | |
172 push_function_context (void) | |
173 { | |
174 if (cfun == 0) | |
175 allocate_struct_function (NULL, false); | |
176 | |
177 VEC_safe_push (function_p, heap, function_context_stack, cfun); | |
178 set_cfun (NULL); | |
179 } | |
180 | |
181 /* Restore the last saved context, at the end of a nested function. | |
182 This function is called from language-specific code. */ | |
183 | |
184 void | |
185 pop_function_context (void) | |
186 { | |
187 struct function *p = VEC_pop (function_p, function_context_stack); | |
188 set_cfun (p); | |
189 current_function_decl = p->decl; | |
190 | |
191 /* Reset variables that have known state during rtx generation. */ | |
192 virtuals_instantiated = 0; | |
193 generating_concat_p = 1; | |
194 } | |
195 | |
196 /* Clear out all parts of the state in F that can safely be discarded | |
197 after the function has been parsed, but not compiled, to let | |
198 garbage collection reclaim the memory. */ | |
199 | |
200 void | |
201 free_after_parsing (struct function *f) | |
202 { | |
203 f->language = 0; | |
204 } | |
205 | |
206 /* Clear out all parts of the state in F that can safely be discarded | |
207 after the function has been compiled, to let garbage collection | |
208 reclaim the memory. */ | |
209 | |
210 void | |
211 free_after_compilation (struct function *f) | |
212 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
213 prologue_insn_hash = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
214 epilogue_insn_hash = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
215 |
0 | 216 if (crtl->emit.regno_pointer_align) |
217 free (crtl->emit.regno_pointer_align); | |
218 | |
219 memset (crtl, 0, sizeof (struct rtl_data)); | |
220 f->eh = NULL; | |
221 f->machine = NULL; | |
222 f->cfg = NULL; | |
223 | |
224 regno_reg_rtx = NULL; | |
225 insn_locators_free (); | |
226 } | |
227 | |
228 /* Return size needed for stack frame based on slots so far allocated. | |
229 This size counts from zero. It is not rounded to PREFERRED_STACK_BOUNDARY; | |
230 the caller may have to do that. */ | |
231 | |
232 HOST_WIDE_INT | |
233 get_frame_size (void) | |
234 { | |
235 if (FRAME_GROWS_DOWNWARD) | |
236 return -frame_offset; | |
237 else | |
238 return frame_offset; | |
239 } | |
240 | |
241 /* Issue an error message and return TRUE if frame OFFSET overflows in | |
242 the signed target pointer arithmetics for function FUNC. Otherwise | |
243 return FALSE. */ | |
244 | |
245 bool | |
246 frame_offset_overflow (HOST_WIDE_INT offset, tree func) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
247 { |
0 | 248 unsigned HOST_WIDE_INT size = FRAME_GROWS_DOWNWARD ? -offset : offset; |
249 | |
250 if (size > ((unsigned HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (Pmode) - 1)) | |
251 /* Leave room for the fixed part of the frame. */ | |
252 - 64 * UNITS_PER_WORD) | |
253 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
254 error_at (DECL_SOURCE_LOCATION (func), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
255 "total size of local objects too large"); |
0 | 256 return TRUE; |
257 } | |
258 | |
259 return FALSE; | |
260 } | |
261 | |
262 /* Return stack slot alignment in bits for TYPE and MODE. */ | |
263 | |
264 static unsigned int | |
265 get_stack_local_alignment (tree type, enum machine_mode mode) | |
266 { | |
267 unsigned int alignment; | |
268 | |
269 if (mode == BLKmode) | |
270 alignment = BIGGEST_ALIGNMENT; | |
271 else | |
272 alignment = GET_MODE_ALIGNMENT (mode); | |
273 | |
274 /* Allow the frond-end to (possibly) increase the alignment of this | |
275 stack slot. */ | |
276 if (! type) | |
277 type = lang_hooks.types.type_for_mode (mode, 0); | |
278 | |
279 return STACK_SLOT_ALIGNMENT (type, mode, alignment); | |
280 } | |
281 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
282 /* Determine whether it is possible to fit a stack slot of size SIZE and |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
283 alignment ALIGNMENT into an area in the stack frame that starts at |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
284 frame offset START and has a length of LENGTH. If so, store the frame |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
285 offset to be used for the stack slot in *POFFSET and return true; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
286 return false otherwise. This function will extend the frame size when |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
287 given a start/length pair that lies at the end of the frame. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
288 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
289 static bool |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
290 try_fit_stack_local (HOST_WIDE_INT start, HOST_WIDE_INT length, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
291 HOST_WIDE_INT size, unsigned int alignment, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
292 HOST_WIDE_INT *poffset) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
293 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
294 HOST_WIDE_INT this_frame_offset; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
295 int frame_off, frame_alignment, frame_phase; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
296 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
297 /* Calculate how many bytes the start of local variables is off from |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
298 stack alignment. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
299 frame_alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
300 frame_off = STARTING_FRAME_OFFSET % frame_alignment; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
301 frame_phase = frame_off ? frame_alignment - frame_off : 0; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
302 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
303 /* Round the frame offset to the specified alignment. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
304 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
305 /* We must be careful here, since FRAME_OFFSET might be negative and |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
306 division with a negative dividend isn't as well defined as we might |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
307 like. So we instead assume that ALIGNMENT is a power of two and |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
308 use logical operations which are unambiguous. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
309 if (FRAME_GROWS_DOWNWARD) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
310 this_frame_offset |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
311 = (FLOOR_ROUND (start + length - size - frame_phase, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
312 (unsigned HOST_WIDE_INT) alignment) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
313 + frame_phase); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
314 else |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
315 this_frame_offset |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
316 = (CEIL_ROUND (start - frame_phase, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
317 (unsigned HOST_WIDE_INT) alignment) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
318 + frame_phase); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
319 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
320 /* See if it fits. If this space is at the edge of the frame, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
321 consider extending the frame to make it fit. Our caller relies on |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
322 this when allocating a new slot. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
323 if (frame_offset == start && this_frame_offset < frame_offset) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
324 frame_offset = this_frame_offset; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
325 else if (this_frame_offset < start) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
326 return false; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
327 else if (start + length == frame_offset |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
328 && this_frame_offset + size > start + length) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
329 frame_offset = this_frame_offset + size; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
330 else if (this_frame_offset + size > start + length) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
331 return false; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
332 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
333 *poffset = this_frame_offset; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
334 return true; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
335 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
336 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
337 /* Create a new frame_space structure describing free space in the stack |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
338 frame beginning at START and ending at END, and chain it into the |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
339 function's frame_space_list. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
340 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
341 static void |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
342 add_frame_space (HOST_WIDE_INT start, HOST_WIDE_INT end) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
343 { |
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
|
344 struct frame_space *space = ggc_alloc_frame_space (); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
345 space->next = crtl->frame_space_list; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
346 crtl->frame_space_list = space; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
347 space->start = start; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
348 space->length = end - start; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
349 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
350 |
0 | 351 /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it |
352 with machine mode MODE. | |
353 | |
354 ALIGN controls the amount of alignment for the address of the slot: | |
355 0 means according to MODE, | |
356 -1 means use BIGGEST_ALIGNMENT and round size to multiple of that, | |
357 -2 means use BITS_PER_UNIT, | |
358 positive specifies alignment boundary in bits. | |
359 | |
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
|
360 KIND has ASLK_REDUCE_ALIGN bit set if it is OK to reduce |
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
|
361 alignment and ASLK_RECORD_PAD bit set if we should remember |
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
|
362 extra space we allocated for alignment purposes. When we are |
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
|
363 called from assign_stack_temp_for_type, it is not set so we don't |
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
|
364 track the same stack slot in two independent lists. |
0 | 365 |
366 We do not round to stack_boundary here. */ | |
367 | |
368 rtx | |
369 assign_stack_local_1 (enum machine_mode mode, HOST_WIDE_INT size, | |
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
|
370 int align, int kind) |
0 | 371 { |
372 rtx x, addr; | |
373 int bigend_correction = 0; | |
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
|
374 HOST_WIDE_INT slot_offset = 0, old_frame_offset; |
0 | 375 unsigned int alignment, alignment_in_bits; |
376 | |
377 if (align == 0) | |
378 { | |
379 alignment = get_stack_local_alignment (NULL, mode); | |
380 alignment /= BITS_PER_UNIT; | |
381 } | |
382 else if (align == -1) | |
383 { | |
384 alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT; | |
385 size = CEIL_ROUND (size, alignment); | |
386 } | |
387 else if (align == -2) | |
388 alignment = 1; /* BITS_PER_UNIT / BITS_PER_UNIT */ | |
389 else | |
390 alignment = align / BITS_PER_UNIT; | |
391 | |
392 alignment_in_bits = alignment * BITS_PER_UNIT; | |
393 | |
394 /* Ignore alignment if it exceeds MAX_SUPPORTED_STACK_ALIGNMENT. */ | |
395 if (alignment_in_bits > MAX_SUPPORTED_STACK_ALIGNMENT) | |
396 { | |
397 alignment_in_bits = MAX_SUPPORTED_STACK_ALIGNMENT; | |
398 alignment = alignment_in_bits / BITS_PER_UNIT; | |
399 } | |
400 | |
401 if (SUPPORTS_STACK_ALIGNMENT) | |
402 { | |
403 if (crtl->stack_alignment_estimated < alignment_in_bits) | |
404 { | |
405 if (!crtl->stack_realign_processed) | |
406 crtl->stack_alignment_estimated = alignment_in_bits; | |
407 else | |
408 { | |
409 /* If stack is realigned and stack alignment value | |
410 hasn't been finalized, it is OK not to increase | |
411 stack_alignment_estimated. The bigger alignment | |
412 requirement is recorded in stack_alignment_needed | |
413 below. */ | |
414 gcc_assert (!crtl->stack_realign_finalized); | |
415 if (!crtl->stack_realign_needed) | |
416 { | |
417 /* It is OK to reduce the alignment as long as the | |
418 requested size is 0 or the estimated stack | |
419 alignment >= mode alignment. */ | |
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
|
420 gcc_assert ((kind & ASLK_REDUCE_ALIGN) |
0 | 421 || size == 0 |
422 || (crtl->stack_alignment_estimated | |
423 >= GET_MODE_ALIGNMENT (mode))); | |
424 alignment_in_bits = crtl->stack_alignment_estimated; | |
425 alignment = alignment_in_bits / BITS_PER_UNIT; | |
426 } | |
427 } | |
428 } | |
429 } | |
430 | |
431 if (crtl->stack_alignment_needed < alignment_in_bits) | |
432 crtl->stack_alignment_needed = alignment_in_bits; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
433 if (crtl->max_used_stack_slot_alignment < alignment_in_bits) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
434 crtl->max_used_stack_slot_alignment = alignment_in_bits; |
0 | 435 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
436 if (mode != BLKmode || size != 0) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
437 { |
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
|
438 if (kind & ASLK_RECORD_PAD) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
439 { |
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
|
440 struct frame_space **psp; |
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
|
441 |
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
|
442 for (psp = &crtl->frame_space_list; *psp; psp = &(*psp)->next) |
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
|
443 { |
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
|
444 struct frame_space *space = *psp; |
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
|
445 if (!try_fit_stack_local (space->start, space->length, 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
|
446 alignment, &slot_offset)) |
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
|
447 continue; |
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
|
448 *psp = space->next; |
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
|
449 if (slot_offset > space->start) |
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
|
450 add_frame_space (space->start, slot_offset); |
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
|
451 if (slot_offset + size < space->start + space->length) |
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
|
452 add_frame_space (slot_offset + 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
|
453 space->start + space->length); |
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
|
454 goto found_space; |
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
|
455 } |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
456 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
457 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
458 else if (!STACK_ALIGNMENT_NEEDED) |
0 | 459 { |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
460 slot_offset = frame_offset; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
461 goto found_space; |
0 | 462 } |
463 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
464 old_frame_offset = frame_offset; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
465 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
466 if (FRAME_GROWS_DOWNWARD) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
467 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
468 frame_offset -= size; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
469 try_fit_stack_local (frame_offset, size, size, alignment, &slot_offset); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
470 |
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
|
471 if (kind & ASLK_RECORD_PAD) |
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
|
472 { |
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
|
473 if (slot_offset > frame_offset) |
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
|
474 add_frame_space (frame_offset, slot_offset); |
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
|
475 if (slot_offset + size < old_frame_offset) |
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
|
476 add_frame_space (slot_offset + size, old_frame_offset); |
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
|
477 } |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
478 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
479 else |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
480 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
481 frame_offset += size; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
482 try_fit_stack_local (old_frame_offset, size, size, alignment, &slot_offset); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
483 |
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
|
484 if (kind & ASLK_RECORD_PAD) |
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
|
485 { |
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
|
486 if (slot_offset > old_frame_offset) |
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
|
487 add_frame_space (old_frame_offset, slot_offset); |
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
|
488 if (slot_offset + size < frame_offset) |
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
|
489 add_frame_space (slot_offset + size, frame_offset); |
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
|
490 } |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
491 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
492 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
493 found_space: |
0 | 494 /* On a big-endian machine, if we are allocating more space than we will use, |
495 use the least significant bytes of those that are allocated. */ | |
496 if (BYTES_BIG_ENDIAN && mode != BLKmode && GET_MODE_SIZE (mode) < size) | |
497 bigend_correction = size - GET_MODE_SIZE (mode); | |
498 | |
499 /* If we have already instantiated virtual registers, return the actual | |
500 address relative to the frame pointer. */ | |
501 if (virtuals_instantiated) | |
502 addr = plus_constant (frame_pointer_rtx, | |
503 trunc_int_for_mode | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
504 (slot_offset + bigend_correction |
0 | 505 + STARTING_FRAME_OFFSET, Pmode)); |
506 else | |
507 addr = plus_constant (virtual_stack_vars_rtx, | |
508 trunc_int_for_mode | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
509 (slot_offset + bigend_correction, |
0 | 510 Pmode)); |
511 | |
512 x = gen_rtx_MEM (mode, addr); | |
513 set_mem_align (x, alignment_in_bits); | |
514 MEM_NOTRAP_P (x) = 1; | |
515 | |
516 stack_slot_list | |
517 = gen_rtx_EXPR_LIST (VOIDmode, x, stack_slot_list); | |
518 | |
519 if (frame_offset_overflow (frame_offset, current_function_decl)) | |
520 frame_offset = 0; | |
521 | |
522 return x; | |
523 } | |
524 | |
525 /* Wrap up assign_stack_local_1 with last parameter as false. */ | |
526 | |
527 rtx | |
528 assign_stack_local (enum machine_mode mode, HOST_WIDE_INT size, int align) | |
529 { | |
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
|
530 return assign_stack_local_1 (mode, size, align, ASLK_RECORD_PAD); |
0 | 531 } |
532 | |
533 | |
534 /* In order to evaluate some expressions, such as function calls returning | |
535 structures in memory, we need to temporarily allocate stack locations. | |
536 We record each allocated temporary in the following structure. | |
537 | |
538 Associated with each temporary slot is a nesting level. When we pop up | |
539 one level, all temporaries associated with the previous level are freed. | |
540 Normally, all temporaries are freed after the execution of the statement | |
541 in which they were created. However, if we are inside a ({...}) grouping, | |
542 the result may be in a temporary and hence must be preserved. If the | |
543 result could be in a temporary, we preserve it if we can determine which | |
544 one it is in. If we cannot determine which temporary may contain the | |
545 result, all temporaries are preserved. A temporary is preserved by | |
546 pretending it was allocated at the previous nesting level. | |
547 | |
548 Automatic variables are also assigned temporary slots, at the nesting | |
549 level where they are defined. They are marked a "kept" so that | |
550 free_temp_slots will not free them. */ | |
551 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
552 struct GTY(()) temp_slot { |
0 | 553 /* Points to next temporary slot. */ |
554 struct temp_slot *next; | |
555 /* Points to previous temporary slot. */ | |
556 struct temp_slot *prev; | |
557 /* The rtx to used to reference the slot. */ | |
558 rtx slot; | |
559 /* The size, in units, of the slot. */ | |
560 HOST_WIDE_INT size; | |
561 /* The type of the object in the slot, or zero if it doesn't correspond | |
562 to a type. We use this to determine whether a slot can be reused. | |
563 It can be reused if objects of the type of the new slot will always | |
564 conflict with objects of the type of the old slot. */ | |
565 tree type; | |
566 /* The alignment (in bits) of the slot. */ | |
567 unsigned int align; | |
568 /* Nonzero if this temporary is currently in use. */ | |
569 char in_use; | |
570 /* Nonzero if this temporary has its address taken. */ | |
571 char addr_taken; | |
572 /* Nesting level at which this slot is being used. */ | |
573 int level; | |
574 /* Nonzero if this should survive a call to free_temp_slots. */ | |
575 int keep; | |
576 /* The offset of the slot from the frame_pointer, including extra space | |
577 for alignment. This info is for combine_temp_slots. */ | |
578 HOST_WIDE_INT base_offset; | |
579 /* The size of the slot, including extra space for alignment. This | |
580 info is for combine_temp_slots. */ | |
581 HOST_WIDE_INT full_size; | |
582 }; | |
583 | |
584 /* A table of addresses that represent a stack slot. The table is a mapping | |
585 from address RTXen to a temp slot. */ | |
586 static GTY((param_is(struct temp_slot_address_entry))) htab_t temp_slot_address_table; | |
587 | |
588 /* Entry for the above hash table. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
589 struct GTY(()) temp_slot_address_entry { |
0 | 590 hashval_t hash; |
591 rtx address; | |
592 struct temp_slot *temp_slot; | |
593 }; | |
594 | |
595 /* Removes temporary slot TEMP from LIST. */ | |
596 | |
597 static void | |
598 cut_slot_from_list (struct temp_slot *temp, struct temp_slot **list) | |
599 { | |
600 if (temp->next) | |
601 temp->next->prev = temp->prev; | |
602 if (temp->prev) | |
603 temp->prev->next = temp->next; | |
604 else | |
605 *list = temp->next; | |
606 | |
607 temp->prev = temp->next = NULL; | |
608 } | |
609 | |
610 /* Inserts temporary slot TEMP to LIST. */ | |
611 | |
612 static void | |
613 insert_slot_to_list (struct temp_slot *temp, struct temp_slot **list) | |
614 { | |
615 temp->next = *list; | |
616 if (*list) | |
617 (*list)->prev = temp; | |
618 temp->prev = NULL; | |
619 *list = temp; | |
620 } | |
621 | |
622 /* Returns the list of used temp slots at LEVEL. */ | |
623 | |
624 static struct temp_slot ** | |
625 temp_slots_at_level (int level) | |
626 { | |
627 if (level >= (int) VEC_length (temp_slot_p, used_temp_slots)) | |
628 VEC_safe_grow_cleared (temp_slot_p, gc, used_temp_slots, level + 1); | |
629 | |
630 return &(VEC_address (temp_slot_p, used_temp_slots)[level]); | |
631 } | |
632 | |
633 /* Returns the maximal temporary slot level. */ | |
634 | |
635 static int | |
636 max_slot_level (void) | |
637 { | |
638 if (!used_temp_slots) | |
639 return -1; | |
640 | |
641 return VEC_length (temp_slot_p, used_temp_slots) - 1; | |
642 } | |
643 | |
644 /* Moves temporary slot TEMP to LEVEL. */ | |
645 | |
646 static void | |
647 move_slot_to_level (struct temp_slot *temp, int level) | |
648 { | |
649 cut_slot_from_list (temp, temp_slots_at_level (temp->level)); | |
650 insert_slot_to_list (temp, temp_slots_at_level (level)); | |
651 temp->level = level; | |
652 } | |
653 | |
654 /* Make temporary slot TEMP available. */ | |
655 | |
656 static void | |
657 make_slot_available (struct temp_slot *temp) | |
658 { | |
659 cut_slot_from_list (temp, temp_slots_at_level (temp->level)); | |
660 insert_slot_to_list (temp, &avail_temp_slots); | |
661 temp->in_use = 0; | |
662 temp->level = -1; | |
663 } | |
664 | |
665 /* Compute the hash value for an address -> temp slot mapping. | |
666 The value is cached on the mapping entry. */ | |
667 static hashval_t | |
668 temp_slot_address_compute_hash (struct temp_slot_address_entry *t) | |
669 { | |
670 int do_not_record = 0; | |
671 return hash_rtx (t->address, GET_MODE (t->address), | |
672 &do_not_record, NULL, false); | |
673 } | |
674 | |
675 /* Return the hash value for an address -> temp slot mapping. */ | |
676 static hashval_t | |
677 temp_slot_address_hash (const void *p) | |
678 { | |
679 const struct temp_slot_address_entry *t; | |
680 t = (const struct temp_slot_address_entry *) p; | |
681 return t->hash; | |
682 } | |
683 | |
684 /* Compare two address -> temp slot mapping entries. */ | |
685 static int | |
686 temp_slot_address_eq (const void *p1, const void *p2) | |
687 { | |
688 const struct temp_slot_address_entry *t1, *t2; | |
689 t1 = (const struct temp_slot_address_entry *) p1; | |
690 t2 = (const struct temp_slot_address_entry *) p2; | |
691 return exp_equiv_p (t1->address, t2->address, 0, true); | |
692 } | |
693 | |
694 /* Add ADDRESS as an alias of TEMP_SLOT to the addess -> temp slot mapping. */ | |
695 static void | |
696 insert_temp_slot_address (rtx address, struct temp_slot *temp_slot) | |
697 { | |
698 void **slot; | |
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
|
699 struct temp_slot_address_entry *t = ggc_alloc_temp_slot_address_entry (); |
0 | 700 t->address = address; |
701 t->temp_slot = temp_slot; | |
702 t->hash = temp_slot_address_compute_hash (t); | |
703 slot = htab_find_slot_with_hash (temp_slot_address_table, t, t->hash, INSERT); | |
704 *slot = t; | |
705 } | |
706 | |
707 /* Remove an address -> temp slot mapping entry if the temp slot is | |
708 not in use anymore. Callback for remove_unused_temp_slot_addresses. */ | |
709 static int | |
710 remove_unused_temp_slot_addresses_1 (void **slot, void *data ATTRIBUTE_UNUSED) | |
711 { | |
712 const struct temp_slot_address_entry *t; | |
713 t = (const struct temp_slot_address_entry *) *slot; | |
714 if (! t->temp_slot->in_use) | |
715 *slot = NULL; | |
716 return 1; | |
717 } | |
718 | |
719 /* Remove all mappings of addresses to unused temp slots. */ | |
720 static void | |
721 remove_unused_temp_slot_addresses (void) | |
722 { | |
723 htab_traverse (temp_slot_address_table, | |
724 remove_unused_temp_slot_addresses_1, | |
725 NULL); | |
726 } | |
727 | |
728 /* Find the temp slot corresponding to the object at address X. */ | |
729 | |
730 static struct temp_slot * | |
731 find_temp_slot_from_address (rtx x) | |
732 { | |
733 struct temp_slot *p; | |
734 struct temp_slot_address_entry tmp, *t; | |
735 | |
736 /* First try the easy way: | |
737 See if X exists in the address -> temp slot mapping. */ | |
738 tmp.address = x; | |
739 tmp.temp_slot = NULL; | |
740 tmp.hash = temp_slot_address_compute_hash (&tmp); | |
741 t = (struct temp_slot_address_entry *) | |
742 htab_find_with_hash (temp_slot_address_table, &tmp, tmp.hash); | |
743 if (t) | |
744 return t->temp_slot; | |
745 | |
746 /* If we have a sum involving a register, see if it points to a temp | |
747 slot. */ | |
748 if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0)) | |
749 && (p = find_temp_slot_from_address (XEXP (x, 0))) != 0) | |
750 return p; | |
751 else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 1)) | |
752 && (p = find_temp_slot_from_address (XEXP (x, 1))) != 0) | |
753 return p; | |
754 | |
755 /* Last resort: Address is a virtual stack var address. */ | |
756 if (GET_CODE (x) == PLUS | |
757 && XEXP (x, 0) == virtual_stack_vars_rtx | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
758 && CONST_INT_P (XEXP (x, 1))) |
0 | 759 { |
760 int i; | |
761 for (i = max_slot_level (); i >= 0; i--) | |
762 for (p = *temp_slots_at_level (i); p; p = p->next) | |
763 { | |
764 if (INTVAL (XEXP (x, 1)) >= p->base_offset | |
765 && INTVAL (XEXP (x, 1)) < p->base_offset + p->full_size) | |
766 return p; | |
767 } | |
768 } | |
769 | |
770 return NULL; | |
771 } | |
772 | |
773 /* Allocate a temporary stack slot and record it for possible later | |
774 reuse. | |
775 | |
776 MODE is the machine mode to be given to the returned rtx. | |
777 | |
778 SIZE is the size in units of the space required. We do no rounding here | |
779 since assign_stack_local will do any required rounding. | |
780 | |
781 KEEP is 1 if this slot is to be retained after a call to | |
782 free_temp_slots. Automatic variables for a block are allocated | |
783 with this flag. KEEP values of 2 or 3 were needed respectively | |
784 for variables whose lifetime is controlled by CLEANUP_POINT_EXPRs | |
785 or for SAVE_EXPRs, but they are now unused. | |
786 | |
787 TYPE is the type that will be used for the stack slot. */ | |
788 | |
789 rtx | |
790 assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size, | |
791 int keep, tree type) | |
792 { | |
793 unsigned int align; | |
794 struct temp_slot *p, *best_p = 0, *selected = NULL, **pp; | |
795 rtx slot; | |
796 | |
797 /* If SIZE is -1 it means that somebody tried to allocate a temporary | |
798 of a variable size. */ | |
799 gcc_assert (size != -1); | |
800 | |
801 /* These are now unused. */ | |
802 gcc_assert (keep <= 1); | |
803 | |
804 align = get_stack_local_alignment (type, mode); | |
805 | |
806 /* Try to find an available, already-allocated temporary of the proper | |
807 mode which meets the size and alignment requirements. Choose the | |
808 smallest one with the closest alignment. | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
809 |
0 | 810 If assign_stack_temp is called outside of the tree->rtl expansion, |
811 we cannot reuse the stack slots (that may still refer to | |
812 VIRTUAL_STACK_VARS_REGNUM). */ | |
813 if (!virtuals_instantiated) | |
814 { | |
815 for (p = avail_temp_slots; p; p = p->next) | |
816 { | |
817 if (p->align >= align && p->size >= size | |
818 && GET_MODE (p->slot) == mode | |
819 && objects_must_conflict_p (p->type, type) | |
820 && (best_p == 0 || best_p->size > p->size | |
821 || (best_p->size == p->size && best_p->align > p->align))) | |
822 { | |
823 if (p->align == align && p->size == size) | |
824 { | |
825 selected = p; | |
826 cut_slot_from_list (selected, &avail_temp_slots); | |
827 best_p = 0; | |
828 break; | |
829 } | |
830 best_p = p; | |
831 } | |
832 } | |
833 } | |
834 | |
835 /* Make our best, if any, the one to use. */ | |
836 if (best_p) | |
837 { | |
838 selected = best_p; | |
839 cut_slot_from_list (selected, &avail_temp_slots); | |
840 | |
841 /* If there are enough aligned bytes left over, make them into a new | |
842 temp_slot so that the extra bytes don't get wasted. Do this only | |
843 for BLKmode slots, so that we can be sure of the alignment. */ | |
844 if (GET_MODE (best_p->slot) == BLKmode) | |
845 { | |
846 int alignment = best_p->align / BITS_PER_UNIT; | |
847 HOST_WIDE_INT rounded_size = CEIL_ROUND (size, alignment); | |
848 | |
849 if (best_p->size - rounded_size >= alignment) | |
850 { | |
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
|
851 p = ggc_alloc_temp_slot (); |
0 | 852 p->in_use = p->addr_taken = 0; |
853 p->size = best_p->size - rounded_size; | |
854 p->base_offset = best_p->base_offset + rounded_size; | |
855 p->full_size = best_p->full_size - rounded_size; | |
856 p->slot = adjust_address_nv (best_p->slot, BLKmode, rounded_size); | |
857 p->align = best_p->align; | |
858 p->type = best_p->type; | |
859 insert_slot_to_list (p, &avail_temp_slots); | |
860 | |
861 stack_slot_list = gen_rtx_EXPR_LIST (VOIDmode, p->slot, | |
862 stack_slot_list); | |
863 | |
864 best_p->size = rounded_size; | |
865 best_p->full_size = rounded_size; | |
866 } | |
867 } | |
868 } | |
869 | |
870 /* If we still didn't find one, make a new temporary. */ | |
871 if (selected == 0) | |
872 { | |
873 HOST_WIDE_INT frame_offset_old = frame_offset; | |
874 | |
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
|
875 p = ggc_alloc_temp_slot (); |
0 | 876 |
877 /* We are passing an explicit alignment request to assign_stack_local. | |
878 One side effect of that is assign_stack_local will not round SIZE | |
879 to ensure the frame offset remains suitably aligned. | |
880 | |
881 So for requests which depended on the rounding of SIZE, we go ahead | |
882 and round it now. We also make sure ALIGNMENT is at least | |
883 BIGGEST_ALIGNMENT. */ | |
884 gcc_assert (mode != BLKmode || align == BIGGEST_ALIGNMENT); | |
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
|
885 p->slot = assign_stack_local_1 (mode, |
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
|
886 (mode == BLKmode |
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
|
887 ? CEIL_ROUND (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
|
888 (int) align |
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
|
889 / BITS_PER_UNIT) |
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
|
890 : 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
|
891 align, 0); |
0 | 892 |
893 p->align = align; | |
894 | |
895 /* The following slot size computation is necessary because we don't | |
896 know the actual size of the temporary slot until assign_stack_local | |
897 has performed all the frame alignment and size rounding for the | |
898 requested temporary. Note that extra space added for alignment | |
899 can be either above or below this stack slot depending on which | |
900 way the frame grows. We include the extra space if and only if it | |
901 is above this slot. */ | |
902 if (FRAME_GROWS_DOWNWARD) | |
903 p->size = frame_offset_old - frame_offset; | |
904 else | |
905 p->size = size; | |
906 | |
907 /* Now define the fields used by combine_temp_slots. */ | |
908 if (FRAME_GROWS_DOWNWARD) | |
909 { | |
910 p->base_offset = frame_offset; | |
911 p->full_size = frame_offset_old - frame_offset; | |
912 } | |
913 else | |
914 { | |
915 p->base_offset = frame_offset_old; | |
916 p->full_size = frame_offset - frame_offset_old; | |
917 } | |
918 | |
919 selected = p; | |
920 } | |
921 | |
922 p = selected; | |
923 p->in_use = 1; | |
924 p->addr_taken = 0; | |
925 p->type = type; | |
926 p->level = temp_slot_level; | |
927 p->keep = keep; | |
928 | |
929 pp = temp_slots_at_level (p->level); | |
930 insert_slot_to_list (p, pp); | |
931 insert_temp_slot_address (XEXP (p->slot, 0), p); | |
932 | |
933 /* Create a new MEM rtx to avoid clobbering MEM flags of old slots. */ | |
934 slot = gen_rtx_MEM (mode, XEXP (p->slot, 0)); | |
935 stack_slot_list = gen_rtx_EXPR_LIST (VOIDmode, slot, stack_slot_list); | |
936 | |
937 /* If we know the alias set for the memory that will be used, use | |
938 it. If there's no TYPE, then we don't know anything about the | |
939 alias set for the memory. */ | |
940 set_mem_alias_set (slot, type ? get_alias_set (type) : 0); | |
941 set_mem_align (slot, align); | |
942 | |
943 /* If a type is specified, set the relevant flags. */ | |
944 if (type != 0) | |
945 { | |
946 MEM_VOLATILE_P (slot) = TYPE_VOLATILE (type); | |
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
|
947 gcc_checking_assert (!MEM_SCALAR_P (slot) && !MEM_IN_STRUCT_P (slot)); |
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
|
948 if (AGGREGATE_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE) |
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
|
949 MEM_IN_STRUCT_P (slot) = 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
|
950 else |
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
|
951 MEM_SCALAR_P (slot) = 1; |
0 | 952 } |
953 MEM_NOTRAP_P (slot) = 1; | |
954 | |
955 return slot; | |
956 } | |
957 | |
958 /* Allocate a temporary stack slot and record it for possible later | |
959 reuse. First three arguments are same as in preceding function. */ | |
960 | |
961 rtx | |
962 assign_stack_temp (enum machine_mode mode, HOST_WIDE_INT size, int keep) | |
963 { | |
964 return assign_stack_temp_for_type (mode, size, keep, NULL_TREE); | |
965 } | |
966 | |
967 /* Assign a temporary. | |
968 If TYPE_OR_DECL is a decl, then we are doing it on behalf of the decl | |
969 and so that should be used in error messages. In either case, we | |
970 allocate of the given type. | |
971 KEEP is as for assign_stack_temp. | |
972 MEMORY_REQUIRED is 1 if the result must be addressable stack memory; | |
973 it is 0 if a register is OK. | |
974 DONT_PROMOTE is 1 if we should not promote values in register | |
975 to wider modes. */ | |
976 | |
977 rtx | |
978 assign_temp (tree type_or_decl, int keep, int memory_required, | |
979 int dont_promote ATTRIBUTE_UNUSED) | |
980 { | |
981 tree type, decl; | |
982 enum machine_mode mode; | |
983 #ifdef PROMOTE_MODE | |
984 int unsignedp; | |
985 #endif | |
986 | |
987 if (DECL_P (type_or_decl)) | |
988 decl = type_or_decl, type = TREE_TYPE (decl); | |
989 else | |
990 decl = NULL, type = type_or_decl; | |
991 | |
992 mode = TYPE_MODE (type); | |
993 #ifdef PROMOTE_MODE | |
994 unsignedp = TYPE_UNSIGNED (type); | |
995 #endif | |
996 | |
997 if (mode == BLKmode || memory_required) | |
998 { | |
999 HOST_WIDE_INT size = int_size_in_bytes (type); | |
1000 rtx tmp; | |
1001 | |
1002 /* Zero sized arrays are GNU C extension. Set size to 1 to avoid | |
1003 problems with allocating the stack space. */ | |
1004 if (size == 0) | |
1005 size = 1; | |
1006 | |
1007 /* Unfortunately, we don't yet know how to allocate variable-sized | |
1008 temporaries. However, sometimes we can find a fixed upper limit on | |
1009 the size, so try that instead. */ | |
1010 else if (size == -1) | |
1011 size = max_int_size_in_bytes (type); | |
1012 | |
1013 /* The size of the temporary may be too large to fit into an integer. */ | |
1014 /* ??? Not sure this should happen except for user silliness, so limit | |
1015 this to things that aren't compiler-generated temporaries. The | |
1016 rest of the time we'll die in assign_stack_temp_for_type. */ | |
1017 if (decl && size == -1 | |
1018 && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST) | |
1019 { | |
1020 error ("size of variable %q+D is too large", decl); | |
1021 size = 1; | |
1022 } | |
1023 | |
1024 tmp = assign_stack_temp_for_type (mode, size, keep, type); | |
1025 return tmp; | |
1026 } | |
1027 | |
1028 #ifdef PROMOTE_MODE | |
1029 if (! dont_promote) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1030 mode = promote_mode (type, mode, &unsignedp); |
0 | 1031 #endif |
1032 | |
1033 return gen_reg_rtx (mode); | |
1034 } | |
1035 | |
1036 /* Combine temporary stack slots which are adjacent on the stack. | |
1037 | |
1038 This allows for better use of already allocated stack space. This is only | |
1039 done for BLKmode slots because we can be sure that we won't have alignment | |
1040 problems in this case. */ | |
1041 | |
1042 static void | |
1043 combine_temp_slots (void) | |
1044 { | |
1045 struct temp_slot *p, *q, *next, *next_q; | |
1046 int num_slots; | |
1047 | |
1048 /* We can't combine slots, because the information about which slot | |
1049 is in which alias set will be lost. */ | |
1050 if (flag_strict_aliasing) | |
1051 return; | |
1052 | |
1053 /* If there are a lot of temp slots, don't do anything unless | |
1054 high levels of optimization. */ | |
1055 if (! flag_expensive_optimizations) | |
1056 for (p = avail_temp_slots, num_slots = 0; p; p = p->next, num_slots++) | |
1057 if (num_slots > 100 || (num_slots > 10 && optimize == 0)) | |
1058 return; | |
1059 | |
1060 for (p = avail_temp_slots; p; p = next) | |
1061 { | |
1062 int delete_p = 0; | |
1063 | |
1064 next = p->next; | |
1065 | |
1066 if (GET_MODE (p->slot) != BLKmode) | |
1067 continue; | |
1068 | |
1069 for (q = p->next; q; q = next_q) | |
1070 { | |
1071 int delete_q = 0; | |
1072 | |
1073 next_q = q->next; | |
1074 | |
1075 if (GET_MODE (q->slot) != BLKmode) | |
1076 continue; | |
1077 | |
1078 if (p->base_offset + p->full_size == q->base_offset) | |
1079 { | |
1080 /* Q comes after P; combine Q into P. */ | |
1081 p->size += q->size; | |
1082 p->full_size += q->full_size; | |
1083 delete_q = 1; | |
1084 } | |
1085 else if (q->base_offset + q->full_size == p->base_offset) | |
1086 { | |
1087 /* P comes after Q; combine P into Q. */ | |
1088 q->size += p->size; | |
1089 q->full_size += p->full_size; | |
1090 delete_p = 1; | |
1091 break; | |
1092 } | |
1093 if (delete_q) | |
1094 cut_slot_from_list (q, &avail_temp_slots); | |
1095 } | |
1096 | |
1097 /* Either delete P or advance past it. */ | |
1098 if (delete_p) | |
1099 cut_slot_from_list (p, &avail_temp_slots); | |
1100 } | |
1101 } | |
1102 | |
1103 /* Indicate that NEW_RTX is an alternate way of referring to the temp | |
1104 slot that previously was known by OLD_RTX. */ | |
1105 | |
1106 void | |
1107 update_temp_slot_address (rtx old_rtx, rtx new_rtx) | |
1108 { | |
1109 struct temp_slot *p; | |
1110 | |
1111 if (rtx_equal_p (old_rtx, new_rtx)) | |
1112 return; | |
1113 | |
1114 p = find_temp_slot_from_address (old_rtx); | |
1115 | |
1116 /* If we didn't find one, see if both OLD_RTX is a PLUS. If so, and | |
1117 NEW_RTX is a register, see if one operand of the PLUS is a | |
1118 temporary location. If so, NEW_RTX points into it. Otherwise, | |
1119 if both OLD_RTX and NEW_RTX are a PLUS and if there is a register | |
1120 in common between them. If so, try a recursive call on those | |
1121 values. */ | |
1122 if (p == 0) | |
1123 { | |
1124 if (GET_CODE (old_rtx) != PLUS) | |
1125 return; | |
1126 | |
1127 if (REG_P (new_rtx)) | |
1128 { | |
1129 update_temp_slot_address (XEXP (old_rtx, 0), new_rtx); | |
1130 update_temp_slot_address (XEXP (old_rtx, 1), new_rtx); | |
1131 return; | |
1132 } | |
1133 else if (GET_CODE (new_rtx) != PLUS) | |
1134 return; | |
1135 | |
1136 if (rtx_equal_p (XEXP (old_rtx, 0), XEXP (new_rtx, 0))) | |
1137 update_temp_slot_address (XEXP (old_rtx, 1), XEXP (new_rtx, 1)); | |
1138 else if (rtx_equal_p (XEXP (old_rtx, 1), XEXP (new_rtx, 0))) | |
1139 update_temp_slot_address (XEXP (old_rtx, 0), XEXP (new_rtx, 1)); | |
1140 else if (rtx_equal_p (XEXP (old_rtx, 0), XEXP (new_rtx, 1))) | |
1141 update_temp_slot_address (XEXP (old_rtx, 1), XEXP (new_rtx, 0)); | |
1142 else if (rtx_equal_p (XEXP (old_rtx, 1), XEXP (new_rtx, 1))) | |
1143 update_temp_slot_address (XEXP (old_rtx, 0), XEXP (new_rtx, 0)); | |
1144 | |
1145 return; | |
1146 } | |
1147 | |
1148 /* Otherwise add an alias for the temp's address. */ | |
1149 insert_temp_slot_address (new_rtx, p); | |
1150 } | |
1151 | |
1152 /* If X could be a reference to a temporary slot, mark the fact that its | |
1153 address was taken. */ | |
1154 | |
1155 void | |
1156 mark_temp_addr_taken (rtx x) | |
1157 { | |
1158 struct temp_slot *p; | |
1159 | |
1160 if (x == 0) | |
1161 return; | |
1162 | |
1163 /* If X is not in memory or is at a constant address, it cannot be in | |
1164 a temporary slot. */ | |
1165 if (!MEM_P (x) || CONSTANT_P (XEXP (x, 0))) | |
1166 return; | |
1167 | |
1168 p = find_temp_slot_from_address (XEXP (x, 0)); | |
1169 if (p != 0) | |
1170 p->addr_taken = 1; | |
1171 } | |
1172 | |
1173 /* If X could be a reference to a temporary slot, mark that slot as | |
1174 belonging to the to one level higher than the current level. If X | |
1175 matched one of our slots, just mark that one. Otherwise, we can't | |
1176 easily predict which it is, so upgrade all of them. Kept slots | |
1177 need not be touched. | |
1178 | |
1179 This is called when an ({...}) construct occurs and a statement | |
1180 returns a value in memory. */ | |
1181 | |
1182 void | |
1183 preserve_temp_slots (rtx x) | |
1184 { | |
1185 struct temp_slot *p = 0, *next; | |
1186 | |
1187 /* If there is no result, we still might have some objects whose address | |
1188 were taken, so we need to make sure they stay around. */ | |
1189 if (x == 0) | |
1190 { | |
1191 for (p = *temp_slots_at_level (temp_slot_level); p; p = next) | |
1192 { | |
1193 next = p->next; | |
1194 | |
1195 if (p->addr_taken) | |
1196 move_slot_to_level (p, temp_slot_level - 1); | |
1197 } | |
1198 | |
1199 return; | |
1200 } | |
1201 | |
1202 /* If X is a register that is being used as a pointer, see if we have | |
1203 a temporary slot we know it points to. To be consistent with | |
1204 the code below, we really should preserve all non-kept slots | |
1205 if we can't find a match, but that seems to be much too costly. */ | |
1206 if (REG_P (x) && REG_POINTER (x)) | |
1207 p = find_temp_slot_from_address (x); | |
1208 | |
1209 /* If X is not in memory or is at a constant address, it cannot be in | |
1210 a temporary slot, but it can contain something whose address was | |
1211 taken. */ | |
1212 if (p == 0 && (!MEM_P (x) || CONSTANT_P (XEXP (x, 0)))) | |
1213 { | |
1214 for (p = *temp_slots_at_level (temp_slot_level); p; p = next) | |
1215 { | |
1216 next = p->next; | |
1217 | |
1218 if (p->addr_taken) | |
1219 move_slot_to_level (p, temp_slot_level - 1); | |
1220 } | |
1221 | |
1222 return; | |
1223 } | |
1224 | |
1225 /* First see if we can find a match. */ | |
1226 if (p == 0) | |
1227 p = find_temp_slot_from_address (XEXP (x, 0)); | |
1228 | |
1229 if (p != 0) | |
1230 { | |
1231 /* Move everything at our level whose address was taken to our new | |
1232 level in case we used its address. */ | |
1233 struct temp_slot *q; | |
1234 | |
1235 if (p->level == temp_slot_level) | |
1236 { | |
1237 for (q = *temp_slots_at_level (temp_slot_level); q; q = next) | |
1238 { | |
1239 next = q->next; | |
1240 | |
1241 if (p != q && q->addr_taken) | |
1242 move_slot_to_level (q, temp_slot_level - 1); | |
1243 } | |
1244 | |
1245 move_slot_to_level (p, temp_slot_level - 1); | |
1246 p->addr_taken = 0; | |
1247 } | |
1248 return; | |
1249 } | |
1250 | |
1251 /* Otherwise, preserve all non-kept slots at this level. */ | |
1252 for (p = *temp_slots_at_level (temp_slot_level); p; p = next) | |
1253 { | |
1254 next = p->next; | |
1255 | |
1256 if (!p->keep) | |
1257 move_slot_to_level (p, temp_slot_level - 1); | |
1258 } | |
1259 } | |
1260 | |
1261 /* Free all temporaries used so far. This is normally called at the | |
1262 end of generating code for a statement. */ | |
1263 | |
1264 void | |
1265 free_temp_slots (void) | |
1266 { | |
1267 struct temp_slot *p, *next; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1268 bool some_available = false; |
0 | 1269 |
1270 for (p = *temp_slots_at_level (temp_slot_level); p; p = next) | |
1271 { | |
1272 next = p->next; | |
1273 | |
1274 if (!p->keep) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1275 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1276 make_slot_available (p); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1277 some_available = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1278 } |
0 | 1279 } |
1280 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1281 if (some_available) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1282 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1283 remove_unused_temp_slot_addresses (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1284 combine_temp_slots (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1285 } |
0 | 1286 } |
1287 | |
1288 /* Push deeper into the nesting level for stack temporaries. */ | |
1289 | |
1290 void | |
1291 push_temp_slots (void) | |
1292 { | |
1293 temp_slot_level++; | |
1294 } | |
1295 | |
1296 /* Pop a temporary nesting level. All slots in use in the current level | |
1297 are freed. */ | |
1298 | |
1299 void | |
1300 pop_temp_slots (void) | |
1301 { | |
1302 struct temp_slot *p, *next; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1303 bool some_available = false; |
0 | 1304 |
1305 for (p = *temp_slots_at_level (temp_slot_level); p; p = next) | |
1306 { | |
1307 next = p->next; | |
1308 make_slot_available (p); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1309 some_available = true; |
0 | 1310 } |
1311 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1312 if (some_available) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1313 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1314 remove_unused_temp_slot_addresses (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1315 combine_temp_slots (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1316 } |
0 | 1317 |
1318 temp_slot_level--; | |
1319 } | |
1320 | |
1321 /* Initialize temporary slots. */ | |
1322 | |
1323 void | |
1324 init_temp_slots (void) | |
1325 { | |
1326 /* We have not allocated any temporaries yet. */ | |
1327 avail_temp_slots = 0; | |
1328 used_temp_slots = 0; | |
1329 temp_slot_level = 0; | |
1330 | |
1331 /* Set up the table to map addresses to temp slots. */ | |
1332 if (! temp_slot_address_table) | |
1333 temp_slot_address_table = htab_create_ggc (32, | |
1334 temp_slot_address_hash, | |
1335 temp_slot_address_eq, | |
1336 NULL); | |
1337 else | |
1338 htab_empty (temp_slot_address_table); | |
1339 } | |
1340 | |
1341 /* These routines are responsible for converting virtual register references | |
1342 to the actual hard register references once RTL generation is complete. | |
1343 | |
1344 The following four variables are used for communication between the | |
1345 routines. They contain the offsets of the virtual registers from their | |
1346 respective hard registers. */ | |
1347 | |
1348 static int in_arg_offset; | |
1349 static int var_offset; | |
1350 static int dynamic_offset; | |
1351 static int out_arg_offset; | |
1352 static int cfa_offset; | |
1353 | |
1354 /* In most machines, the stack pointer register is equivalent to the bottom | |
1355 of the stack. */ | |
1356 | |
1357 #ifndef STACK_POINTER_OFFSET | |
1358 #define STACK_POINTER_OFFSET 0 | |
1359 #endif | |
1360 | |
1361 /* If not defined, pick an appropriate default for the offset of dynamically | |
1362 allocated memory depending on the value of ACCUMULATE_OUTGOING_ARGS, | |
1363 REG_PARM_STACK_SPACE, and OUTGOING_REG_PARM_STACK_SPACE. */ | |
1364 | |
1365 #ifndef STACK_DYNAMIC_OFFSET | |
1366 | |
1367 /* The bottom of the stack points to the actual arguments. If | |
1368 REG_PARM_STACK_SPACE is defined, this includes the space for the register | |
1369 parameters. However, if OUTGOING_REG_PARM_STACK space is not defined, | |
1370 stack space for register parameters is not pushed by the caller, but | |
1371 rather part of the fixed stack areas and hence not included in | |
1372 `crtl->outgoing_args_size'. Nevertheless, we must allow | |
1373 for it when allocating stack dynamic objects. */ | |
1374 | |
1375 #if defined(REG_PARM_STACK_SPACE) | |
1376 #define STACK_DYNAMIC_OFFSET(FNDECL) \ | |
1377 ((ACCUMULATE_OUTGOING_ARGS \ | |
1378 ? (crtl->outgoing_args_size \ | |
1379 + (OUTGOING_REG_PARM_STACK_SPACE ((!(FNDECL) ? NULL_TREE : TREE_TYPE (FNDECL))) ? 0 \ | |
1380 : REG_PARM_STACK_SPACE (FNDECL))) \ | |
1381 : 0) + (STACK_POINTER_OFFSET)) | |
1382 #else | |
1383 #define STACK_DYNAMIC_OFFSET(FNDECL) \ | |
1384 ((ACCUMULATE_OUTGOING_ARGS ? crtl->outgoing_args_size : 0) \ | |
1385 + (STACK_POINTER_OFFSET)) | |
1386 #endif | |
1387 #endif | |
1388 | |
1389 | |
1390 /* Given a piece of RTX and a pointer to a HOST_WIDE_INT, if the RTX | |
1391 is a virtual register, return the equivalent hard register and set the | |
1392 offset indirectly through the pointer. Otherwise, return 0. */ | |
1393 | |
1394 static rtx | |
1395 instantiate_new_reg (rtx x, HOST_WIDE_INT *poffset) | |
1396 { | |
1397 rtx new_rtx; | |
1398 HOST_WIDE_INT offset; | |
1399 | |
1400 if (x == virtual_incoming_args_rtx) | |
1401 { | |
1402 if (stack_realign_drap) | |
1403 { | |
1404 /* Replace virtual_incoming_args_rtx with internal arg | |
1405 pointer if DRAP is used to realign stack. */ | |
1406 new_rtx = crtl->args.internal_arg_pointer; | |
1407 offset = 0; | |
1408 } | |
1409 else | |
1410 new_rtx = arg_pointer_rtx, offset = in_arg_offset; | |
1411 } | |
1412 else if (x == virtual_stack_vars_rtx) | |
1413 new_rtx = frame_pointer_rtx, offset = var_offset; | |
1414 else if (x == virtual_stack_dynamic_rtx) | |
1415 new_rtx = stack_pointer_rtx, offset = dynamic_offset; | |
1416 else if (x == virtual_outgoing_args_rtx) | |
1417 new_rtx = stack_pointer_rtx, offset = out_arg_offset; | |
1418 else if (x == virtual_cfa_rtx) | |
1419 { | |
1420 #ifdef FRAME_POINTER_CFA_OFFSET | |
1421 new_rtx = frame_pointer_rtx; | |
1422 #else | |
1423 new_rtx = arg_pointer_rtx; | |
1424 #endif | |
1425 offset = cfa_offset; | |
1426 } | |
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
|
1427 else if (x == virtual_preferred_stack_boundary_rtx) |
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
|
1428 { |
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
|
1429 new_rtx = GEN_INT (crtl->preferred_stack_boundary / BITS_PER_UNIT); |
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
|
1430 offset = 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
|
1431 } |
0 | 1432 else |
1433 return NULL_RTX; | |
1434 | |
1435 *poffset = offset; | |
1436 return new_rtx; | |
1437 } | |
1438 | |
1439 /* A subroutine of instantiate_virtual_regs, called via for_each_rtx. | |
1440 Instantiate any virtual registers present inside of *LOC. The expression | |
1441 is simplified, as much as possible, but is not to be considered "valid" | |
1442 in any sense implied by the target. If any change is made, set CHANGED | |
1443 to true. */ | |
1444 | |
1445 static int | |
1446 instantiate_virtual_regs_in_rtx (rtx *loc, void *data) | |
1447 { | |
1448 HOST_WIDE_INT offset; | |
1449 bool *changed = (bool *) data; | |
1450 rtx x, new_rtx; | |
1451 | |
1452 x = *loc; | |
1453 if (x == 0) | |
1454 return 0; | |
1455 | |
1456 switch (GET_CODE (x)) | |
1457 { | |
1458 case REG: | |
1459 new_rtx = instantiate_new_reg (x, &offset); | |
1460 if (new_rtx) | |
1461 { | |
1462 *loc = plus_constant (new_rtx, offset); | |
1463 if (changed) | |
1464 *changed = true; | |
1465 } | |
1466 return -1; | |
1467 | |
1468 case PLUS: | |
1469 new_rtx = instantiate_new_reg (XEXP (x, 0), &offset); | |
1470 if (new_rtx) | |
1471 { | |
1472 new_rtx = plus_constant (new_rtx, offset); | |
1473 *loc = simplify_gen_binary (PLUS, GET_MODE (x), new_rtx, XEXP (x, 1)); | |
1474 if (changed) | |
1475 *changed = true; | |
1476 return -1; | |
1477 } | |
1478 | |
1479 /* FIXME -- from old code */ | |
1480 /* If we have (plus (subreg (virtual-reg)) (const_int)), we know | |
1481 we can commute the PLUS and SUBREG because pointers into the | |
1482 frame are well-behaved. */ | |
1483 break; | |
1484 | |
1485 default: | |
1486 break; | |
1487 } | |
1488 | |
1489 return 0; | |
1490 } | |
1491 | |
1492 /* A subroutine of instantiate_virtual_regs_in_insn. Return true if X | |
1493 matches the predicate for insn CODE operand OPERAND. */ | |
1494 | |
1495 static int | |
1496 safe_insn_predicate (int code, int operand, rtx x) | |
1497 { | |
1498 const struct insn_operand_data *op_data; | |
1499 | |
1500 if (code < 0) | |
1501 return true; | |
1502 | |
1503 op_data = &insn_data[code].operand[operand]; | |
1504 if (op_data->predicate == NULL) | |
1505 return true; | |
1506 | |
1507 return op_data->predicate (x, op_data->mode); | |
1508 } | |
1509 | |
1510 /* A subroutine of instantiate_virtual_regs. Instantiate any virtual | |
1511 registers present inside of insn. The result will be a valid insn. */ | |
1512 | |
1513 static void | |
1514 instantiate_virtual_regs_in_insn (rtx insn) | |
1515 { | |
1516 HOST_WIDE_INT offset; | |
1517 int insn_code, i; | |
1518 bool any_change = false; | |
1519 rtx set, new_rtx, x, seq; | |
1520 | |
1521 /* There are some special cases to be handled first. */ | |
1522 set = single_set (insn); | |
1523 if (set) | |
1524 { | |
1525 /* We're allowed to assign to a virtual register. This is interpreted | |
1526 to mean that the underlying register gets assigned the inverse | |
1527 transformation. This is used, for example, in the handling of | |
1528 non-local gotos. */ | |
1529 new_rtx = instantiate_new_reg (SET_DEST (set), &offset); | |
1530 if (new_rtx) | |
1531 { | |
1532 start_sequence (); | |
1533 | |
1534 for_each_rtx (&SET_SRC (set), instantiate_virtual_regs_in_rtx, NULL); | |
1535 x = simplify_gen_binary (PLUS, GET_MODE (new_rtx), SET_SRC (set), | |
1536 GEN_INT (-offset)); | |
1537 x = force_operand (x, new_rtx); | |
1538 if (x != new_rtx) | |
1539 emit_move_insn (new_rtx, x); | |
1540 | |
1541 seq = get_insns (); | |
1542 end_sequence (); | |
1543 | |
1544 emit_insn_before (seq, insn); | |
1545 delete_insn (insn); | |
1546 return; | |
1547 } | |
1548 | |
1549 /* Handle a straight copy from a virtual register by generating a | |
1550 new add insn. The difference between this and falling through | |
1551 to the generic case is avoiding a new pseudo and eliminating a | |
1552 move insn in the initial rtl stream. */ | |
1553 new_rtx = instantiate_new_reg (SET_SRC (set), &offset); | |
1554 if (new_rtx && offset != 0 | |
1555 && REG_P (SET_DEST (set)) | |
1556 && REGNO (SET_DEST (set)) > LAST_VIRTUAL_REGISTER) | |
1557 { | |
1558 start_sequence (); | |
1559 | |
1560 x = expand_simple_binop (GET_MODE (SET_DEST (set)), PLUS, | |
1561 new_rtx, GEN_INT (offset), SET_DEST (set), | |
1562 1, OPTAB_LIB_WIDEN); | |
1563 if (x != SET_DEST (set)) | |
1564 emit_move_insn (SET_DEST (set), x); | |
1565 | |
1566 seq = get_insns (); | |
1567 end_sequence (); | |
1568 | |
1569 emit_insn_before (seq, insn); | |
1570 delete_insn (insn); | |
1571 return; | |
1572 } | |
1573 | |
1574 extract_insn (insn); | |
1575 insn_code = INSN_CODE (insn); | |
1576 | |
1577 /* Handle a plus involving a virtual register by determining if the | |
1578 operands remain valid if they're modified in place. */ | |
1579 if (GET_CODE (SET_SRC (set)) == PLUS | |
1580 && recog_data.n_operands >= 3 | |
1581 && recog_data.operand_loc[1] == &XEXP (SET_SRC (set), 0) | |
1582 && recog_data.operand_loc[2] == &XEXP (SET_SRC (set), 1) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1583 && CONST_INT_P (recog_data.operand[2]) |
0 | 1584 && (new_rtx = instantiate_new_reg (recog_data.operand[1], &offset))) |
1585 { | |
1586 offset += INTVAL (recog_data.operand[2]); | |
1587 | |
1588 /* If the sum is zero, then replace with a plain move. */ | |
1589 if (offset == 0 | |
1590 && REG_P (SET_DEST (set)) | |
1591 && REGNO (SET_DEST (set)) > LAST_VIRTUAL_REGISTER) | |
1592 { | |
1593 start_sequence (); | |
1594 emit_move_insn (SET_DEST (set), new_rtx); | |
1595 seq = get_insns (); | |
1596 end_sequence (); | |
1597 | |
1598 emit_insn_before (seq, insn); | |
1599 delete_insn (insn); | |
1600 return; | |
1601 } | |
1602 | |
1603 x = gen_int_mode (offset, recog_data.operand_mode[2]); | |
1604 | |
1605 /* Using validate_change and apply_change_group here leaves | |
1606 recog_data in an invalid state. Since we know exactly what | |
1607 we want to check, do those two by hand. */ | |
1608 if (safe_insn_predicate (insn_code, 1, new_rtx) | |
1609 && safe_insn_predicate (insn_code, 2, x)) | |
1610 { | |
1611 *recog_data.operand_loc[1] = recog_data.operand[1] = new_rtx; | |
1612 *recog_data.operand_loc[2] = recog_data.operand[2] = x; | |
1613 any_change = true; | |
1614 | |
1615 /* Fall through into the regular operand fixup loop in | |
1616 order to take care of operands other than 1 and 2. */ | |
1617 } | |
1618 } | |
1619 } | |
1620 else | |
1621 { | |
1622 extract_insn (insn); | |
1623 insn_code = INSN_CODE (insn); | |
1624 } | |
1625 | |
1626 /* In the general case, we expect virtual registers to appear only in | |
1627 operands, and then only as either bare registers or inside memories. */ | |
1628 for (i = 0; i < recog_data.n_operands; ++i) | |
1629 { | |
1630 x = recog_data.operand[i]; | |
1631 switch (GET_CODE (x)) | |
1632 { | |
1633 case MEM: | |
1634 { | |
1635 rtx addr = XEXP (x, 0); | |
1636 bool changed = false; | |
1637 | |
1638 for_each_rtx (&addr, instantiate_virtual_regs_in_rtx, &changed); | |
1639 if (!changed) | |
1640 continue; | |
1641 | |
1642 start_sequence (); | |
1643 x = replace_equiv_address (x, addr); | |
1644 /* It may happen that the address with the virtual reg | |
1645 was valid (e.g. based on the virtual stack reg, which might | |
1646 be acceptable to the predicates with all offsets), whereas | |
1647 the address now isn't anymore, for instance when the address | |
1648 is still offsetted, but the base reg isn't virtual-stack-reg | |
1649 anymore. Below we would do a force_reg on the whole operand, | |
1650 but this insn might actually only accept memory. Hence, | |
1651 before doing that last resort, try to reload the address into | |
1652 a register, so this operand stays a MEM. */ | |
1653 if (!safe_insn_predicate (insn_code, i, x)) | |
1654 { | |
1655 addr = force_reg (GET_MODE (addr), addr); | |
1656 x = replace_equiv_address (x, addr); | |
1657 } | |
1658 seq = get_insns (); | |
1659 end_sequence (); | |
1660 if (seq) | |
1661 emit_insn_before (seq, insn); | |
1662 } | |
1663 break; | |
1664 | |
1665 case REG: | |
1666 new_rtx = instantiate_new_reg (x, &offset); | |
1667 if (new_rtx == NULL) | |
1668 continue; | |
1669 if (offset == 0) | |
1670 x = new_rtx; | |
1671 else | |
1672 { | |
1673 start_sequence (); | |
1674 | |
1675 /* Careful, special mode predicates may have stuff in | |
1676 insn_data[insn_code].operand[i].mode that isn't useful | |
1677 to us for computing a new value. */ | |
1678 /* ??? Recognize address_operand and/or "p" constraints | |
1679 to see if (plus new offset) is a valid before we put | |
1680 this through expand_simple_binop. */ | |
1681 x = expand_simple_binop (GET_MODE (x), PLUS, new_rtx, | |
1682 GEN_INT (offset), NULL_RTX, | |
1683 1, OPTAB_LIB_WIDEN); | |
1684 seq = get_insns (); | |
1685 end_sequence (); | |
1686 emit_insn_before (seq, insn); | |
1687 } | |
1688 break; | |
1689 | |
1690 case SUBREG: | |
1691 new_rtx = instantiate_new_reg (SUBREG_REG (x), &offset); | |
1692 if (new_rtx == NULL) | |
1693 continue; | |
1694 if (offset != 0) | |
1695 { | |
1696 start_sequence (); | |
1697 new_rtx = expand_simple_binop (GET_MODE (new_rtx), PLUS, new_rtx, | |
1698 GEN_INT (offset), NULL_RTX, | |
1699 1, OPTAB_LIB_WIDEN); | |
1700 seq = get_insns (); | |
1701 end_sequence (); | |
1702 emit_insn_before (seq, insn); | |
1703 } | |
1704 x = simplify_gen_subreg (recog_data.operand_mode[i], new_rtx, | |
1705 GET_MODE (new_rtx), SUBREG_BYTE (x)); | |
1706 gcc_assert (x); | |
1707 break; | |
1708 | |
1709 default: | |
1710 continue; | |
1711 } | |
1712 | |
1713 /* At this point, X contains the new value for the operand. | |
1714 Validate the new value vs the insn predicate. Note that | |
1715 asm insns will have insn_code -1 here. */ | |
1716 if (!safe_insn_predicate (insn_code, i, x)) | |
1717 { | |
1718 start_sequence (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1719 if (REG_P (x)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1720 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1721 gcc_assert (REGNO (x) <= LAST_VIRTUAL_REGISTER); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1722 x = copy_to_reg (x); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1723 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1724 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1725 x = force_reg (insn_data[insn_code].operand[i].mode, x); |
0 | 1726 seq = get_insns (); |
1727 end_sequence (); | |
1728 if (seq) | |
1729 emit_insn_before (seq, insn); | |
1730 } | |
1731 | |
1732 *recog_data.operand_loc[i] = recog_data.operand[i] = x; | |
1733 any_change = true; | |
1734 } | |
1735 | |
1736 if (any_change) | |
1737 { | |
1738 /* Propagate operand changes into the duplicates. */ | |
1739 for (i = 0; i < recog_data.n_dups; ++i) | |
1740 *recog_data.dup_loc[i] | |
1741 = copy_rtx (recog_data.operand[(unsigned)recog_data.dup_num[i]]); | |
1742 | |
1743 /* Force re-recognition of the instruction for validation. */ | |
1744 INSN_CODE (insn) = -1; | |
1745 } | |
1746 | |
1747 if (asm_noperands (PATTERN (insn)) >= 0) | |
1748 { | |
1749 if (!check_asm_operands (PATTERN (insn))) | |
1750 { | |
1751 error_for_asm (insn, "impossible constraint in %<asm%>"); | |
1752 delete_insn (insn); | |
1753 } | |
1754 } | |
1755 else | |
1756 { | |
1757 if (recog_memoized (insn) < 0) | |
1758 fatal_insn_not_found (insn); | |
1759 } | |
1760 } | |
1761 | |
1762 /* Subroutine of instantiate_decls. Given RTL representing a decl, | |
1763 do any instantiation required. */ | |
1764 | |
1765 void | |
1766 instantiate_decl_rtl (rtx x) | |
1767 { | |
1768 rtx addr; | |
1769 | |
1770 if (x == 0) | |
1771 return; | |
1772 | |
1773 /* If this is a CONCAT, recurse for the pieces. */ | |
1774 if (GET_CODE (x) == CONCAT) | |
1775 { | |
1776 instantiate_decl_rtl (XEXP (x, 0)); | |
1777 instantiate_decl_rtl (XEXP (x, 1)); | |
1778 return; | |
1779 } | |
1780 | |
1781 /* If this is not a MEM, no need to do anything. Similarly if the | |
1782 address is a constant or a register that is not a virtual register. */ | |
1783 if (!MEM_P (x)) | |
1784 return; | |
1785 | |
1786 addr = XEXP (x, 0); | |
1787 if (CONSTANT_P (addr) | |
1788 || (REG_P (addr) | |
1789 && (REGNO (addr) < FIRST_VIRTUAL_REGISTER | |
1790 || REGNO (addr) > LAST_VIRTUAL_REGISTER))) | |
1791 return; | |
1792 | |
1793 for_each_rtx (&XEXP (x, 0), instantiate_virtual_regs_in_rtx, NULL); | |
1794 } | |
1795 | |
1796 /* Helper for instantiate_decls called via walk_tree: Process all decls | |
1797 in the given DECL_VALUE_EXPR. */ | |
1798 | |
1799 static tree | |
1800 instantiate_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) | |
1801 { | |
1802 tree t = *tp; | |
1803 if (! EXPR_P (t)) | |
1804 { | |
1805 *walk_subtrees = 0; | |
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
|
1806 if (DECL_P (t)) |
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
|
1807 { |
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
|
1808 if (DECL_RTL_SET_P (t)) |
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
|
1809 instantiate_decl_rtl (DECL_RTL (t)); |
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
|
1810 if (TREE_CODE (t) == PARM_DECL && DECL_NAMELESS (t) |
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
|
1811 && DECL_INCOMING_RTL (t)) |
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
|
1812 instantiate_decl_rtl (DECL_INCOMING_RTL (t)); |
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
|
1813 if ((TREE_CODE (t) == VAR_DECL |
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
|
1814 || TREE_CODE (t) == RESULT_DECL) |
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
|
1815 && DECL_HAS_VALUE_EXPR_P (t)) |
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
|
1816 { |
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
|
1817 tree v = DECL_VALUE_EXPR (t); |
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
|
1818 walk_tree (&v, instantiate_expr, NULL, NULL); |
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
|
1819 } |
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
|
1820 } |
0 | 1821 } |
1822 return NULL; | |
1823 } | |
1824 | |
1825 /* Subroutine of instantiate_decls: Process all decls in the given | |
1826 BLOCK node and all its subblocks. */ | |
1827 | |
1828 static void | |
1829 instantiate_decls_1 (tree let) | |
1830 { | |
1831 tree t; | |
1832 | |
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
|
1833 for (t = BLOCK_VARS (let); t; t = DECL_CHAIN (t)) |
0 | 1834 { |
1835 if (DECL_RTL_SET_P (t)) | |
1836 instantiate_decl_rtl (DECL_RTL (t)); | |
1837 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)) | |
1838 { | |
1839 tree v = DECL_VALUE_EXPR (t); | |
1840 walk_tree (&v, instantiate_expr, NULL, NULL); | |
1841 } | |
1842 } | |
1843 | |
1844 /* Process all subblocks. */ | |
1845 for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t)) | |
1846 instantiate_decls_1 (t); | |
1847 } | |
1848 | |
1849 /* Scan all decls in FNDECL (both variables and parameters) and instantiate | |
1850 all virtual registers in their DECL_RTL's. */ | |
1851 | |
1852 static void | |
1853 instantiate_decls (tree fndecl) | |
1854 { | |
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
|
1855 tree decl; |
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
|
1856 unsigned ix; |
0 | 1857 |
1858 /* Process all parameters of the function. */ | |
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
|
1859 for (decl = DECL_ARGUMENTS (fndecl); decl; decl = DECL_CHAIN (decl)) |
0 | 1860 { |
1861 instantiate_decl_rtl (DECL_RTL (decl)); | |
1862 instantiate_decl_rtl (DECL_INCOMING_RTL (decl)); | |
1863 if (DECL_HAS_VALUE_EXPR_P (decl)) | |
1864 { | |
1865 tree v = DECL_VALUE_EXPR (decl); | |
1866 walk_tree (&v, instantiate_expr, NULL, NULL); | |
1867 } | |
1868 } | |
1869 | |
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
|
1870 if ((decl = DECL_RESULT (fndecl)) |
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
|
1871 && TREE_CODE (decl) == RESULT_DECL) |
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
|
1872 { |
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
|
1873 if (DECL_RTL_SET_P (decl)) |
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
|
1874 instantiate_decl_rtl (DECL_RTL (decl)); |
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
|
1875 if (DECL_HAS_VALUE_EXPR_P (decl)) |
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
|
1876 { |
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
|
1877 tree v = DECL_VALUE_EXPR (decl); |
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
|
1878 walk_tree (&v, instantiate_expr, NULL, NULL); |
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
|
1879 } |
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
|
1880 } |
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
|
1881 |
0 | 1882 /* Now process all variables defined in the function or its subblocks. */ |
1883 instantiate_decls_1 (DECL_INITIAL (fndecl)); | |
1884 | |
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
|
1885 FOR_EACH_LOCAL_DECL (cfun, ix, decl) |
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
|
1886 if (DECL_RTL_SET_P (decl)) |
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
|
1887 instantiate_decl_rtl (DECL_RTL (decl)); |
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
|
1888 VEC_free (tree, gc, cfun->local_decls); |
0 | 1889 } |
1890 | |
1891 /* Pass through the INSNS of function FNDECL and convert virtual register | |
1892 references to hard register references. */ | |
1893 | |
1894 static unsigned int | |
1895 instantiate_virtual_regs (void) | |
1896 { | |
1897 rtx insn; | |
1898 | |
1899 /* Compute the offsets to use for this function. */ | |
1900 in_arg_offset = FIRST_PARM_OFFSET (current_function_decl); | |
1901 var_offset = STARTING_FRAME_OFFSET; | |
1902 dynamic_offset = STACK_DYNAMIC_OFFSET (current_function_decl); | |
1903 out_arg_offset = STACK_POINTER_OFFSET; | |
1904 #ifdef FRAME_POINTER_CFA_OFFSET | |
1905 cfa_offset = FRAME_POINTER_CFA_OFFSET (current_function_decl); | |
1906 #else | |
1907 cfa_offset = ARG_POINTER_CFA_OFFSET (current_function_decl); | |
1908 #endif | |
1909 | |
1910 /* Initialize recognition, indicating that volatile is OK. */ | |
1911 init_recog (); | |
1912 | |
1913 /* Scan through all the insns, instantiating every virtual register still | |
1914 present. */ | |
1915 for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) | |
1916 if (INSN_P (insn)) | |
1917 { | |
1918 /* These patterns in the instruction stream can never be recognized. | |
1919 Fortunately, they shouldn't contain virtual registers either. */ | |
1920 if (GET_CODE (PATTERN (insn)) == USE | |
1921 || GET_CODE (PATTERN (insn)) == CLOBBER | |
1922 || GET_CODE (PATTERN (insn)) == ADDR_VEC | |
1923 || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC | |
1924 || GET_CODE (PATTERN (insn)) == ASM_INPUT) | |
1925 continue; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1926 else if (DEBUG_INSN_P (insn)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1927 for_each_rtx (&INSN_VAR_LOCATION (insn), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1928 instantiate_virtual_regs_in_rtx, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1929 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1930 instantiate_virtual_regs_in_insn (insn); |
0 | 1931 |
1932 if (INSN_DELETED_P (insn)) | |
1933 continue; | |
1934 | |
1935 for_each_rtx (®_NOTES (insn), instantiate_virtual_regs_in_rtx, NULL); | |
1936 | |
1937 /* Instantiate any virtual registers in CALL_INSN_FUNCTION_USAGE. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1938 if (CALL_P (insn)) |
0 | 1939 for_each_rtx (&CALL_INSN_FUNCTION_USAGE (insn), |
1940 instantiate_virtual_regs_in_rtx, NULL); | |
1941 } | |
1942 | |
1943 /* Instantiate the virtual registers in the DECLs for debugging purposes. */ | |
1944 instantiate_decls (current_function_decl); | |
1945 | |
1946 targetm.instantiate_decls (); | |
1947 | |
1948 /* Indicate that, from now on, assign_stack_local should use | |
1949 frame_pointer_rtx. */ | |
1950 virtuals_instantiated = 1; | |
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
|
1951 |
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
|
1952 /* See allocate_dynamic_stack_space for the rationale. */ |
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
|
1953 #ifdef SETJMP_VIA_SAVE_AREA |
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
|
1954 if (flag_stack_usage && cfun->calls_setjmp) |
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
|
1955 { |
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
|
1956 int align = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT; |
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
|
1957 dynamic_offset = (dynamic_offset + align - 1) / align * align; |
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
|
1958 current_function_dynamic_stack_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
|
1959 += current_function_dynamic_alloc_count * dynamic_offset; |
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
|
1960 } |
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
|
1961 #endif |
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
|
1962 |
0 | 1963 return 0; |
1964 } | |
1965 | |
1966 struct rtl_opt_pass pass_instantiate_virtual_regs = | |
1967 { | |
1968 { | |
1969 RTL_PASS, | |
1970 "vregs", /* name */ | |
1971 NULL, /* gate */ | |
1972 instantiate_virtual_regs, /* execute */ | |
1973 NULL, /* sub */ | |
1974 NULL, /* next */ | |
1975 0, /* static_pass_number */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
1976 TV_NONE, /* tv_id */ |
0 | 1977 0, /* properties_required */ |
1978 0, /* properties_provided */ | |
1979 0, /* properties_destroyed */ | |
1980 0, /* todo_flags_start */ | |
1981 TODO_dump_func /* todo_flags_finish */ | |
1982 } | |
1983 }; | |
1984 | |
1985 | |
1986 /* Return 1 if EXP is an aggregate type (or a value with aggregate type). | |
1987 This means a type for which function calls must pass an address to the | |
1988 function or get an address back from the function. | |
1989 EXP may be a type node or an expression (whose type is tested). */ | |
1990 | |
1991 int | |
1992 aggregate_value_p (const_tree exp, const_tree fntype) | |
1993 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1994 const_tree type = (TYPE_P (exp)) ? exp : TREE_TYPE (exp); |
0 | 1995 int i, regno, nregs; |
1996 rtx reg; | |
1997 | |
1998 if (fntype) | |
1999 switch (TREE_CODE (fntype)) | |
2000 { | |
2001 case CALL_EXPR: | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2002 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2003 tree fndecl = get_callee_fndecl (fntype); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2004 fntype = (fndecl |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2005 ? TREE_TYPE (fndecl) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2006 : TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (fntype)))); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2007 } |
0 | 2008 break; |
2009 case FUNCTION_DECL: | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2010 fntype = TREE_TYPE (fntype); |
0 | 2011 break; |
2012 case FUNCTION_TYPE: | |
2013 case METHOD_TYPE: | |
2014 break; | |
2015 case IDENTIFIER_NODE: | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2016 fntype = NULL_TREE; |
0 | 2017 break; |
2018 default: | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2019 /* We don't expect other tree types here. */ |
0 | 2020 gcc_unreachable (); |
2021 } | |
2022 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2023 if (VOID_TYPE_P (type)) |
0 | 2024 return 0; |
2025 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2026 /* If a record should be passed the same as its first (and only) member |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2027 don't pass it as an aggregate. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2028 if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2029 return aggregate_value_p (first_field (type), fntype); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2030 |
0 | 2031 /* If the front end has decided that this needs to be passed by |
2032 reference, do so. */ | |
2033 if ((TREE_CODE (exp) == PARM_DECL || TREE_CODE (exp) == RESULT_DECL) | |
2034 && DECL_BY_REFERENCE (exp)) | |
2035 return 1; | |
2036 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2037 /* Function types that are TREE_ADDRESSABLE force return in memory. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2038 if (fntype && TREE_ADDRESSABLE (fntype)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2039 return 1; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2040 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2041 /* Types that are TREE_ADDRESSABLE must be constructed in memory, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2042 and thus can't be returned in registers. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2043 if (TREE_ADDRESSABLE (type)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2044 return 1; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2045 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2046 if (flag_pcc_struct_return && AGGREGATE_TYPE_P (type)) |
0 | 2047 return 1; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2048 |
0 | 2049 if (targetm.calls.return_in_memory (type, fntype)) |
2050 return 1; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2051 |
0 | 2052 /* Make sure we have suitable call-clobbered regs to return |
2053 the value in; if not, we must return it in memory. */ | |
2054 reg = hard_function_value (type, 0, fntype, 0); | |
2055 | |
2056 /* If we have something other than a REG (e.g. a PARALLEL), then assume | |
2057 it is OK. */ | |
2058 if (!REG_P (reg)) | |
2059 return 0; | |
2060 | |
2061 regno = REGNO (reg); | |
2062 nregs = hard_regno_nregs[regno][TYPE_MODE (type)]; | |
2063 for (i = 0; i < nregs; i++) | |
2064 if (! call_used_regs[regno + i]) | |
2065 return 1; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2066 |
0 | 2067 return 0; |
2068 } | |
2069 | |
2070 /* Return true if we should assign DECL a pseudo register; false if it | |
2071 should live on the local stack. */ | |
2072 | |
2073 bool | |
2074 use_register_for_decl (const_tree decl) | |
2075 { | |
2076 if (!targetm.calls.allocate_stack_slots_for_args()) | |
2077 return true; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2078 |
0 | 2079 /* Honor volatile. */ |
2080 if (TREE_SIDE_EFFECTS (decl)) | |
2081 return false; | |
2082 | |
2083 /* Honor addressability. */ | |
2084 if (TREE_ADDRESSABLE (decl)) | |
2085 return false; | |
2086 | |
2087 /* Only register-like things go in registers. */ | |
2088 if (DECL_MODE (decl) == BLKmode) | |
2089 return false; | |
2090 | |
2091 /* If -ffloat-store specified, don't put explicit float variables | |
2092 into registers. */ | |
2093 /* ??? This should be checked after DECL_ARTIFICIAL, but tree-ssa | |
2094 propagates values across these stores, and it probably shouldn't. */ | |
2095 if (flag_float_store && FLOAT_TYPE_P (TREE_TYPE (decl))) | |
2096 return false; | |
2097 | |
2098 /* If we're not interested in tracking debugging information for | |
2099 this decl, then we can certainly put it in a register. */ | |
2100 if (DECL_IGNORED_P (decl)) | |
2101 return true; | |
2102 | |
2103 if (optimize) | |
2104 return true; | |
2105 | |
2106 if (!DECL_REGISTER (decl)) | |
2107 return false; | |
2108 | |
2109 switch (TREE_CODE (TREE_TYPE (decl))) | |
2110 { | |
2111 case RECORD_TYPE: | |
2112 case UNION_TYPE: | |
2113 case QUAL_UNION_TYPE: | |
2114 /* When not optimizing, disregard register keyword for variables with | |
2115 types containing methods, otherwise the methods won't be callable | |
2116 from the debugger. */ | |
2117 if (TYPE_METHODS (TREE_TYPE (decl))) | |
2118 return false; | |
2119 break; | |
2120 default: | |
2121 break; | |
2122 } | |
2123 | |
2124 return true; | |
2125 } | |
2126 | |
2127 /* Return true if TYPE should be passed by invisible reference. */ | |
2128 | |
2129 bool | |
2130 pass_by_reference (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
2131 tree type, bool named_arg) | |
2132 { | |
2133 if (type) | |
2134 { | |
2135 /* If this type contains non-trivial constructors, then it is | |
2136 forbidden for the middle-end to create any new copies. */ | |
2137 if (TREE_ADDRESSABLE (type)) | |
2138 return true; | |
2139 | |
2140 /* GCC post 3.4 passes *all* variable sized types by reference. */ | |
2141 if (!TYPE_SIZE (type) || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) | |
2142 return true; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2143 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2144 /* If a record type should be passed the same as its first (and only) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2145 member, use the type and mode of that member. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2146 if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2147 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2148 type = TREE_TYPE (first_field (type)); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2149 mode = TYPE_MODE (type); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2150 } |
0 | 2151 } |
2152 | |
2153 return targetm.calls.pass_by_reference (ca, mode, type, named_arg); | |
2154 } | |
2155 | |
2156 /* Return true if TYPE, which is passed by reference, should be callee | |
2157 copied instead of caller copied. */ | |
2158 | |
2159 bool | |
2160 reference_callee_copied (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
2161 tree type, bool named_arg) | |
2162 { | |
2163 if (type && TREE_ADDRESSABLE (type)) | |
2164 return false; | |
2165 return targetm.calls.callee_copies (ca, mode, type, named_arg); | |
2166 } | |
2167 | |
2168 /* Structures to communicate between the subroutines of assign_parms. | |
2169 The first holds data persistent across all parameters, the second | |
2170 is cleared out for each parameter. */ | |
2171 | |
2172 struct assign_parm_data_all | |
2173 { | |
2174 CUMULATIVE_ARGS args_so_far; | |
2175 struct args_size stack_args_size; | |
2176 tree function_result_decl; | |
2177 tree orig_fnargs; | |
2178 rtx first_conversion_insn; | |
2179 rtx last_conversion_insn; | |
2180 HOST_WIDE_INT pretend_args_size; | |
2181 HOST_WIDE_INT extra_pretend_bytes; | |
2182 int reg_parm_stack_space; | |
2183 }; | |
2184 | |
2185 struct assign_parm_data_one | |
2186 { | |
2187 tree nominal_type; | |
2188 tree passed_type; | |
2189 rtx entry_parm; | |
2190 rtx stack_parm; | |
2191 enum machine_mode nominal_mode; | |
2192 enum machine_mode passed_mode; | |
2193 enum machine_mode promoted_mode; | |
2194 struct locate_and_pad_arg_data locate; | |
2195 int partial; | |
2196 BOOL_BITFIELD named_arg : 1; | |
2197 BOOL_BITFIELD passed_pointer : 1; | |
2198 BOOL_BITFIELD on_stack : 1; | |
2199 BOOL_BITFIELD loaded_in_reg : 1; | |
2200 }; | |
2201 | |
2202 /* A subroutine of assign_parms. Initialize ALL. */ | |
2203 | |
2204 static void | |
2205 assign_parms_initialize_all (struct assign_parm_data_all *all) | |
2206 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2207 tree fntype ATTRIBUTE_UNUSED; |
0 | 2208 |
2209 memset (all, 0, sizeof (*all)); | |
2210 | |
2211 fntype = TREE_TYPE (current_function_decl); | |
2212 | |
2213 #ifdef INIT_CUMULATIVE_INCOMING_ARGS | |
2214 INIT_CUMULATIVE_INCOMING_ARGS (all->args_so_far, fntype, NULL_RTX); | |
2215 #else | |
2216 INIT_CUMULATIVE_ARGS (all->args_so_far, fntype, NULL_RTX, | |
2217 current_function_decl, -1); | |
2218 #endif | |
2219 | |
2220 #ifdef REG_PARM_STACK_SPACE | |
2221 all->reg_parm_stack_space = REG_PARM_STACK_SPACE (current_function_decl); | |
2222 #endif | |
2223 } | |
2224 | |
2225 /* If ARGS contains entries with complex types, split the entry into two | |
2226 entries of the component type. Return a new list of substitutions are | |
2227 needed, else the old list. */ | |
2228 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2229 static void |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2230 split_complex_args (VEC(tree, heap) **args) |
0 | 2231 { |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2232 unsigned i; |
0 | 2233 tree p; |
2234 | |
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
|
2235 FOR_EACH_VEC_ELT (tree, *args, i, p) |
0 | 2236 { |
2237 tree type = TREE_TYPE (p); | |
2238 if (TREE_CODE (type) == COMPLEX_TYPE | |
2239 && targetm.calls.split_complex_arg (type)) | |
2240 { | |
2241 tree decl; | |
2242 tree subtype = TREE_TYPE (type); | |
2243 bool addressable = TREE_ADDRESSABLE (p); | |
2244 | |
2245 /* Rewrite the PARM_DECL's type with its component. */ | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2246 p = copy_node (p); |
0 | 2247 TREE_TYPE (p) = subtype; |
2248 DECL_ARG_TYPE (p) = TREE_TYPE (DECL_ARG_TYPE (p)); | |
2249 DECL_MODE (p) = VOIDmode; | |
2250 DECL_SIZE (p) = NULL; | |
2251 DECL_SIZE_UNIT (p) = NULL; | |
2252 /* If this arg must go in memory, put it in a pseudo here. | |
2253 We can't allow it to go in memory as per normal parms, | |
2254 because the usual place might not have the imag part | |
2255 adjacent to the real part. */ | |
2256 DECL_ARTIFICIAL (p) = addressable; | |
2257 DECL_IGNORED_P (p) = addressable; | |
2258 TREE_ADDRESSABLE (p) = 0; | |
2259 layout_decl (p, 0); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2260 VEC_replace (tree, *args, i, p); |
0 | 2261 |
2262 /* Build a second synthetic decl. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2263 decl = build_decl (EXPR_LOCATION (p), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2264 PARM_DECL, NULL_TREE, subtype); |
0 | 2265 DECL_ARG_TYPE (decl) = DECL_ARG_TYPE (p); |
2266 DECL_ARTIFICIAL (decl) = addressable; | |
2267 DECL_IGNORED_P (decl) = addressable; | |
2268 layout_decl (decl, 0); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2269 VEC_safe_insert (tree, heap, *args, ++i, decl); |
0 | 2270 } |
2271 } | |
2272 } | |
2273 | |
2274 /* A subroutine of assign_parms. Adjust the parameter list to incorporate | |
2275 the hidden struct return argument, and (abi willing) complex args. | |
2276 Return the new parameter list. */ | |
2277 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2278 static VEC(tree, heap) * |
0 | 2279 assign_parms_augmented_arg_list (struct assign_parm_data_all *all) |
2280 { | |
2281 tree fndecl = current_function_decl; | |
2282 tree fntype = TREE_TYPE (fndecl); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2283 VEC(tree, heap) *fnargs = NULL; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2284 tree arg; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2285 |
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
|
2286 for (arg = DECL_ARGUMENTS (fndecl); arg; arg = DECL_CHAIN (arg)) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2287 VEC_safe_push (tree, heap, fnargs, arg); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2288 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2289 all->orig_fnargs = DECL_ARGUMENTS (fndecl); |
0 | 2290 |
2291 /* If struct value address is treated as the first argument, make it so. */ | |
2292 if (aggregate_value_p (DECL_RESULT (fndecl), fndecl) | |
2293 && ! cfun->returns_pcc_struct | |
2294 && targetm.calls.struct_value_rtx (TREE_TYPE (fndecl), 1) == 0) | |
2295 { | |
2296 tree type = build_pointer_type (TREE_TYPE (fntype)); | |
2297 tree decl; | |
2298 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2299 decl = build_decl (DECL_SOURCE_LOCATION (fndecl), |
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
|
2300 PARM_DECL, get_identifier (".result_ptr"), type); |
0 | 2301 DECL_ARG_TYPE (decl) = type; |
2302 DECL_ARTIFICIAL (decl) = 1; | |
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
|
2303 DECL_NAMELESS (decl) = 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
|
2304 TREE_CONSTANT (decl) = 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
|
2305 |
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
|
2306 DECL_CHAIN (decl) = all->orig_fnargs; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2307 all->orig_fnargs = decl; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2308 VEC_safe_insert (tree, heap, fnargs, 0, decl); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2309 |
0 | 2310 all->function_result_decl = decl; |
2311 } | |
2312 | |
2313 /* If the target wants to split complex arguments into scalars, do so. */ | |
2314 if (targetm.calls.split_complex_arg) | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2315 split_complex_args (&fnargs); |
0 | 2316 |
2317 return fnargs; | |
2318 } | |
2319 | |
2320 /* A subroutine of assign_parms. Examine PARM and pull out type and mode | |
2321 data for the parameter. Incorporate ABI specifics such as pass-by- | |
2322 reference and type promotion. */ | |
2323 | |
2324 static void | |
2325 assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm, | |
2326 struct assign_parm_data_one *data) | |
2327 { | |
2328 tree nominal_type, passed_type; | |
2329 enum machine_mode nominal_mode, passed_mode, promoted_mode; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2330 int unsignedp; |
0 | 2331 |
2332 memset (data, 0, sizeof (*data)); | |
2333 | |
2334 /* NAMED_ARG is a misnomer. We really mean 'non-variadic'. */ | |
2335 if (!cfun->stdarg) | |
2336 data->named_arg = 1; /* No variadic parms. */ | |
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
|
2337 else if (DECL_CHAIN (parm)) |
0 | 2338 data->named_arg = 1; /* Not the last non-variadic parm. */ |
2339 else if (targetm.calls.strict_argument_naming (&all->args_so_far)) | |
2340 data->named_arg = 1; /* Only variadic ones are unnamed. */ | |
2341 else | |
2342 data->named_arg = 0; /* Treat as variadic. */ | |
2343 | |
2344 nominal_type = TREE_TYPE (parm); | |
2345 passed_type = DECL_ARG_TYPE (parm); | |
2346 | |
2347 /* Look out for errors propagating this far. Also, if the parameter's | |
2348 type is void then its value doesn't matter. */ | |
2349 if (TREE_TYPE (parm) == error_mark_node | |
2350 /* This can happen after weird syntax errors | |
2351 or if an enum type is defined among the parms. */ | |
2352 || TREE_CODE (parm) != PARM_DECL | |
2353 || passed_type == NULL | |
2354 || VOID_TYPE_P (nominal_type)) | |
2355 { | |
2356 nominal_type = passed_type = void_type_node; | |
2357 nominal_mode = passed_mode = promoted_mode = VOIDmode; | |
2358 goto egress; | |
2359 } | |
2360 | |
2361 /* Find mode of arg as it is passed, and mode of arg as it should be | |
2362 during execution of this function. */ | |
2363 passed_mode = TYPE_MODE (passed_type); | |
2364 nominal_mode = TYPE_MODE (nominal_type); | |
2365 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2366 /* If the parm is to be passed as a transparent union or record, use the |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2367 type of the first field for the tests below. We have already verified |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2368 that the modes are the same. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2369 if ((TREE_CODE (passed_type) == UNION_TYPE |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2370 || TREE_CODE (passed_type) == RECORD_TYPE) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2371 && TYPE_TRANSPARENT_AGGR (passed_type)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2372 passed_type = TREE_TYPE (first_field (passed_type)); |
0 | 2373 |
2374 /* See if this arg was passed by invisible reference. */ | |
2375 if (pass_by_reference (&all->args_so_far, passed_mode, | |
2376 passed_type, data->named_arg)) | |
2377 { | |
2378 passed_type = nominal_type = build_pointer_type (passed_type); | |
2379 data->passed_pointer = true; | |
2380 passed_mode = nominal_mode = Pmode; | |
2381 } | |
2382 | |
2383 /* Find mode as it is passed by the ABI. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2384 unsignedp = TYPE_UNSIGNED (passed_type); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2385 promoted_mode = promote_function_mode (passed_type, passed_mode, &unsignedp, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2386 TREE_TYPE (current_function_decl), 0); |
0 | 2387 |
2388 egress: | |
2389 data->nominal_type = nominal_type; | |
2390 data->passed_type = passed_type; | |
2391 data->nominal_mode = nominal_mode; | |
2392 data->passed_mode = passed_mode; | |
2393 data->promoted_mode = promoted_mode; | |
2394 } | |
2395 | |
2396 /* A subroutine of assign_parms. Invoke setup_incoming_varargs. */ | |
2397 | |
2398 static void | |
2399 assign_parms_setup_varargs (struct assign_parm_data_all *all, | |
2400 struct assign_parm_data_one *data, bool no_rtl) | |
2401 { | |
2402 int varargs_pretend_bytes = 0; | |
2403 | |
2404 targetm.calls.setup_incoming_varargs (&all->args_so_far, | |
2405 data->promoted_mode, | |
2406 data->passed_type, | |
2407 &varargs_pretend_bytes, no_rtl); | |
2408 | |
2409 /* If the back-end has requested extra stack space, record how much is | |
2410 needed. Do not change pretend_args_size otherwise since it may be | |
2411 nonzero from an earlier partial argument. */ | |
2412 if (varargs_pretend_bytes > 0) | |
2413 all->pretend_args_size = varargs_pretend_bytes; | |
2414 } | |
2415 | |
2416 /* A subroutine of assign_parms. Set DATA->ENTRY_PARM corresponding to | |
2417 the incoming location of the current parameter. */ | |
2418 | |
2419 static void | |
2420 assign_parm_find_entry_rtl (struct assign_parm_data_all *all, | |
2421 struct assign_parm_data_one *data) | |
2422 { | |
2423 HOST_WIDE_INT pretend_bytes = 0; | |
2424 rtx entry_parm; | |
2425 bool in_regs; | |
2426 | |
2427 if (data->promoted_mode == VOIDmode) | |
2428 { | |
2429 data->entry_parm = data->stack_parm = const0_rtx; | |
2430 return; | |
2431 } | |
2432 | |
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
|
2433 entry_parm = targetm.calls.function_incoming_arg (&all->args_so_far, |
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
|
2434 data->promoted_mode, |
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
|
2435 data->passed_type, |
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
|
2436 data->named_arg); |
0 | 2437 |
2438 if (entry_parm == 0) | |
2439 data->promoted_mode = data->passed_mode; | |
2440 | |
2441 /* Determine parm's home in the stack, in case it arrives in the stack | |
2442 or we should pretend it did. Compute the stack position and rtx where | |
2443 the argument arrives and its size. | |
2444 | |
2445 There is one complexity here: If this was a parameter that would | |
2446 have been passed in registers, but wasn't only because it is | |
2447 __builtin_va_alist, we want locate_and_pad_parm to treat it as if | |
2448 it came in a register so that REG_PARM_STACK_SPACE isn't skipped. | |
2449 In this case, we call FUNCTION_ARG with NAMED set to 1 instead of 0 | |
2450 as it was the previous time. */ | |
2451 in_regs = entry_parm != 0; | |
2452 #ifdef STACK_PARMS_IN_REG_PARM_AREA | |
2453 in_regs = true; | |
2454 #endif | |
2455 if (!in_regs && !data->named_arg) | |
2456 { | |
2457 if (targetm.calls.pretend_outgoing_varargs_named (&all->args_so_far)) | |
2458 { | |
2459 rtx tem; | |
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
|
2460 tem = targetm.calls.function_incoming_arg (&all->args_so_far, |
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
|
2461 data->promoted_mode, |
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
|
2462 data->passed_type, true); |
0 | 2463 in_regs = tem != NULL; |
2464 } | |
2465 } | |
2466 | |
2467 /* If this parameter was passed both in registers and in the stack, use | |
2468 the copy on the stack. */ | |
2469 if (targetm.calls.must_pass_in_stack (data->promoted_mode, | |
2470 data->passed_type)) | |
2471 entry_parm = 0; | |
2472 | |
2473 if (entry_parm) | |
2474 { | |
2475 int partial; | |
2476 | |
2477 partial = targetm.calls.arg_partial_bytes (&all->args_so_far, | |
2478 data->promoted_mode, | |
2479 data->passed_type, | |
2480 data->named_arg); | |
2481 data->partial = partial; | |
2482 | |
2483 /* The caller might already have allocated stack space for the | |
2484 register parameters. */ | |
2485 if (partial != 0 && all->reg_parm_stack_space == 0) | |
2486 { | |
2487 /* Part of this argument is passed in registers and part | |
2488 is passed on the stack. Ask the prologue code to extend | |
2489 the stack part so that we can recreate the full value. | |
2490 | |
2491 PRETEND_BYTES is the size of the registers we need to store. | |
2492 CURRENT_FUNCTION_PRETEND_ARGS_SIZE is the amount of extra | |
2493 stack space that the prologue should allocate. | |
2494 | |
2495 Internally, gcc assumes that the argument pointer is aligned | |
2496 to STACK_BOUNDARY bits. This is used both for alignment | |
2497 optimizations (see init_emit) and to locate arguments that are | |
2498 aligned to more than PARM_BOUNDARY bits. We must preserve this | |
2499 invariant by rounding CURRENT_FUNCTION_PRETEND_ARGS_SIZE up to | |
2500 a stack boundary. */ | |
2501 | |
2502 /* We assume at most one partial arg, and it must be the first | |
2503 argument on the stack. */ | |
2504 gcc_assert (!all->extra_pretend_bytes && !all->pretend_args_size); | |
2505 | |
2506 pretend_bytes = partial; | |
2507 all->pretend_args_size = CEIL_ROUND (pretend_bytes, STACK_BYTES); | |
2508 | |
2509 /* We want to align relative to the actual stack pointer, so | |
2510 don't include this in the stack size until later. */ | |
2511 all->extra_pretend_bytes = all->pretend_args_size; | |
2512 } | |
2513 } | |
2514 | |
2515 locate_and_pad_parm (data->promoted_mode, data->passed_type, in_regs, | |
2516 entry_parm ? data->partial : 0, current_function_decl, | |
2517 &all->stack_args_size, &data->locate); | |
2518 | |
2519 /* Update parm_stack_boundary if this parameter is passed in the | |
2520 stack. */ | |
2521 if (!in_regs && crtl->parm_stack_boundary < data->locate.boundary) | |
2522 crtl->parm_stack_boundary = data->locate.boundary; | |
2523 | |
2524 /* Adjust offsets to include the pretend args. */ | |
2525 pretend_bytes = all->extra_pretend_bytes - pretend_bytes; | |
2526 data->locate.slot_offset.constant += pretend_bytes; | |
2527 data->locate.offset.constant += pretend_bytes; | |
2528 | |
2529 data->entry_parm = entry_parm; | |
2530 } | |
2531 | |
2532 /* A subroutine of assign_parms. If there is actually space on the stack | |
2533 for this parm, count it in stack_args_size and return true. */ | |
2534 | |
2535 static bool | |
2536 assign_parm_is_stack_parm (struct assign_parm_data_all *all, | |
2537 struct assign_parm_data_one *data) | |
2538 { | |
2539 /* Trivially true if we've no incoming register. */ | |
2540 if (data->entry_parm == NULL) | |
2541 ; | |
2542 /* Also true if we're partially in registers and partially not, | |
2543 since we've arranged to drop the entire argument on the stack. */ | |
2544 else if (data->partial != 0) | |
2545 ; | |
2546 /* Also true if the target says that it's passed in both registers | |
2547 and on the stack. */ | |
2548 else if (GET_CODE (data->entry_parm) == PARALLEL | |
2549 && XEXP (XVECEXP (data->entry_parm, 0, 0), 0) == NULL_RTX) | |
2550 ; | |
2551 /* Also true if the target says that there's stack allocated for | |
2552 all register parameters. */ | |
2553 else if (all->reg_parm_stack_space > 0) | |
2554 ; | |
2555 /* Otherwise, no, this parameter has no ABI defined stack slot. */ | |
2556 else | |
2557 return false; | |
2558 | |
2559 all->stack_args_size.constant += data->locate.size.constant; | |
2560 if (data->locate.size.var) | |
2561 ADD_PARM_SIZE (all->stack_args_size, data->locate.size.var); | |
2562 | |
2563 return true; | |
2564 } | |
2565 | |
2566 /* A subroutine of assign_parms. Given that this parameter is allocated | |
2567 stack space by the ABI, find it. */ | |
2568 | |
2569 static void | |
2570 assign_parm_find_stack_rtl (tree parm, struct assign_parm_data_one *data) | |
2571 { | |
2572 rtx offset_rtx, stack_parm; | |
2573 unsigned int align, boundary; | |
2574 | |
2575 /* If we're passing this arg using a reg, make its stack home the | |
2576 aligned stack slot. */ | |
2577 if (data->entry_parm) | |
2578 offset_rtx = ARGS_SIZE_RTX (data->locate.slot_offset); | |
2579 else | |
2580 offset_rtx = ARGS_SIZE_RTX (data->locate.offset); | |
2581 | |
2582 stack_parm = crtl->args.internal_arg_pointer; | |
2583 if (offset_rtx != const0_rtx) | |
2584 stack_parm = gen_rtx_PLUS (Pmode, stack_parm, offset_rtx); | |
2585 stack_parm = gen_rtx_MEM (data->promoted_mode, stack_parm); | |
2586 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2587 if (!data->passed_pointer) |
0 | 2588 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2589 set_mem_attributes (stack_parm, parm, 1); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2590 /* set_mem_attributes could set MEM_SIZE to the passed mode's size, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2591 while promoted mode's size is needed. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2592 if (data->promoted_mode != BLKmode |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2593 && data->promoted_mode != DECL_MODE (parm)) |
0 | 2594 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2595 set_mem_size (stack_parm, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2596 GEN_INT (GET_MODE_SIZE (data->promoted_mode))); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2597 if (MEM_EXPR (stack_parm) && MEM_OFFSET (stack_parm)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2598 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2599 int offset = subreg_lowpart_offset (DECL_MODE (parm), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2600 data->promoted_mode); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2601 if (offset) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2602 set_mem_offset (stack_parm, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2603 plus_constant (MEM_OFFSET (stack_parm), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2604 -offset)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2605 } |
0 | 2606 } |
2607 } | |
2608 | |
2609 boundary = data->locate.boundary; | |
2610 align = BITS_PER_UNIT; | |
2611 | |
2612 /* If we're padding upward, we know that the alignment of the slot | |
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
|
2613 is TARGET_FUNCTION_ARG_BOUNDARY. If we're using slot_offset, we're |
0 | 2614 intentionally forcing upward padding. Otherwise we have to come |
2615 up with a guess at the alignment based on OFFSET_RTX. */ | |
2616 if (data->locate.where_pad != downward || data->entry_parm) | |
2617 align = boundary; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2618 else if (CONST_INT_P (offset_rtx)) |
0 | 2619 { |
2620 align = INTVAL (offset_rtx) * BITS_PER_UNIT | boundary; | |
2621 align = align & -align; | |
2622 } | |
2623 set_mem_align (stack_parm, align); | |
2624 | |
2625 if (data->entry_parm) | |
2626 set_reg_attrs_for_parm (data->entry_parm, stack_parm); | |
2627 | |
2628 data->stack_parm = stack_parm; | |
2629 } | |
2630 | |
2631 /* A subroutine of assign_parms. Adjust DATA->ENTRY_RTL such that it's | |
2632 always valid and contiguous. */ | |
2633 | |
2634 static void | |
2635 assign_parm_adjust_entry_rtl (struct assign_parm_data_one *data) | |
2636 { | |
2637 rtx entry_parm = data->entry_parm; | |
2638 rtx stack_parm = data->stack_parm; | |
2639 | |
2640 /* If this parm was passed part in regs and part in memory, pretend it | |
2641 arrived entirely in memory by pushing the register-part onto the stack. | |
2642 In the special case of a DImode or DFmode that is split, we could put | |
2643 it together in a pseudoreg directly, but for now that's not worth | |
2644 bothering with. */ | |
2645 if (data->partial != 0) | |
2646 { | |
2647 /* Handle calls that pass values in multiple non-contiguous | |
2648 locations. The Irix 6 ABI has examples of this. */ | |
2649 if (GET_CODE (entry_parm) == PARALLEL) | |
2650 emit_group_store (validize_mem (stack_parm), entry_parm, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2651 data->passed_type, |
0 | 2652 int_size_in_bytes (data->passed_type)); |
2653 else | |
2654 { | |
2655 gcc_assert (data->partial % UNITS_PER_WORD == 0); | |
2656 move_block_from_reg (REGNO (entry_parm), validize_mem (stack_parm), | |
2657 data->partial / UNITS_PER_WORD); | |
2658 } | |
2659 | |
2660 entry_parm = stack_parm; | |
2661 } | |
2662 | |
2663 /* If we didn't decide this parm came in a register, by default it came | |
2664 on the stack. */ | |
2665 else if (entry_parm == NULL) | |
2666 entry_parm = stack_parm; | |
2667 | |
2668 /* When an argument is passed in multiple locations, we can't make use | |
2669 of this information, but we can save some copying if the whole argument | |
2670 is passed in a single register. */ | |
2671 else if (GET_CODE (entry_parm) == PARALLEL | |
2672 && data->nominal_mode != BLKmode | |
2673 && data->passed_mode != BLKmode) | |
2674 { | |
2675 size_t i, len = XVECLEN (entry_parm, 0); | |
2676 | |
2677 for (i = 0; i < len; i++) | |
2678 if (XEXP (XVECEXP (entry_parm, 0, i), 0) != NULL_RTX | |
2679 && REG_P (XEXP (XVECEXP (entry_parm, 0, i), 0)) | |
2680 && (GET_MODE (XEXP (XVECEXP (entry_parm, 0, i), 0)) | |
2681 == data->passed_mode) | |
2682 && INTVAL (XEXP (XVECEXP (entry_parm, 0, i), 1)) == 0) | |
2683 { | |
2684 entry_parm = XEXP (XVECEXP (entry_parm, 0, i), 0); | |
2685 break; | |
2686 } | |
2687 } | |
2688 | |
2689 data->entry_parm = entry_parm; | |
2690 } | |
2691 | |
2692 /* A subroutine of assign_parms. Reconstitute any values which were | |
2693 passed in multiple registers and would fit in a single register. */ | |
2694 | |
2695 static void | |
2696 assign_parm_remove_parallels (struct assign_parm_data_one *data) | |
2697 { | |
2698 rtx entry_parm = data->entry_parm; | |
2699 | |
2700 /* Convert the PARALLEL to a REG of the same mode as the parallel. | |
2701 This can be done with register operations rather than on the | |
2702 stack, even if we will store the reconstituted parameter on the | |
2703 stack later. */ | |
2704 if (GET_CODE (entry_parm) == PARALLEL && GET_MODE (entry_parm) != BLKmode) | |
2705 { | |
2706 rtx parmreg = gen_reg_rtx (GET_MODE (entry_parm)); | |
2707 emit_group_store (parmreg, entry_parm, data->passed_type, | |
2708 GET_MODE_SIZE (GET_MODE (entry_parm))); | |
2709 entry_parm = parmreg; | |
2710 } | |
2711 | |
2712 data->entry_parm = entry_parm; | |
2713 } | |
2714 | |
2715 /* A subroutine of assign_parms. Adjust DATA->STACK_RTL such that it's | |
2716 always valid and properly aligned. */ | |
2717 | |
2718 static void | |
2719 assign_parm_adjust_stack_rtl (struct assign_parm_data_one *data) | |
2720 { | |
2721 rtx stack_parm = data->stack_parm; | |
2722 | |
2723 /* If we can't trust the parm stack slot to be aligned enough for its | |
2724 ultimate type, don't use that slot after entry. We'll make another | |
2725 stack slot, if we need one. */ | |
2726 if (stack_parm | |
2727 && ((STRICT_ALIGNMENT | |
2728 && GET_MODE_ALIGNMENT (data->nominal_mode) > MEM_ALIGN (stack_parm)) | |
2729 || (data->nominal_type | |
2730 && TYPE_ALIGN (data->nominal_type) > MEM_ALIGN (stack_parm) | |
2731 && MEM_ALIGN (stack_parm) < PREFERRED_STACK_BOUNDARY))) | |
2732 stack_parm = NULL; | |
2733 | |
2734 /* If parm was passed in memory, and we need to convert it on entry, | |
2735 don't store it back in that same slot. */ | |
2736 else if (data->entry_parm == stack_parm | |
2737 && data->nominal_mode != BLKmode | |
2738 && data->nominal_mode != data->passed_mode) | |
2739 stack_parm = NULL; | |
2740 | |
2741 /* If stack protection is in effect for this function, don't leave any | |
2742 pointers in their passed stack slots. */ | |
2743 else if (crtl->stack_protect_guard | |
2744 && (flag_stack_protect == 2 | |
2745 || data->passed_pointer | |
2746 || POINTER_TYPE_P (data->nominal_type))) | |
2747 stack_parm = NULL; | |
2748 | |
2749 data->stack_parm = stack_parm; | |
2750 } | |
2751 | |
2752 /* A subroutine of assign_parms. Return true if the current parameter | |
2753 should be stored as a BLKmode in the current frame. */ | |
2754 | |
2755 static bool | |
2756 assign_parm_setup_block_p (struct assign_parm_data_one *data) | |
2757 { | |
2758 if (data->nominal_mode == BLKmode) | |
2759 return true; | |
2760 if (GET_MODE (data->entry_parm) == BLKmode) | |
2761 return true; | |
2762 | |
2763 #ifdef BLOCK_REG_PADDING | |
2764 /* Only assign_parm_setup_block knows how to deal with register arguments | |
2765 that are padded at the least significant end. */ | |
2766 if (REG_P (data->entry_parm) | |
2767 && GET_MODE_SIZE (data->promoted_mode) < UNITS_PER_WORD | |
2768 && (BLOCK_REG_PADDING (data->passed_mode, data->passed_type, 1) | |
2769 == (BYTES_BIG_ENDIAN ? upward : downward))) | |
2770 return true; | |
2771 #endif | |
2772 | |
2773 return false; | |
2774 } | |
2775 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2776 /* A subroutine of assign_parms. Arrange for the parameter to be |
0 | 2777 present and valid in DATA->STACK_RTL. */ |
2778 | |
2779 static void | |
2780 assign_parm_setup_block (struct assign_parm_data_all *all, | |
2781 tree parm, struct assign_parm_data_one *data) | |
2782 { | |
2783 rtx entry_parm = data->entry_parm; | |
2784 rtx stack_parm = data->stack_parm; | |
2785 HOST_WIDE_INT size; | |
2786 HOST_WIDE_INT size_stored; | |
2787 | |
2788 if (GET_CODE (entry_parm) == PARALLEL) | |
2789 entry_parm = emit_group_move_into_temps (entry_parm); | |
2790 | |
2791 size = int_size_in_bytes (data->passed_type); | |
2792 size_stored = CEIL_ROUND (size, UNITS_PER_WORD); | |
2793 if (stack_parm == 0) | |
2794 { | |
2795 DECL_ALIGN (parm) = MAX (DECL_ALIGN (parm), BITS_PER_WORD); | |
2796 stack_parm = assign_stack_local (BLKmode, size_stored, | |
2797 DECL_ALIGN (parm)); | |
2798 if (GET_MODE_SIZE (GET_MODE (entry_parm)) == size) | |
2799 PUT_MODE (stack_parm, GET_MODE (entry_parm)); | |
2800 set_mem_attributes (stack_parm, parm, 1); | |
2801 } | |
2802 | |
2803 /* If a BLKmode arrives in registers, copy it to a stack slot. Handle | |
2804 calls that pass values in multiple non-contiguous locations. */ | |
2805 if (REG_P (entry_parm) || GET_CODE (entry_parm) == PARALLEL) | |
2806 { | |
2807 rtx mem; | |
2808 | |
2809 /* Note that we will be storing an integral number of words. | |
2810 So we have to be careful to ensure that we allocate an | |
2811 integral number of words. We do this above when we call | |
2812 assign_stack_local if space was not allocated in the argument | |
2813 list. If it was, this will not work if PARM_BOUNDARY is not | |
2814 a multiple of BITS_PER_WORD. It isn't clear how to fix this | |
2815 if it becomes a problem. Exception is when BLKmode arrives | |
2816 with arguments not conforming to word_mode. */ | |
2817 | |
2818 if (data->stack_parm == 0) | |
2819 ; | |
2820 else if (GET_CODE (entry_parm) == PARALLEL) | |
2821 ; | |
2822 else | |
2823 gcc_assert (!size || !(PARM_BOUNDARY % BITS_PER_WORD)); | |
2824 | |
2825 mem = validize_mem (stack_parm); | |
2826 | |
2827 /* Handle values in multiple non-contiguous locations. */ | |
2828 if (GET_CODE (entry_parm) == PARALLEL) | |
2829 { | |
2830 push_to_sequence2 (all->first_conversion_insn, | |
2831 all->last_conversion_insn); | |
2832 emit_group_store (mem, entry_parm, data->passed_type, size); | |
2833 all->first_conversion_insn = get_insns (); | |
2834 all->last_conversion_insn = get_last_insn (); | |
2835 end_sequence (); | |
2836 } | |
2837 | |
2838 else if (size == 0) | |
2839 ; | |
2840 | |
2841 /* If SIZE is that of a mode no bigger than a word, just use | |
2842 that mode's store operation. */ | |
2843 else if (size <= UNITS_PER_WORD) | |
2844 { | |
2845 enum machine_mode mode | |
2846 = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0); | |
2847 | |
2848 if (mode != BLKmode | |
2849 #ifdef BLOCK_REG_PADDING | |
2850 && (size == UNITS_PER_WORD | |
2851 || (BLOCK_REG_PADDING (mode, data->passed_type, 1) | |
2852 != (BYTES_BIG_ENDIAN ? upward : downward))) | |
2853 #endif | |
2854 ) | |
2855 { | |
2856 rtx reg; | |
2857 | |
2858 /* We are really truncating a word_mode value containing | |
2859 SIZE bytes into a value of mode MODE. If such an | |
2860 operation requires no actual instructions, we can refer | |
2861 to the value directly in mode MODE, otherwise we must | |
2862 start with the register in word_mode and explicitly | |
2863 convert it. */ | |
2864 if (TRULY_NOOP_TRUNCATION (size * BITS_PER_UNIT, BITS_PER_WORD)) | |
2865 reg = gen_rtx_REG (mode, REGNO (entry_parm)); | |
2866 else | |
2867 { | |
2868 reg = gen_rtx_REG (word_mode, REGNO (entry_parm)); | |
2869 reg = convert_to_mode (mode, copy_to_reg (reg), 1); | |
2870 } | |
2871 emit_move_insn (change_address (mem, mode, 0), reg); | |
2872 } | |
2873 | |
2874 /* Blocks smaller than a word on a BYTES_BIG_ENDIAN | |
2875 machine must be aligned to the left before storing | |
2876 to memory. Note that the previous test doesn't | |
2877 handle all cases (e.g. SIZE == 3). */ | |
2878 else if (size != UNITS_PER_WORD | |
2879 #ifdef BLOCK_REG_PADDING | |
2880 && (BLOCK_REG_PADDING (mode, data->passed_type, 1) | |
2881 == downward) | |
2882 #else | |
2883 && BYTES_BIG_ENDIAN | |
2884 #endif | |
2885 ) | |
2886 { | |
2887 rtx tem, x; | |
2888 int by = (UNITS_PER_WORD - size) * BITS_PER_UNIT; | |
2889 rtx reg = gen_rtx_REG (word_mode, REGNO (entry_parm)); | |
2890 | |
2891 x = expand_shift (LSHIFT_EXPR, word_mode, reg, | |
2892 build_int_cst (NULL_TREE, by), | |
2893 NULL_RTX, 1); | |
2894 tem = change_address (mem, word_mode, 0); | |
2895 emit_move_insn (tem, x); | |
2896 } | |
2897 else | |
2898 move_block_from_reg (REGNO (entry_parm), mem, | |
2899 size_stored / UNITS_PER_WORD); | |
2900 } | |
2901 else | |
2902 move_block_from_reg (REGNO (entry_parm), mem, | |
2903 size_stored / UNITS_PER_WORD); | |
2904 } | |
2905 else if (data->stack_parm == 0) | |
2906 { | |
2907 push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn); | |
2908 emit_block_move (stack_parm, data->entry_parm, GEN_INT (size), | |
2909 BLOCK_OP_NORMAL); | |
2910 all->first_conversion_insn = get_insns (); | |
2911 all->last_conversion_insn = get_last_insn (); | |
2912 end_sequence (); | |
2913 } | |
2914 | |
2915 data->stack_parm = stack_parm; | |
2916 SET_DECL_RTL (parm, stack_parm); | |
2917 } | |
2918 | |
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
|
2919 /* A subroutine of assign_parm_setup_reg, called through note_stores. |
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
|
2920 This collects sets and clobbers of hard registers in a HARD_REG_SET, |
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
|
2921 which is pointed to by DATA. */ |
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
|
2922 static 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
|
2923 record_hard_reg_sets (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data) |
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
|
2924 { |
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
|
2925 HARD_REG_SET *pset = (HARD_REG_SET *)data; |
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
|
2926 if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER) |
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
|
2927 { |
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
|
2928 int nregs = hard_regno_nregs[REGNO (x)][GET_MODE (x)]; |
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
|
2929 while (nregs-- > 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
|
2930 SET_HARD_REG_BIT (*pset, REGNO (x) + nregs); |
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
|
2931 } |
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
|
2932 } |
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
|
2933 |
0 | 2934 /* A subroutine of assign_parms. Allocate a pseudo to hold the current |
2935 parameter. Get it there. Perform all ABI specified conversions. */ | |
2936 | |
2937 static void | |
2938 assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, | |
2939 struct assign_parm_data_one *data) | |
2940 { | |
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
|
2941 rtx parmreg, validated_mem; |
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
|
2942 rtx equiv_stack_parm; |
0 | 2943 enum machine_mode promoted_nominal_mode; |
2944 int unsignedp = TYPE_UNSIGNED (TREE_TYPE (parm)); | |
2945 bool did_conversion = false; | |
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
|
2946 bool need_conversion, moved; |
0 | 2947 |
2948 /* Store the parm in a pseudoregister during the function, but we may | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2949 need to do it in a wider mode. Using 2 here makes the result |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2950 consistent with promote_decl_mode and thus expand_expr_real_1. */ |
0 | 2951 promoted_nominal_mode |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2952 = promote_function_mode (data->nominal_type, data->nominal_mode, &unsignedp, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2953 TREE_TYPE (current_function_decl), 2); |
0 | 2954 |
2955 parmreg = gen_reg_rtx (promoted_nominal_mode); | |
2956 | |
2957 if (!DECL_ARTIFICIAL (parm)) | |
2958 mark_user_reg (parmreg); | |
2959 | |
2960 /* If this was an item that we received a pointer to, | |
2961 set DECL_RTL appropriately. */ | |
2962 if (data->passed_pointer) | |
2963 { | |
2964 rtx x = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (data->passed_type)), parmreg); | |
2965 set_mem_attributes (x, parm, 1); | |
2966 SET_DECL_RTL (parm, x); | |
2967 } | |
2968 else | |
2969 SET_DECL_RTL (parm, parmreg); | |
2970 | |
2971 assign_parm_remove_parallels (data); | |
2972 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2973 /* Copy the value into the register, thus bridging between |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
2974 assign_parm_find_data_types and expand_expr_real_1. */ |
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
|
2975 |
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
|
2976 equiv_stack_parm = data->stack_parm; |
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
|
2977 validated_mem = validize_mem (data->entry_parm); |
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
|
2978 |
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
|
2979 need_conversion = (data->nominal_mode != data->passed_mode |
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
|
2980 || promoted_nominal_mode != data->promoted_mode); |
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
|
2981 moved = false; |
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
|
2982 |
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
|
2983 if (need_conversion |
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
|
2984 && GET_MODE_CLASS (data->nominal_mode) == MODE_INT |
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
|
2985 && data->nominal_mode == data->passed_mode |
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
|
2986 && data->nominal_mode == GET_MODE (data->entry_parm)) |
0 | 2987 { |
2988 /* ENTRY_PARM has been converted to PROMOTED_MODE, its | |
2989 mode, by the caller. We now have to convert it to | |
2990 NOMINAL_MODE, if different. However, PARMREG may be in | |
2991 a different mode than NOMINAL_MODE if it is being stored | |
2992 promoted. | |
2993 | |
2994 If ENTRY_PARM is a hard register, it might be in a register | |
2995 not valid for operating in its mode (e.g., an odd-numbered | |
2996 register for a DFmode). In that case, moves are the only | |
2997 thing valid, so we can't do a convert from there. This | |
2998 occurs when the calling sequence allow such misaligned | |
2999 usages. | |
3000 | |
3001 In addition, the conversion may involve a call, which could | |
3002 clobber parameters which haven't been copied to pseudo | |
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
|
3003 registers yet. |
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
|
3004 |
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
|
3005 First, we try to emit an insn which performs the necessary |
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
|
3006 conversion. We verify that this insn does not clobber any |
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
|
3007 hard registers. */ |
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
|
3008 |
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
|
3009 enum insn_code icode; |
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
|
3010 rtx op0, op1; |
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
|
3011 |
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
|
3012 icode = can_extend_p (promoted_nominal_mode, data->passed_mode, |
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
|
3013 unsignedp); |
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
|
3014 |
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
|
3015 op0 = parmreg; |
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
|
3016 op1 = validated_mem; |
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
|
3017 if (icode != CODE_FOR_nothing |
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
|
3018 && insn_data[icode].operand[0].predicate (op0, promoted_nominal_mode) |
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
|
3019 && insn_data[icode].operand[1].predicate (op1, data->passed_mode)) |
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
|
3020 { |
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
|
3021 enum rtx_code code = unsignedp ? ZERO_EXTEND : SIGN_EXTEND; |
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
|
3022 rtx insn, insns; |
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
|
3023 HARD_REG_SET hardregs; |
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
|
3024 |
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
|
3025 start_sequence (); |
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
|
3026 insn = gen_extend_insn (op0, op1, promoted_nominal_mode, |
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
|
3027 data->passed_mode, unsignedp); |
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
|
3028 emit_insn (insn); |
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
|
3029 insns = get_insns (); |
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
|
3030 |
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
|
3031 moved = true; |
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
|
3032 CLEAR_HARD_REG_SET (hardregs); |
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
|
3033 for (insn = insns; insn && moved; insn = NEXT_INSN (insn)) |
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
|
3034 { |
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
|
3035 if (INSN_P (insn)) |
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
|
3036 note_stores (PATTERN (insn), record_hard_reg_sets, |
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
|
3037 &hardregs); |
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
|
3038 if (!hard_reg_set_empty_p (hardregs)) |
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
|
3039 moved = false; |
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
|
3040 } |
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
|
3041 |
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
|
3042 end_sequence (); |
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
|
3043 |
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
|
3044 if (moved) |
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
|
3045 { |
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
|
3046 emit_insn (insns); |
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
|
3047 if (equiv_stack_parm != NULL_RTX) |
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
|
3048 equiv_stack_parm = gen_rtx_fmt_e (code, GET_MODE (parmreg), |
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
|
3049 equiv_stack_parm); |
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
|
3050 } |
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
|
3051 } |
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
|
3052 } |
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
|
3053 |
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
|
3054 if (moved) |
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
|
3055 /* Nothing to do. */ |
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
|
3056 ; |
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
|
3057 else if (need_conversion) |
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
|
3058 { |
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
|
3059 /* We did not have an insn to convert directly, or the sequence |
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
|
3060 generated appeared unsafe. We must first copy the parm to a |
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
|
3061 pseudo reg, and save the conversion until after all |
0 | 3062 parameters have been moved. */ |
3063 | |
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
|
3064 int save_tree_used; |
0 | 3065 rtx tempreg = gen_reg_rtx (GET_MODE (data->entry_parm)); |
3066 | |
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
|
3067 emit_move_insn (tempreg, validated_mem); |
0 | 3068 |
3069 push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn); | |
3070 tempreg = convert_to_mode (data->nominal_mode, tempreg, unsignedp); | |
3071 | |
3072 if (GET_CODE (tempreg) == SUBREG | |
3073 && GET_MODE (tempreg) == data->nominal_mode | |
3074 && REG_P (SUBREG_REG (tempreg)) | |
3075 && data->nominal_mode == data->passed_mode | |
3076 && GET_MODE (SUBREG_REG (tempreg)) == GET_MODE (data->entry_parm) | |
3077 && GET_MODE_SIZE (GET_MODE (tempreg)) | |
3078 < GET_MODE_SIZE (GET_MODE (data->entry_parm))) | |
3079 { | |
3080 /* The argument is already sign/zero extended, so note it | |
3081 into the subreg. */ | |
3082 SUBREG_PROMOTED_VAR_P (tempreg) = 1; | |
3083 SUBREG_PROMOTED_UNSIGNED_SET (tempreg, unsignedp); | |
3084 } | |
3085 | |
3086 /* TREE_USED gets set erroneously during expand_assignment. */ | |
3087 save_tree_used = TREE_USED (parm); | |
3088 expand_assignment (parm, make_tree (data->nominal_type, tempreg), false); | |
3089 TREE_USED (parm) = save_tree_used; | |
3090 all->first_conversion_insn = get_insns (); | |
3091 all->last_conversion_insn = get_last_insn (); | |
3092 end_sequence (); | |
3093 | |
3094 did_conversion = true; | |
3095 } | |
3096 else | |
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
|
3097 emit_move_insn (parmreg, validated_mem); |
0 | 3098 |
3099 /* If we were passed a pointer but the actual value can safely live | |
3100 in a register, put it in one. */ | |
3101 if (data->passed_pointer | |
3102 && TYPE_MODE (TREE_TYPE (parm)) != BLKmode | |
3103 /* If by-reference argument was promoted, demote it. */ | |
3104 && (TYPE_MODE (TREE_TYPE (parm)) != GET_MODE (DECL_RTL (parm)) | |
3105 || use_register_for_decl (parm))) | |
3106 { | |
3107 /* We can't use nominal_mode, because it will have been set to | |
3108 Pmode above. We must use the actual mode of the parm. */ | |
3109 parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm))); | |
3110 mark_user_reg (parmreg); | |
3111 | |
3112 if (GET_MODE (parmreg) != GET_MODE (DECL_RTL (parm))) | |
3113 { | |
3114 rtx tempreg = gen_reg_rtx (GET_MODE (DECL_RTL (parm))); | |
3115 int unsigned_p = TYPE_UNSIGNED (TREE_TYPE (parm)); | |
3116 | |
3117 push_to_sequence2 (all->first_conversion_insn, | |
3118 all->last_conversion_insn); | |
3119 emit_move_insn (tempreg, DECL_RTL (parm)); | |
3120 tempreg = convert_to_mode (GET_MODE (parmreg), tempreg, unsigned_p); | |
3121 emit_move_insn (parmreg, tempreg); | |
3122 all->first_conversion_insn = get_insns (); | |
3123 all->last_conversion_insn = get_last_insn (); | |
3124 end_sequence (); | |
3125 | |
3126 did_conversion = true; | |
3127 } | |
3128 else | |
3129 emit_move_insn (parmreg, DECL_RTL (parm)); | |
3130 | |
3131 SET_DECL_RTL (parm, parmreg); | |
3132 | |
3133 /* STACK_PARM is the pointer, not the parm, and PARMREG is | |
3134 now the parm. */ | |
3135 data->stack_parm = NULL; | |
3136 } | |
3137 | |
3138 /* Mark the register as eliminable if we did no conversion and it was | |
3139 copied from memory at a fixed offset, and the arg pointer was not | |
3140 copied to a pseudo-reg. If the arg pointer is a pseudo reg or the | |
3141 offset formed an invalid address, such memory-equivalences as we | |
3142 make here would screw up life analysis for it. */ | |
3143 if (data->nominal_mode == data->passed_mode | |
3144 && !did_conversion | |
3145 && data->stack_parm != 0 | |
3146 && MEM_P (data->stack_parm) | |
3147 && data->locate.offset.var == 0 | |
3148 && reg_mentioned_p (virtual_incoming_args_rtx, | |
3149 XEXP (data->stack_parm, 0))) | |
3150 { | |
3151 rtx linsn = get_last_insn (); | |
3152 rtx sinsn, set; | |
3153 | |
3154 /* Mark complex types separately. */ | |
3155 if (GET_CODE (parmreg) == CONCAT) | |
3156 { | |
3157 enum machine_mode submode | |
3158 = GET_MODE_INNER (GET_MODE (parmreg)); | |
3159 int regnor = REGNO (XEXP (parmreg, 0)); | |
3160 int regnoi = REGNO (XEXP (parmreg, 1)); | |
3161 rtx stackr = adjust_address_nv (data->stack_parm, submode, 0); | |
3162 rtx stacki = adjust_address_nv (data->stack_parm, submode, | |
3163 GET_MODE_SIZE (submode)); | |
3164 | |
3165 /* Scan backwards for the set of the real and | |
3166 imaginary parts. */ | |
3167 for (sinsn = linsn; sinsn != 0; | |
3168 sinsn = prev_nonnote_insn (sinsn)) | |
3169 { | |
3170 set = single_set (sinsn); | |
3171 if (set == 0) | |
3172 continue; | |
3173 | |
3174 if (SET_DEST (set) == regno_reg_rtx [regnoi]) | |
3175 set_unique_reg_note (sinsn, REG_EQUIV, stacki); | |
3176 else if (SET_DEST (set) == regno_reg_rtx [regnor]) | |
3177 set_unique_reg_note (sinsn, REG_EQUIV, stackr); | |
3178 } | |
3179 } | |
3180 else if ((set = single_set (linsn)) != 0 | |
3181 && SET_DEST (set) == parmreg) | |
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
|
3182 set_unique_reg_note (linsn, REG_EQUIV, equiv_stack_parm); |
0 | 3183 } |
3184 | |
3185 /* For pointer data type, suggest pointer register. */ | |
3186 if (POINTER_TYPE_P (TREE_TYPE (parm))) | |
3187 mark_reg_pointer (parmreg, | |
3188 TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm)))); | |
3189 } | |
3190 | |
3191 /* A subroutine of assign_parms. Allocate stack space to hold the current | |
3192 parameter. Get it there. Perform all ABI specified conversions. */ | |
3193 | |
3194 static void | |
3195 assign_parm_setup_stack (struct assign_parm_data_all *all, tree parm, | |
3196 struct assign_parm_data_one *data) | |
3197 { | |
3198 /* Value must be stored in the stack slot STACK_PARM during function | |
3199 execution. */ | |
3200 bool to_conversion = false; | |
3201 | |
3202 assign_parm_remove_parallels (data); | |
3203 | |
3204 if (data->promoted_mode != data->nominal_mode) | |
3205 { | |
3206 /* Conversion is required. */ | |
3207 rtx tempreg = gen_reg_rtx (GET_MODE (data->entry_parm)); | |
3208 | |
3209 emit_move_insn (tempreg, validize_mem (data->entry_parm)); | |
3210 | |
3211 push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn); | |
3212 to_conversion = true; | |
3213 | |
3214 data->entry_parm = convert_to_mode (data->nominal_mode, tempreg, | |
3215 TYPE_UNSIGNED (TREE_TYPE (parm))); | |
3216 | |
3217 if (data->stack_parm) | |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3218 { |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3219 int offset = subreg_lowpart_offset (data->nominal_mode, |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3220 GET_MODE (data->stack_parm)); |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3221 /* ??? This may need a big-endian conversion on sparc64. */ |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3222 data->stack_parm |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3223 = adjust_address (data->stack_parm, data->nominal_mode, 0); |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3224 if (offset && MEM_OFFSET (data->stack_parm)) |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3225 set_mem_offset (data->stack_parm, |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3226 plus_constant (MEM_OFFSET (data->stack_parm), |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3227 offset)); |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3228 } |
0 | 3229 } |
3230 | |
3231 if (data->entry_parm != data->stack_parm) | |
3232 { | |
3233 rtx src, dest; | |
3234 | |
3235 if (data->stack_parm == 0) | |
3236 { | |
3237 int align = STACK_SLOT_ALIGNMENT (data->passed_type, | |
3238 GET_MODE (data->entry_parm), | |
3239 TYPE_ALIGN (data->passed_type)); | |
3240 data->stack_parm | |
3241 = assign_stack_local (GET_MODE (data->entry_parm), | |
3242 GET_MODE_SIZE (GET_MODE (data->entry_parm)), | |
3243 align); | |
3244 set_mem_attributes (data->stack_parm, parm, 1); | |
3245 } | |
3246 | |
3247 dest = validize_mem (data->stack_parm); | |
3248 src = validize_mem (data->entry_parm); | |
3249 | |
3250 if (MEM_P (src)) | |
3251 { | |
3252 /* Use a block move to handle potentially misaligned entry_parm. */ | |
3253 if (!to_conversion) | |
3254 push_to_sequence2 (all->first_conversion_insn, | |
3255 all->last_conversion_insn); | |
3256 to_conversion = true; | |
3257 | |
3258 emit_block_move (dest, src, | |
3259 GEN_INT (int_size_in_bytes (data->passed_type)), | |
3260 BLOCK_OP_NORMAL); | |
3261 } | |
3262 else | |
3263 emit_move_insn (dest, src); | |
3264 } | |
3265 | |
3266 if (to_conversion) | |
3267 { | |
3268 all->first_conversion_insn = get_insns (); | |
3269 all->last_conversion_insn = get_last_insn (); | |
3270 end_sequence (); | |
3271 } | |
3272 | |
3273 SET_DECL_RTL (parm, data->stack_parm); | |
3274 } | |
3275 | |
3276 /* A subroutine of assign_parms. If the ABI splits complex arguments, then | |
3277 undo the frobbing that we did in assign_parms_augmented_arg_list. */ | |
3278 | |
3279 static void | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3280 assign_parms_unsplit_complex (struct assign_parm_data_all *all, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3281 VEC(tree, heap) *fnargs) |
0 | 3282 { |
3283 tree parm; | |
3284 tree orig_fnargs = all->orig_fnargs; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3285 unsigned i = 0; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3286 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3287 for (parm = orig_fnargs; parm; parm = TREE_CHAIN (parm), ++i) |
0 | 3288 { |
3289 if (TREE_CODE (TREE_TYPE (parm)) == COMPLEX_TYPE | |
3290 && targetm.calls.split_complex_arg (TREE_TYPE (parm))) | |
3291 { | |
3292 rtx tmp, real, imag; | |
3293 enum machine_mode inner = GET_MODE_INNER (DECL_MODE (parm)); | |
3294 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3295 real = DECL_RTL (VEC_index (tree, fnargs, i)); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3296 imag = DECL_RTL (VEC_index (tree, fnargs, i + 1)); |
0 | 3297 if (inner != GET_MODE (real)) |
3298 { | |
3299 real = gen_lowpart_SUBREG (inner, real); | |
3300 imag = gen_lowpart_SUBREG (inner, imag); | |
3301 } | |
3302 | |
3303 if (TREE_ADDRESSABLE (parm)) | |
3304 { | |
3305 rtx rmem, imem; | |
3306 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (parm)); | |
3307 int align = STACK_SLOT_ALIGNMENT (TREE_TYPE (parm), | |
3308 DECL_MODE (parm), | |
3309 TYPE_ALIGN (TREE_TYPE (parm))); | |
3310 | |
3311 /* split_complex_arg put the real and imag parts in | |
3312 pseudos. Move them to memory. */ | |
3313 tmp = assign_stack_local (DECL_MODE (parm), size, align); | |
3314 set_mem_attributes (tmp, parm, 1); | |
3315 rmem = adjust_address_nv (tmp, inner, 0); | |
3316 imem = adjust_address_nv (tmp, inner, GET_MODE_SIZE (inner)); | |
3317 push_to_sequence2 (all->first_conversion_insn, | |
3318 all->last_conversion_insn); | |
3319 emit_move_insn (rmem, real); | |
3320 emit_move_insn (imem, imag); | |
3321 all->first_conversion_insn = get_insns (); | |
3322 all->last_conversion_insn = get_last_insn (); | |
3323 end_sequence (); | |
3324 } | |
3325 else | |
3326 tmp = gen_rtx_CONCAT (DECL_MODE (parm), real, imag); | |
3327 SET_DECL_RTL (parm, tmp); | |
3328 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3329 real = DECL_INCOMING_RTL (VEC_index (tree, fnargs, i)); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3330 imag = DECL_INCOMING_RTL (VEC_index (tree, fnargs, i + 1)); |
0 | 3331 if (inner != GET_MODE (real)) |
3332 { | |
3333 real = gen_lowpart_SUBREG (inner, real); | |
3334 imag = gen_lowpart_SUBREG (inner, imag); | |
3335 } | |
3336 tmp = gen_rtx_CONCAT (DECL_MODE (parm), real, imag); | |
3337 set_decl_incoming_rtl (parm, tmp, false); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3338 i++; |
0 | 3339 } |
3340 } | |
3341 } | |
3342 | |
3343 /* Assign RTL expressions to the function's parameters. This may involve | |
3344 copying them into registers and using those registers as the DECL_RTL. */ | |
3345 | |
3346 static void | |
3347 assign_parms (tree fndecl) | |
3348 { | |
3349 struct assign_parm_data_all all; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3350 tree parm; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3351 VEC(tree, heap) *fnargs; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3352 unsigned i; |
0 | 3353 |
3354 crtl->args.internal_arg_pointer | |
3355 = targetm.calls.internal_arg_pointer (); | |
3356 | |
3357 assign_parms_initialize_all (&all); | |
3358 fnargs = assign_parms_augmented_arg_list (&all); | |
3359 | |
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
|
3360 FOR_EACH_VEC_ELT (tree, fnargs, i, parm) |
0 | 3361 { |
3362 struct assign_parm_data_one data; | |
3363 | |
3364 /* Extract the type of PARM; adjust it according to ABI. */ | |
3365 assign_parm_find_data_types (&all, parm, &data); | |
3366 | |
3367 /* Early out for errors and void parameters. */ | |
3368 if (data.passed_mode == VOIDmode) | |
3369 { | |
3370 SET_DECL_RTL (parm, const0_rtx); | |
3371 DECL_INCOMING_RTL (parm) = DECL_RTL (parm); | |
3372 continue; | |
3373 } | |
3374 | |
3375 /* Estimate stack alignment from parameter alignment. */ | |
3376 if (SUPPORTS_STACK_ALIGNMENT) | |
3377 { | |
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
|
3378 unsigned int align |
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
|
3379 = targetm.calls.function_arg_boundary (data.promoted_mode, |
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
|
3380 data.passed_type); |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3381 align = MINIMUM_ALIGNMENT (data.passed_type, data.promoted_mode, |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3382 align); |
0 | 3383 if (TYPE_ALIGN (data.nominal_type) > align) |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3384 align = MINIMUM_ALIGNMENT (data.nominal_type, |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3385 TYPE_MODE (data.nominal_type), |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
3386 TYPE_ALIGN (data.nominal_type)); |
0 | 3387 if (crtl->stack_alignment_estimated < align) |
3388 { | |
3389 gcc_assert (!crtl->stack_realign_processed); | |
3390 crtl->stack_alignment_estimated = align; | |
3391 } | |
3392 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
3393 |
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
|
3394 if (cfun->stdarg && !DECL_CHAIN (parm)) |
0 | 3395 assign_parms_setup_varargs (&all, &data, false); |
3396 | |
3397 /* Find out where the parameter arrives in this function. */ | |
3398 assign_parm_find_entry_rtl (&all, &data); | |
3399 | |
3400 /* Find out where stack space for this parameter might be. */ | |
3401 if (assign_parm_is_stack_parm (&all, &data)) | |
3402 { | |
3403 assign_parm_find_stack_rtl (parm, &data); | |
3404 assign_parm_adjust_entry_rtl (&data); | |
3405 } | |
3406 | |
3407 /* Record permanently how this parm was passed. */ | |
3408 set_decl_incoming_rtl (parm, data.entry_parm, data.passed_pointer); | |
3409 | |
3410 /* Update info on where next arg arrives in registers. */ | |
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
|
3411 targetm.calls.function_arg_advance (&all.args_so_far, data.promoted_mode, |
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
|
3412 data.passed_type, data.named_arg); |
0 | 3413 |
3414 assign_parm_adjust_stack_rtl (&data); | |
3415 | |
3416 if (assign_parm_setup_block_p (&data)) | |
3417 assign_parm_setup_block (&all, parm, &data); | |
3418 else if (data.passed_pointer || use_register_for_decl (parm)) | |
3419 assign_parm_setup_reg (&all, parm, &data); | |
3420 else | |
3421 assign_parm_setup_stack (&all, parm, &data); | |
3422 } | |
3423 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3424 if (targetm.calls.split_complex_arg) |
0 | 3425 assign_parms_unsplit_complex (&all, fnargs); |
3426 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3427 VEC_free (tree, heap, fnargs); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3428 |
0 | 3429 /* Output all parameter conversion instructions (possibly including calls) |
3430 now that all parameters have been copied out of hard registers. */ | |
3431 emit_insn (all.first_conversion_insn); | |
3432 | |
3433 /* Estimate reload stack alignment from scalar return mode. */ | |
3434 if (SUPPORTS_STACK_ALIGNMENT) | |
3435 { | |
3436 if (DECL_RESULT (fndecl)) | |
3437 { | |
3438 tree type = TREE_TYPE (DECL_RESULT (fndecl)); | |
3439 enum machine_mode mode = TYPE_MODE (type); | |
3440 | |
3441 if (mode != BLKmode | |
3442 && mode != VOIDmode | |
3443 && !AGGREGATE_TYPE_P (type)) | |
3444 { | |
3445 unsigned int align = GET_MODE_ALIGNMENT (mode); | |
3446 if (crtl->stack_alignment_estimated < align) | |
3447 { | |
3448 gcc_assert (!crtl->stack_realign_processed); | |
3449 crtl->stack_alignment_estimated = align; | |
3450 } | |
3451 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
3452 } |
0 | 3453 } |
3454 | |
3455 /* If we are receiving a struct value address as the first argument, set up | |
3456 the RTL for the function result. As this might require code to convert | |
3457 the transmitted address to Pmode, we do this here to ensure that possible | |
3458 preliminary conversions of the address have been emitted already. */ | |
3459 if (all.function_result_decl) | |
3460 { | |
3461 tree result = DECL_RESULT (current_function_decl); | |
3462 rtx addr = DECL_RTL (all.function_result_decl); | |
3463 rtx x; | |
3464 | |
3465 if (DECL_BY_REFERENCE (result)) | |
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
|
3466 { |
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
|
3467 SET_DECL_VALUE_EXPR (result, all.function_result_decl); |
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
|
3468 x = addr; |
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
|
3469 } |
0 | 3470 else |
3471 { | |
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
|
3472 SET_DECL_VALUE_EXPR (result, |
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
|
3473 build1 (INDIRECT_REF, TREE_TYPE (result), |
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
|
3474 all.function_result_decl)); |
0 | 3475 addr = convert_memory_address (Pmode, addr); |
3476 x = gen_rtx_MEM (DECL_MODE (result), addr); | |
3477 set_mem_attributes (x, result, 1); | |
3478 } | |
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
|
3479 |
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
|
3480 DECL_HAS_VALUE_EXPR_P (result) = 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
|
3481 |
0 | 3482 SET_DECL_RTL (result, x); |
3483 } | |
3484 | |
1 | 3485 #ifndef noCbC |
83
6fb1a677d0b5
modify expand_call
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
82
diff
changeset
|
3486 // if (CbC_IS_CODE_SEGMENT(TREE_TYPE(fndecl)) ) |
6fb1a677d0b5
modify expand_call
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
82
diff
changeset
|
3487 // all.stack_args_size.constant = CbC_STACK_SIZE; |
1 | 3488 #endif |
3489 | |
0 | 3490 /* We have aligned all the args, so add space for the pretend args. */ |
3491 crtl->args.pretend_args_size = all.pretend_args_size; | |
3492 all.stack_args_size.constant += all.extra_pretend_bytes; | |
3493 crtl->args.size = all.stack_args_size.constant; | |
3494 | |
3495 /* Adjust function incoming argument size for alignment and | |
3496 minimum length. */ | |
3497 | |
3498 #ifdef REG_PARM_STACK_SPACE | |
3499 crtl->args.size = MAX (crtl->args.size, | |
3500 REG_PARM_STACK_SPACE (fndecl)); | |
3501 #endif | |
3502 | |
3503 crtl->args.size = CEIL_ROUND (crtl->args.size, | |
3504 PARM_BOUNDARY / BITS_PER_UNIT); | |
3505 | |
3506 #ifdef ARGS_GROW_DOWNWARD | |
3507 crtl->args.arg_offset_rtx | |
3508 = (all.stack_args_size.var == 0 ? GEN_INT (-all.stack_args_size.constant) | |
3509 : expand_expr (size_diffop (all.stack_args_size.var, | |
3510 size_int (-all.stack_args_size.constant)), | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
3511 NULL_RTX, VOIDmode, EXPAND_NORMAL)); |
0 | 3512 #else |
3513 crtl->args.arg_offset_rtx = ARGS_SIZE_RTX (all.stack_args_size); | |
3514 #endif | |
3515 | |
3516 /* See how many bytes, if any, of its args a function should try to pop | |
3517 on return. */ | |
3518 | |
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
|
3519 crtl->args.pops_args = targetm.calls.return_pops_args (fndecl, |
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
|
3520 TREE_TYPE (fndecl), |
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
|
3521 crtl->args.size); |
0 | 3522 |
3523 /* For stdarg.h function, save info about | |
3524 regs and stack space used by the named args. */ | |
3525 | |
3526 crtl->args.info = all.args_so_far; | |
3527 | |
3528 /* Set the rtx used for the function return value. Put this in its | |
3529 own variable so any optimizers that need this information don't have | |
3530 to include tree.h. Do this here so it gets done when an inlined | |
3531 function gets output. */ | |
3532 | |
3533 crtl->return_rtx | |
3534 = (DECL_RTL_SET_P (DECL_RESULT (fndecl)) | |
3535 ? DECL_RTL (DECL_RESULT (fndecl)) : NULL_RTX); | |
3536 | |
3537 /* If scalar return value was computed in a pseudo-reg, or was a named | |
3538 return value that got dumped to the stack, copy that to the hard | |
3539 return register. */ | |
3540 if (DECL_RTL_SET_P (DECL_RESULT (fndecl))) | |
3541 { | |
3542 tree decl_result = DECL_RESULT (fndecl); | |
3543 rtx decl_rtl = DECL_RTL (decl_result); | |
3544 | |
3545 if (REG_P (decl_rtl) | |
3546 ? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER | |
3547 : DECL_REGISTER (decl_result)) | |
3548 { | |
3549 rtx real_decl_rtl; | |
3550 | |
3551 real_decl_rtl = targetm.calls.function_value (TREE_TYPE (decl_result), | |
3552 fndecl, true); | |
3553 REG_FUNCTION_VALUE_P (real_decl_rtl) = 1; | |
3554 /* The delay slot scheduler assumes that crtl->return_rtx | |
3555 holds the hard register containing the return value, not a | |
3556 temporary pseudo. */ | |
3557 crtl->return_rtx = real_decl_rtl; | |
3558 } | |
3559 } | |
3560 } | |
3561 | |
3562 /* A subroutine of gimplify_parameters, invoked via walk_tree. | |
3563 For all seen types, gimplify their sizes. */ | |
3564 | |
3565 static tree | |
3566 gimplify_parm_type (tree *tp, int *walk_subtrees, void *data) | |
3567 { | |
3568 tree t = *tp; | |
3569 | |
3570 *walk_subtrees = 0; | |
3571 if (TYPE_P (t)) | |
3572 { | |
3573 if (POINTER_TYPE_P (t)) | |
3574 *walk_subtrees = 1; | |
3575 else if (TYPE_SIZE (t) && !TREE_CONSTANT (TYPE_SIZE (t)) | |
3576 && !TYPE_SIZES_GIMPLIFIED (t)) | |
3577 { | |
3578 gimplify_type_sizes (t, (gimple_seq *) data); | |
3579 *walk_subtrees = 1; | |
3580 } | |
3581 } | |
3582 | |
3583 return NULL; | |
3584 } | |
3585 | |
3586 /* Gimplify the parameter list for current_function_decl. This involves | |
3587 evaluating SAVE_EXPRs of variable sized parameters and generating code | |
3588 to implement callee-copies reference parameters. Returns a sequence of | |
3589 statements to add to the beginning of the function. */ | |
3590 | |
3591 gimple_seq | |
3592 gimplify_parameters (void) | |
3593 { | |
3594 struct assign_parm_data_all all; | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3595 tree parm; |
0 | 3596 gimple_seq stmts = NULL; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3597 VEC(tree, heap) *fnargs; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3598 unsigned i; |
0 | 3599 |
3600 assign_parms_initialize_all (&all); | |
3601 fnargs = assign_parms_augmented_arg_list (&all); | |
3602 | |
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
|
3603 FOR_EACH_VEC_ELT (tree, fnargs, i, parm) |
0 | 3604 { |
3605 struct assign_parm_data_one data; | |
3606 | |
3607 /* Extract the type of PARM; adjust it according to ABI. */ | |
3608 assign_parm_find_data_types (&all, parm, &data); | |
3609 | |
3610 /* Early out for errors and void parameters. */ | |
3611 if (data.passed_mode == VOIDmode || DECL_SIZE (parm) == NULL) | |
3612 continue; | |
3613 | |
3614 /* Update info on where next arg arrives in registers. */ | |
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
|
3615 targetm.calls.function_arg_advance (&all.args_so_far, data.promoted_mode, |
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
|
3616 data.passed_type, data.named_arg); |
0 | 3617 |
3618 /* ??? Once upon a time variable_size stuffed parameter list | |
3619 SAVE_EXPRs (amongst others) onto a pending sizes list. This | |
3620 turned out to be less than manageable in the gimple world. | |
3621 Now we have to hunt them down ourselves. */ | |
3622 walk_tree_without_duplicates (&data.passed_type, | |
3623 gimplify_parm_type, &stmts); | |
3624 | |
3625 if (TREE_CODE (DECL_SIZE_UNIT (parm)) != INTEGER_CST) | |
3626 { | |
3627 gimplify_one_sizepos (&DECL_SIZE (parm), &stmts); | |
3628 gimplify_one_sizepos (&DECL_SIZE_UNIT (parm), &stmts); | |
3629 } | |
3630 | |
3631 if (data.passed_pointer) | |
3632 { | |
3633 tree type = TREE_TYPE (data.passed_type); | |
3634 if (reference_callee_copied (&all.args_so_far, TYPE_MODE (type), | |
3635 type, data.named_arg)) | |
3636 { | |
3637 tree local, t; | |
3638 | |
3639 /* For constant-sized objects, this is trivial; for | |
3640 variable-sized objects, we have to play games. */ | |
3641 if (TREE_CODE (DECL_SIZE_UNIT (parm)) == INTEGER_CST | |
3642 && !(flag_stack_check == GENERIC_STACK_CHECK | |
3643 && compare_tree_int (DECL_SIZE_UNIT (parm), | |
3644 STACK_CHECK_MAX_VAR_SIZE) > 0)) | |
3645 { | |
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
|
3646 local = create_tmp_reg (type, get_name (parm)); |
0 | 3647 DECL_IGNORED_P (local) = 0; |
3648 /* If PARM was addressable, move that flag over | |
3649 to the local copy, as its address will be taken, | |
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
|
3650 not the PARMs. Keep the parms address taken |
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
|
3651 as we'll query that flag during gimplification. */ |
0 | 3652 if (TREE_ADDRESSABLE (parm)) |
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
|
3653 TREE_ADDRESSABLE (local) = 1; |
0 | 3654 } |
3655 else | |
3656 { | |
3657 tree ptr_type, addr; | |
3658 | |
3659 ptr_type = build_pointer_type (type); | |
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
|
3660 addr = create_tmp_reg (ptr_type, get_name (parm)); |
0 | 3661 DECL_IGNORED_P (addr) = 0; |
3662 local = build_fold_indirect_ref (addr); | |
3663 | |
3664 t = built_in_decls[BUILT_IN_ALLOCA]; | |
3665 t = build_call_expr (t, 1, DECL_SIZE_UNIT (parm)); | |
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
|
3666 /* The call has been built for a variable-sized object. */ |
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
|
3667 ALLOCA_FOR_VAR_P (t) = 1; |
0 | 3668 t = fold_convert (ptr_type, t); |
3669 t = build2 (MODIFY_EXPR, TREE_TYPE (addr), addr, t); | |
3670 gimplify_and_add (t, &stmts); | |
3671 } | |
3672 | |
3673 gimplify_assign (local, parm, &stmts); | |
3674 | |
3675 SET_DECL_VALUE_EXPR (parm, local); | |
3676 DECL_HAS_VALUE_EXPR_P (parm) = 1; | |
3677 } | |
3678 } | |
3679 } | |
3680 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3681 VEC_free (tree, heap, fnargs); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3682 |
0 | 3683 return stmts; |
3684 } | |
3685 | |
3686 /* Compute the size and offset from the start of the stacked arguments for a | |
3687 parm passed in mode PASSED_MODE and with type TYPE. | |
3688 | |
3689 INITIAL_OFFSET_PTR points to the current offset into the stacked | |
3690 arguments. | |
3691 | |
3692 The starting offset and size for this parm are returned in | |
3693 LOCATE->OFFSET and LOCATE->SIZE, respectively. When IN_REGS is | |
3694 nonzero, the offset is that of stack slot, which is returned in | |
3695 LOCATE->SLOT_OFFSET. LOCATE->ALIGNMENT_PAD is the amount of | |
3696 padding required from the initial offset ptr to the stack slot. | |
3697 | |
3698 IN_REGS is nonzero if the argument will be passed in registers. It will | |
3699 never be set if REG_PARM_STACK_SPACE is not defined. | |
3700 | |
3701 FNDECL is the function in which the argument was defined. | |
3702 | |
3703 There are two types of rounding that are done. The first, controlled by | |
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
|
3704 TARGET_FUNCTION_ARG_BOUNDARY, forces the offset from the start of the |
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
|
3705 argument list to be aligned to the specific boundary (in bits). This |
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
|
3706 rounding affects the initial and starting offsets, but not the argument |
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
|
3707 size. |
0 | 3708 |
3709 The second, controlled by FUNCTION_ARG_PADDING and PARM_BOUNDARY, | |
3710 optionally rounds the size of the parm to PARM_BOUNDARY. The | |
3711 initial offset is not affected by this rounding, while the size always | |
3712 is and the starting offset may be. */ | |
3713 | |
3714 /* LOCATE->OFFSET will be negative for ARGS_GROW_DOWNWARD case; | |
3715 INITIAL_OFFSET_PTR is positive because locate_and_pad_parm's | |
3716 callers pass in the total size of args so far as | |
3717 INITIAL_OFFSET_PTR. LOCATE->SIZE is always positive. */ | |
3718 | |
3719 void | |
3720 locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, | |
3721 int partial, tree fndecl ATTRIBUTE_UNUSED, | |
3722 struct args_size *initial_offset_ptr, | |
3723 struct locate_and_pad_arg_data *locate) | |
3724 { | |
3725 tree sizetree; | |
3726 enum direction where_pad; | |
3727 unsigned int boundary; | |
3728 int reg_parm_stack_space = 0; | |
3729 int part_size_in_regs; | |
3730 | |
3731 #ifdef REG_PARM_STACK_SPACE | |
3732 reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl); | |
3733 | |
3734 /* If we have found a stack parm before we reach the end of the | |
3735 area reserved for registers, skip that area. */ | |
3736 if (! in_regs) | |
3737 { | |
3738 if (reg_parm_stack_space > 0) | |
3739 { | |
3740 if (initial_offset_ptr->var) | |
3741 { | |
3742 initial_offset_ptr->var | |
3743 = size_binop (MAX_EXPR, ARGS_SIZE_TREE (*initial_offset_ptr), | |
3744 ssize_int (reg_parm_stack_space)); | |
3745 initial_offset_ptr->constant = 0; | |
3746 } | |
3747 else if (initial_offset_ptr->constant < reg_parm_stack_space) | |
3748 initial_offset_ptr->constant = reg_parm_stack_space; | |
3749 } | |
3750 } | |
3751 #endif /* REG_PARM_STACK_SPACE */ | |
3752 | |
3753 part_size_in_regs = (reg_parm_stack_space == 0 ? partial : 0); | |
3754 | |
3755 sizetree | |
3756 = type ? size_in_bytes (type) : size_int (GET_MODE_SIZE (passed_mode)); | |
3757 where_pad = FUNCTION_ARG_PADDING (passed_mode, type); | |
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
|
3758 boundary = targetm.calls.function_arg_boundary (passed_mode, type); |
0 | 3759 locate->where_pad = where_pad; |
3760 | |
3761 /* Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT. */ | |
3762 if (boundary > MAX_SUPPORTED_STACK_ALIGNMENT) | |
3763 boundary = MAX_SUPPORTED_STACK_ALIGNMENT; | |
3764 | |
3765 locate->boundary = boundary; | |
3766 | |
3767 if (SUPPORTS_STACK_ALIGNMENT) | |
3768 { | |
3769 /* stack_alignment_estimated can't change after stack has been | |
3770 realigned. */ | |
3771 if (crtl->stack_alignment_estimated < boundary) | |
3772 { | |
3773 if (!crtl->stack_realign_processed) | |
3774 crtl->stack_alignment_estimated = boundary; | |
3775 else | |
3776 { | |
3777 /* If stack is realigned and stack alignment value | |
3778 hasn't been finalized, it is OK not to increase | |
3779 stack_alignment_estimated. The bigger alignment | |
3780 requirement is recorded in stack_alignment_needed | |
3781 below. */ | |
3782 gcc_assert (!crtl->stack_realign_finalized | |
3783 && crtl->stack_realign_needed); | |
3784 } | |
3785 } | |
3786 } | |
3787 | |
3788 /* Remember if the outgoing parameter requires extra alignment on the | |
3789 calling function side. */ | |
3790 if (crtl->stack_alignment_needed < boundary) | |
3791 crtl->stack_alignment_needed = boundary; | |
3792 if (crtl->preferred_stack_boundary < boundary) | |
3793 crtl->preferred_stack_boundary = boundary; | |
3794 | |
3795 #ifdef ARGS_GROW_DOWNWARD | |
3796 locate->slot_offset.constant = -initial_offset_ptr->constant; | |
3797 if (initial_offset_ptr->var) | |
3798 locate->slot_offset.var = size_binop (MINUS_EXPR, ssize_int (0), | |
3799 initial_offset_ptr->var); | |
3800 | |
3801 { | |
3802 tree s2 = sizetree; | |
3803 if (where_pad != none | |
3804 && (!host_integerp (sizetree, 1) | |
3805 || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % PARM_BOUNDARY)) | |
3806 s2 = round_up (s2, PARM_BOUNDARY / BITS_PER_UNIT); | |
3807 SUB_PARM_SIZE (locate->slot_offset, s2); | |
3808 } | |
3809 | |
3810 locate->slot_offset.constant += part_size_in_regs; | |
3811 | |
3812 if (!in_regs | |
3813 #ifdef REG_PARM_STACK_SPACE | |
3814 || REG_PARM_STACK_SPACE (fndecl) > 0 | |
3815 #endif | |
3816 ) | |
3817 pad_to_arg_alignment (&locate->slot_offset, boundary, | |
3818 &locate->alignment_pad); | |
3819 | |
3820 locate->size.constant = (-initial_offset_ptr->constant | |
3821 - locate->slot_offset.constant); | |
3822 if (initial_offset_ptr->var) | |
3823 locate->size.var = size_binop (MINUS_EXPR, | |
3824 size_binop (MINUS_EXPR, | |
3825 ssize_int (0), | |
3826 initial_offset_ptr->var), | |
3827 locate->slot_offset.var); | |
3828 | |
3829 /* Pad_below needs the pre-rounded size to know how much to pad | |
3830 below. */ | |
3831 locate->offset = locate->slot_offset; | |
3832 if (where_pad == downward) | |
3833 pad_below (&locate->offset, passed_mode, sizetree); | |
3834 | |
3835 #else /* !ARGS_GROW_DOWNWARD */ | |
3836 if (!in_regs | |
3837 #ifdef REG_PARM_STACK_SPACE | |
3838 || REG_PARM_STACK_SPACE (fndecl) > 0 | |
3839 #endif | |
3840 ) | |
3841 pad_to_arg_alignment (initial_offset_ptr, boundary, | |
3842 &locate->alignment_pad); | |
3843 locate->slot_offset = *initial_offset_ptr; | |
3844 | |
3845 #ifdef PUSH_ROUNDING | |
3846 if (passed_mode != BLKmode) | |
3847 sizetree = size_int (PUSH_ROUNDING (TREE_INT_CST_LOW (sizetree))); | |
3848 #endif | |
3849 | |
3850 /* Pad_below needs the pre-rounded size to know how much to pad below | |
3851 so this must be done before rounding up. */ | |
3852 locate->offset = locate->slot_offset; | |
3853 if (where_pad == downward) | |
3854 pad_below (&locate->offset, passed_mode, sizetree); | |
3855 | |
3856 if (where_pad != none | |
3857 && (!host_integerp (sizetree, 1) | |
3858 || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % PARM_BOUNDARY)) | |
3859 sizetree = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT); | |
3860 | |
3861 ADD_PARM_SIZE (locate->size, sizetree); | |
3862 | |
3863 locate->size.constant -= part_size_in_regs; | |
3864 #endif /* ARGS_GROW_DOWNWARD */ | |
3865 | |
3866 #ifdef FUNCTION_ARG_OFFSET | |
3867 locate->offset.constant += FUNCTION_ARG_OFFSET (passed_mode, type); | |
3868 #endif | |
3869 } | |
3870 | |
3871 /* Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY. | |
3872 BOUNDARY is measured in bits, but must be a multiple of a storage unit. */ | |
3873 | |
3874 static void | |
3875 pad_to_arg_alignment (struct args_size *offset_ptr, int boundary, | |
3876 struct args_size *alignment_pad) | |
3877 { | |
3878 tree save_var = NULL_TREE; | |
3879 HOST_WIDE_INT save_constant = 0; | |
3880 int boundary_in_bytes = boundary / BITS_PER_UNIT; | |
3881 HOST_WIDE_INT sp_offset = STACK_POINTER_OFFSET; | |
3882 | |
3883 #ifdef SPARC_STACK_BOUNDARY_HACK | |
3884 /* ??? The SPARC port may claim a STACK_BOUNDARY higher than | |
3885 the real alignment of %sp. However, when it does this, the | |
3886 alignment of %sp+STACK_POINTER_OFFSET is STACK_BOUNDARY. */ | |
3887 if (SPARC_STACK_BOUNDARY_HACK) | |
3888 sp_offset = 0; | |
3889 #endif | |
3890 | |
3891 if (boundary > PARM_BOUNDARY) | |
3892 { | |
3893 save_var = offset_ptr->var; | |
3894 save_constant = offset_ptr->constant; | |
3895 } | |
3896 | |
3897 alignment_pad->var = NULL_TREE; | |
3898 alignment_pad->constant = 0; | |
3899 | |
3900 if (boundary > BITS_PER_UNIT) | |
3901 { | |
3902 if (offset_ptr->var) | |
3903 { | |
3904 tree sp_offset_tree = ssize_int (sp_offset); | |
3905 tree offset = size_binop (PLUS_EXPR, | |
3906 ARGS_SIZE_TREE (*offset_ptr), | |
3907 sp_offset_tree); | |
3908 #ifdef ARGS_GROW_DOWNWARD | |
3909 tree rounded = round_down (offset, boundary / BITS_PER_UNIT); | |
3910 #else | |
3911 tree rounded = round_up (offset, boundary / BITS_PER_UNIT); | |
3912 #endif | |
3913 | |
3914 offset_ptr->var = size_binop (MINUS_EXPR, rounded, sp_offset_tree); | |
3915 /* ARGS_SIZE_TREE includes constant term. */ | |
3916 offset_ptr->constant = 0; | |
3917 if (boundary > PARM_BOUNDARY) | |
3918 alignment_pad->var = size_binop (MINUS_EXPR, offset_ptr->var, | |
3919 save_var); | |
3920 } | |
3921 else | |
3922 { | |
3923 offset_ptr->constant = -sp_offset + | |
3924 #ifdef ARGS_GROW_DOWNWARD | |
3925 FLOOR_ROUND (offset_ptr->constant + sp_offset, boundary_in_bytes); | |
3926 #else | |
3927 CEIL_ROUND (offset_ptr->constant + sp_offset, boundary_in_bytes); | |
3928 #endif | |
3929 if (boundary > PARM_BOUNDARY) | |
3930 alignment_pad->constant = offset_ptr->constant - save_constant; | |
3931 } | |
3932 } | |
3933 } | |
3934 | |
3935 static void | |
3936 pad_below (struct args_size *offset_ptr, enum machine_mode passed_mode, tree sizetree) | |
3937 { | |
3938 if (passed_mode != BLKmode) | |
3939 { | |
3940 if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY) | |
3941 offset_ptr->constant | |
3942 += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1) | |
3943 / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT) | |
3944 - GET_MODE_SIZE (passed_mode)); | |
3945 } | |
3946 else | |
3947 { | |
3948 if (TREE_CODE (sizetree) != INTEGER_CST | |
3949 || (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY) | |
3950 { | |
3951 /* Round the size up to multiple of PARM_BOUNDARY bits. */ | |
3952 tree s2 = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT); | |
3953 /* Add it in. */ | |
3954 ADD_PARM_SIZE (*offset_ptr, s2); | |
3955 SUB_PARM_SIZE (*offset_ptr, sizetree); | |
3956 } | |
3957 } | |
3958 } | |
3959 | |
3960 | |
3961 /* True if register REGNO was alive at a place where `setjmp' was | |
3962 called and was set more than once or is an argument. Such regs may | |
3963 be clobbered by `longjmp'. */ | |
3964 | |
3965 static bool | |
3966 regno_clobbered_at_setjmp (bitmap setjmp_crosses, int regno) | |
3967 { | |
3968 /* There appear to be cases where some local vars never reach the | |
3969 backend but have bogus regnos. */ | |
3970 if (regno >= max_reg_num ()) | |
3971 return false; | |
3972 | |
3973 return ((REG_N_SETS (regno) > 1 | |
3974 || REGNO_REG_SET_P (df_get_live_out (ENTRY_BLOCK_PTR), regno)) | |
3975 && REGNO_REG_SET_P (setjmp_crosses, regno)); | |
3976 } | |
3977 | |
3978 /* Walk the tree of blocks describing the binding levels within a | |
3979 function and warn about variables the might be killed by setjmp or | |
3980 vfork. This is done after calling flow_analysis before register | |
3981 allocation since that will clobber the pseudo-regs to hard | |
3982 regs. */ | |
3983 | |
3984 static void | |
3985 setjmp_vars_warning (bitmap setjmp_crosses, tree block) | |
3986 { | |
3987 tree decl, sub; | |
3988 | |
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
|
3989 for (decl = BLOCK_VARS (block); decl; decl = DECL_CHAIN (decl)) |
0 | 3990 { |
3991 if (TREE_CODE (decl) == VAR_DECL | |
3992 && DECL_RTL_SET_P (decl) | |
3993 && REG_P (DECL_RTL (decl)) | |
3994 && regno_clobbered_at_setjmp (setjmp_crosses, REGNO (DECL_RTL (decl)))) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
3995 warning (OPT_Wclobbered, "variable %q+D might be clobbered by" |
0 | 3996 " %<longjmp%> or %<vfork%>", decl); |
3997 } | |
3998 | |
3999 for (sub = BLOCK_SUBBLOCKS (block); sub; sub = BLOCK_CHAIN (sub)) | |
4000 setjmp_vars_warning (setjmp_crosses, sub); | |
4001 } | |
4002 | |
4003 /* Do the appropriate part of setjmp_vars_warning | |
4004 but for arguments instead of local variables. */ | |
4005 | |
4006 static void | |
4007 setjmp_args_warning (bitmap setjmp_crosses) | |
4008 { | |
4009 tree decl; | |
4010 for (decl = DECL_ARGUMENTS (current_function_decl); | |
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
|
4011 decl; decl = DECL_CHAIN (decl)) |
0 | 4012 if (DECL_RTL (decl) != 0 |
4013 && REG_P (DECL_RTL (decl)) | |
4014 && regno_clobbered_at_setjmp (setjmp_crosses, REGNO (DECL_RTL (decl)))) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4015 warning (OPT_Wclobbered, |
0 | 4016 "argument %q+D might be clobbered by %<longjmp%> or %<vfork%>", |
4017 decl); | |
4018 } | |
4019 | |
4020 /* Generate warning messages for variables live across setjmp. */ | |
4021 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4022 void |
0 | 4023 generate_setjmp_warnings (void) |
4024 { | |
4025 bitmap setjmp_crosses = regstat_get_setjmp_crosses (); | |
4026 | |
4027 if (n_basic_blocks == NUM_FIXED_BLOCKS | |
4028 || bitmap_empty_p (setjmp_crosses)) | |
4029 return; | |
4030 | |
4031 setjmp_vars_warning (setjmp_crosses, DECL_INITIAL (current_function_decl)); | |
4032 setjmp_args_warning (setjmp_crosses); | |
4033 } | |
4034 | |
4035 | |
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
|
4036 /* Reverse the order of elements in the fragment chain T of blocks, |
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
|
4037 and return the new head of the chain (old last element). */ |
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
|
4038 |
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
|
4039 static tree |
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
|
4040 block_fragments_nreverse (tree t) |
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
|
4041 { |
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
|
4042 tree prev = 0, block, next; |
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
|
4043 for (block = t; block; block = next) |
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
|
4044 { |
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
|
4045 next = BLOCK_FRAGMENT_CHAIN (block); |
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
|
4046 BLOCK_FRAGMENT_CHAIN (block) = prev; |
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
|
4047 prev = block; |
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
|
4048 } |
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
|
4049 return prev; |
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
|
4050 } |
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
|
4051 |
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
|
4052 /* Reverse the order of elements in the chain T of blocks, |
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
|
4053 and return the new head of the chain (old last element). |
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
|
4054 Also do the same on subblocks and reverse the order of elements |
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
|
4055 in BLOCK_FRAGMENT_CHAIN as well. */ |
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
|
4056 |
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
|
4057 static tree |
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
|
4058 blocks_nreverse_all (tree t) |
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
|
4059 { |
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
|
4060 tree prev = 0, block, next; |
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
|
4061 for (block = t; block; block = next) |
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
|
4062 { |
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
|
4063 next = BLOCK_CHAIN (block); |
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
|
4064 BLOCK_CHAIN (block) = prev; |
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
|
4065 BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block)); |
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
|
4066 if (BLOCK_FRAGMENT_CHAIN (block) |
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
|
4067 && BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE) |
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
|
4068 BLOCK_FRAGMENT_CHAIN (block) |
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
|
4069 = block_fragments_nreverse (BLOCK_FRAGMENT_CHAIN (block)); |
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
|
4070 prev = block; |
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
|
4071 } |
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
|
4072 return prev; |
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
|
4073 } |
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
|
4074 |
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
|
4075 |
0 | 4076 /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END}, |
4077 and create duplicate blocks. */ | |
4078 /* ??? Need an option to either create block fragments or to create | |
4079 abstract origin duplicates of a source block. It really depends | |
4080 on what optimization has been performed. */ | |
4081 | |
4082 void | |
4083 reorder_blocks (void) | |
4084 { | |
4085 tree block = DECL_INITIAL (current_function_decl); | |
4086 VEC(tree,heap) *block_stack; | |
4087 | |
4088 if (block == NULL_TREE) | |
4089 return; | |
4090 | |
4091 block_stack = VEC_alloc (tree, heap, 10); | |
4092 | |
4093 /* Reset the TREE_ASM_WRITTEN bit for all blocks. */ | |
4094 clear_block_marks (block); | |
4095 | |
4096 /* Prune the old trees away, so that they don't get in the way. */ | |
4097 BLOCK_SUBBLOCKS (block) = NULL_TREE; | |
4098 BLOCK_CHAIN (block) = NULL_TREE; | |
4099 | |
4100 /* Recreate the block tree from the note nesting. */ | |
4101 reorder_blocks_1 (get_insns (), block, &block_stack); | |
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
|
4102 BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block)); |
0 | 4103 |
4104 VEC_free (tree, heap, block_stack); | |
4105 } | |
4106 | |
4107 /* Helper function for reorder_blocks. Reset TREE_ASM_WRITTEN. */ | |
4108 | |
4109 void | |
4110 clear_block_marks (tree block) | |
4111 { | |
4112 while (block) | |
4113 { | |
4114 TREE_ASM_WRITTEN (block) = 0; | |
4115 clear_block_marks (BLOCK_SUBBLOCKS (block)); | |
4116 block = BLOCK_CHAIN (block); | |
4117 } | |
4118 } | |
4119 | |
4120 static void | |
4121 reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack) | |
4122 { | |
4123 rtx insn; | |
4124 | |
4125 for (insn = insns; insn; insn = NEXT_INSN (insn)) | |
4126 { | |
4127 if (NOTE_P (insn)) | |
4128 { | |
4129 if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_BEG) | |
4130 { | |
4131 tree block = NOTE_BLOCK (insn); | |
4132 tree origin; | |
4133 | |
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
|
4134 gcc_assert (BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE); |
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
|
4135 origin = block; |
0 | 4136 |
4137 /* If we have seen this block before, that means it now | |
4138 spans multiple address regions. Create a new fragment. */ | |
4139 if (TREE_ASM_WRITTEN (block)) | |
4140 { | |
4141 tree new_block = copy_node (block); | |
4142 | |
4143 BLOCK_FRAGMENT_ORIGIN (new_block) = origin; | |
4144 BLOCK_FRAGMENT_CHAIN (new_block) | |
4145 = BLOCK_FRAGMENT_CHAIN (origin); | |
4146 BLOCK_FRAGMENT_CHAIN (origin) = new_block; | |
4147 | |
4148 NOTE_BLOCK (insn) = new_block; | |
4149 block = new_block; | |
4150 } | |
4151 | |
4152 BLOCK_SUBBLOCKS (block) = 0; | |
4153 TREE_ASM_WRITTEN (block) = 1; | |
4154 /* When there's only one block for the entire function, | |
4155 current_block == block and we mustn't do this, it | |
4156 will cause infinite recursion. */ | |
4157 if (block != current_block) | |
4158 { | |
4159 if (block != origin) | |
4160 gcc_assert (BLOCK_SUPERCONTEXT (origin) == current_block); | |
4161 | |
4162 BLOCK_SUPERCONTEXT (block) = current_block; | |
4163 BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (current_block); | |
4164 BLOCK_SUBBLOCKS (current_block) = block; | |
4165 current_block = origin; | |
4166 } | |
4167 VEC_safe_push (tree, heap, *p_block_stack, block); | |
4168 } | |
4169 else if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_END) | |
4170 { | |
4171 NOTE_BLOCK (insn) = VEC_pop (tree, *p_block_stack); | |
4172 current_block = BLOCK_SUPERCONTEXT (current_block); | |
4173 } | |
4174 } | |
4175 } | |
4176 } | |
4177 | |
4178 /* Reverse the order of elements in the chain T of blocks, | |
4179 and return the new head of the chain (old last element). */ | |
4180 | |
4181 tree | |
4182 blocks_nreverse (tree t) | |
4183 { | |
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
|
4184 tree prev = 0, block, next; |
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
|
4185 for (block = t; block; block = next) |
0 | 4186 { |
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
|
4187 next = BLOCK_CHAIN (block); |
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
|
4188 BLOCK_CHAIN (block) = prev; |
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
|
4189 prev = block; |
0 | 4190 } |
4191 return prev; | |
4192 } | |
4193 | |
4194 /* Count the subblocks of the list starting with BLOCK. If VECTOR is | |
4195 non-NULL, list them all into VECTOR, in a depth-first preorder | |
4196 traversal of the block tree. Also clear TREE_ASM_WRITTEN in all | |
4197 blocks. */ | |
4198 | |
4199 static int | |
4200 all_blocks (tree block, tree *vector) | |
4201 { | |
4202 int n_blocks = 0; | |
4203 | |
4204 while (block) | |
4205 { | |
4206 TREE_ASM_WRITTEN (block) = 0; | |
4207 | |
4208 /* Record this block. */ | |
4209 if (vector) | |
4210 vector[n_blocks] = block; | |
4211 | |
4212 ++n_blocks; | |
4213 | |
4214 /* Record the subblocks, and their subblocks... */ | |
4215 n_blocks += all_blocks (BLOCK_SUBBLOCKS (block), | |
4216 vector ? vector + n_blocks : 0); | |
4217 block = BLOCK_CHAIN (block); | |
4218 } | |
4219 | |
4220 return n_blocks; | |
4221 } | |
4222 | |
4223 /* Return a vector containing all the blocks rooted at BLOCK. The | |
4224 number of elements in the vector is stored in N_BLOCKS_P. The | |
4225 vector is dynamically allocated; it is the caller's responsibility | |
4226 to call `free' on the pointer returned. */ | |
4227 | |
4228 static tree * | |
4229 get_block_vector (tree block, int *n_blocks_p) | |
4230 { | |
4231 tree *block_vector; | |
4232 | |
4233 *n_blocks_p = all_blocks (block, NULL); | |
4234 block_vector = XNEWVEC (tree, *n_blocks_p); | |
4235 all_blocks (block, block_vector); | |
4236 | |
4237 return block_vector; | |
4238 } | |
4239 | |
4240 static GTY(()) int next_block_index = 2; | |
4241 | |
4242 /* Set BLOCK_NUMBER for all the blocks in FN. */ | |
4243 | |
4244 void | |
4245 number_blocks (tree fn) | |
4246 { | |
4247 int i; | |
4248 int n_blocks; | |
4249 tree *block_vector; | |
4250 | |
4251 /* For SDB and XCOFF debugging output, we start numbering the blocks | |
4252 from 1 within each function, rather than keeping a running | |
4253 count. */ | |
4254 #if defined (SDB_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
4255 if (write_symbols == SDB_DEBUG || write_symbols == XCOFF_DEBUG) | |
4256 next_block_index = 1; | |
4257 #endif | |
4258 | |
4259 block_vector = get_block_vector (DECL_INITIAL (fn), &n_blocks); | |
4260 | |
4261 /* The top-level BLOCK isn't numbered at all. */ | |
4262 for (i = 1; i < n_blocks; ++i) | |
4263 /* We number the blocks from two. */ | |
4264 BLOCK_NUMBER (block_vector[i]) = next_block_index++; | |
4265 | |
4266 free (block_vector); | |
4267 | |
4268 return; | |
4269 } | |
4270 | |
4271 /* If VAR is present in a subblock of BLOCK, return the subblock. */ | |
4272 | |
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
|
4273 DEBUG_FUNCTION tree |
0 | 4274 debug_find_var_in_block_tree (tree var, tree block) |
4275 { | |
4276 tree t; | |
4277 | |
4278 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t)) | |
4279 if (t == var) | |
4280 return block; | |
4281 | |
4282 for (t = BLOCK_SUBBLOCKS (block); t; t = TREE_CHAIN (t)) | |
4283 { | |
4284 tree ret = debug_find_var_in_block_tree (var, t); | |
4285 if (ret) | |
4286 return ret; | |
4287 } | |
4288 | |
4289 return NULL_TREE; | |
4290 } | |
4291 | |
4292 /* Keep track of whether we're in a dummy function context. If we are, | |
4293 we don't want to invoke the set_current_function hook, because we'll | |
4294 get into trouble if the hook calls target_reinit () recursively or | |
4295 when the initial initialization is not yet complete. */ | |
4296 | |
4297 static bool in_dummy_function; | |
4298 | |
4299 /* Invoke the target hook when setting cfun. Update the optimization options | |
4300 if the function uses different options than the default. */ | |
4301 | |
4302 static void | |
4303 invoke_set_current_function_hook (tree fndecl) | |
4304 { | |
4305 if (!in_dummy_function) | |
4306 { | |
4307 tree opts = ((fndecl) | |
4308 ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) | |
4309 : optimization_default_node); | |
4310 | |
4311 if (!opts) | |
4312 opts = optimization_default_node; | |
4313 | |
4314 /* Change optimization options if needed. */ | |
4315 if (optimization_current_node != opts) | |
4316 { | |
4317 optimization_current_node = opts; | |
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
|
4318 cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts)); |
0 | 4319 } |
4320 | |
4321 targetm.set_current_function (fndecl); | |
4322 } | |
4323 } | |
4324 | |
4325 /* cfun should never be set directly; use this function. */ | |
4326 | |
4327 void | |
4328 set_cfun (struct function *new_cfun) | |
4329 { | |
4330 if (cfun != new_cfun) | |
4331 { | |
4332 cfun = new_cfun; | |
4333 invoke_set_current_function_hook (new_cfun ? new_cfun->decl : NULL_TREE); | |
4334 } | |
4335 } | |
4336 | |
4337 /* Initialized with NOGC, making this poisonous to the garbage collector. */ | |
4338 | |
4339 static VEC(function_p,heap) *cfun_stack; | |
4340 | |
4341 /* Push the current cfun onto the stack, and set cfun to new_cfun. */ | |
4342 | |
4343 void | |
4344 push_cfun (struct function *new_cfun) | |
4345 { | |
4346 VEC_safe_push (function_p, heap, cfun_stack, cfun); | |
4347 set_cfun (new_cfun); | |
4348 } | |
4349 | |
4350 /* Pop cfun from the stack. */ | |
4351 | |
4352 void | |
4353 pop_cfun (void) | |
4354 { | |
4355 struct function *new_cfun = VEC_pop (function_p, cfun_stack); | |
4356 set_cfun (new_cfun); | |
4357 } | |
4358 | |
4359 /* Return value of funcdef and increase it. */ | |
4360 int | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4361 get_next_funcdef_no (void) |
0 | 4362 { |
4363 return funcdef_no++; | |
4364 } | |
4365 | |
4366 /* Allocate a function structure for FNDECL and set its contents | |
4367 to the defaults. Set cfun to the newly-allocated object. | |
4368 Some of the helper functions invoked during initialization assume | |
4369 that cfun has already been set. Therefore, assign the new object | |
4370 directly into cfun and invoke the back end hook explicitly at the | |
4371 very end, rather than initializing a temporary and calling set_cfun | |
4372 on it. | |
4373 | |
4374 ABSTRACT_P is true if this is a function that will never be seen by | |
4375 the middle-end. Such functions are front-end concepts (like C++ | |
4376 function templates) that do not correspond directly to functions | |
4377 placed in object files. */ | |
4378 | |
4379 void | |
4380 allocate_struct_function (tree fndecl, bool abstract_p) | |
4381 { | |
4382 tree result; | |
4383 tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE; | |
4384 | |
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
|
4385 cfun = ggc_alloc_cleared_function (); |
0 | 4386 |
4387 init_eh_for_function (); | |
4388 | |
4389 if (init_machine_status) | |
4390 cfun->machine = (*init_machine_status) (); | |
4391 | |
4392 #ifdef OVERRIDE_ABI_FORMAT | |
4393 OVERRIDE_ABI_FORMAT (fndecl); | |
4394 #endif | |
4395 | |
4396 invoke_set_current_function_hook (fndecl); | |
4397 | |
4398 if (fndecl != NULL_TREE) | |
4399 { | |
4400 DECL_STRUCT_FUNCTION (fndecl) = cfun; | |
4401 cfun->decl = fndecl; | |
4402 current_function_funcdef_no = get_next_funcdef_no (); | |
4403 | |
4404 result = DECL_RESULT (fndecl); | |
4405 if (!abstract_p && aggregate_value_p (result, fndecl)) | |
4406 { | |
4407 #ifdef PCC_STATIC_STRUCT_RETURN | |
4408 cfun->returns_pcc_struct = 1; | |
4409 #endif | |
4410 cfun->returns_struct = 1; | |
4411 } | |
4412 | |
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
|
4413 cfun->stdarg = stdarg_p (fntype); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4414 |
0 | 4415 /* Assume all registers in stdarg functions need to be saved. */ |
4416 cfun->va_list_gpr_size = VA_LIST_MAX_GPR_SIZE; | |
4417 cfun->va_list_fpr_size = VA_LIST_MAX_FPR_SIZE; | |
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
|
4418 |
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
|
4419 /* ??? This could be set on a per-function basis by the front-end |
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
|
4420 but is this worth the hassle? */ |
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
|
4421 cfun->can_throw_non_call_exceptions = flag_non_call_exceptions; |
0 | 4422 } |
4423 } | |
4424 | |
4425 /* This is like allocate_struct_function, but pushes a new cfun for FNDECL | |
4426 instead of just setting it. */ | |
4427 | |
4428 void | |
4429 push_struct_function (tree fndecl) | |
4430 { | |
4431 VEC_safe_push (function_p, heap, cfun_stack, cfun); | |
4432 allocate_struct_function (fndecl, false); | |
4433 } | |
4434 | |
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
|
4435 /* Reset crtl and other non-struct-function variables to defaults as |
0 | 4436 appropriate for emitting rtl at the start of a function. */ |
4437 | |
4438 static void | |
4439 prepare_function_start (void) | |
4440 { | |
4441 gcc_assert (!crtl->emit.x_last_insn); | |
4442 init_temp_slots (); | |
4443 init_emit (); | |
4444 init_varasm_status (); | |
4445 init_expr (); | |
4446 default_rtl_profile (); | |
4447 | |
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
|
4448 if (flag_stack_usage) |
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
|
4449 { |
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
|
4450 cfun->su = ggc_alloc_cleared_stack_usage (); |
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
|
4451 cfun->su->static_stack_size = -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
|
4452 } |
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
|
4453 |
0 | 4454 cse_not_expected = ! optimize; |
4455 | |
4456 /* Caller save not needed yet. */ | |
4457 caller_save_needed = 0; | |
4458 | |
4459 /* We haven't done register allocation yet. */ | |
4460 reg_renumber = 0; | |
4461 | |
4462 /* Indicate that we have not instantiated virtual registers yet. */ | |
4463 virtuals_instantiated = 0; | |
4464 | |
4465 /* Indicate that we want CONCATs now. */ | |
4466 generating_concat_p = 1; | |
4467 | |
4468 /* Indicate we have no need of a frame pointer yet. */ | |
4469 frame_pointer_needed = 0; | |
4470 } | |
4471 | |
4472 /* Initialize the rtl expansion mechanism so that we can do simple things | |
4473 like generate sequences. This is used to provide a context during global | |
4474 initialization of some passes. You must call expand_dummy_function_end | |
4475 to exit this context. */ | |
4476 | |
4477 void | |
4478 init_dummy_function_start (void) | |
4479 { | |
4480 gcc_assert (!in_dummy_function); | |
4481 in_dummy_function = true; | |
4482 push_struct_function (NULL_TREE); | |
4483 prepare_function_start (); | |
4484 } | |
4485 | |
4486 /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node) | |
4487 and initialize static variables for generating RTL for the statements | |
4488 of the function. */ | |
4489 | |
4490 void | |
4491 init_function_start (tree subr) | |
4492 { | |
4493 if (subr && DECL_STRUCT_FUNCTION (subr)) | |
4494 set_cfun (DECL_STRUCT_FUNCTION (subr)); | |
4495 else | |
4496 allocate_struct_function (subr, false); | |
4497 prepare_function_start (); | |
4498 | |
4499 /* Warn if this value is an aggregate type, | |
4500 regardless of which calling convention we are using for it. */ | |
4501 if (AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr)))) | |
4502 warning (OPT_Waggregate_return, "function returns an aggregate"); | |
4503 } | |
4504 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4505 /* Make sure all values used by the optimization passes have sane defaults. */ |
0 | 4506 unsigned int |
4507 init_function_for_compilation (void) | |
4508 { | |
4509 reg_renumber = 0; | |
4510 return 0; | |
4511 } | |
4512 | |
4513 struct rtl_opt_pass pass_init_function = | |
4514 { | |
4515 { | |
4516 RTL_PASS, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4517 "*init_function", /* name */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4518 NULL, /* gate */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4519 init_function_for_compilation, /* execute */ |
0 | 4520 NULL, /* sub */ |
4521 NULL, /* next */ | |
4522 0, /* static_pass_number */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4523 TV_NONE, /* tv_id */ |
0 | 4524 0, /* properties_required */ |
4525 0, /* properties_provided */ | |
4526 0, /* properties_destroyed */ | |
4527 0, /* todo_flags_start */ | |
4528 0 /* todo_flags_finish */ | |
4529 } | |
4530 }; | |
4531 | |
4532 | |
4533 void | |
4534 expand_main_function (void) | |
4535 { | |
4536 #if (defined(INVOKE__main) \ | |
4537 || (!defined(HAS_INIT_SECTION) \ | |
4538 && !defined(INIT_SECTION_ASM_OP) \ | |
4539 && !defined(INIT_ARRAY_SECTION_ASM_OP))) | |
4540 emit_library_call (init_one_libfunc (NAME__MAIN), LCT_NORMAL, VOIDmode, 0); | |
4541 #endif | |
4542 } | |
4543 | |
4544 /* Expand code to initialize the stack_protect_guard. This is invoked at | |
4545 the beginning of a function to be protected. */ | |
4546 | |
4547 #ifndef HAVE_stack_protect_set | |
4548 # define HAVE_stack_protect_set 0 | |
4549 # define gen_stack_protect_set(x,y) (gcc_unreachable (), NULL_RTX) | |
4550 #endif | |
4551 | |
4552 void | |
4553 stack_protect_prologue (void) | |
4554 { | |
4555 tree guard_decl = targetm.stack_protect_guard (); | |
4556 rtx x, y; | |
4557 | |
47
3bfb6c00c1e0
update it from 4.4.2 to 4.4.3.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
4558 x = expand_normal (crtl->stack_protect_guard); |
3bfb6c00c1e0
update it from 4.4.2 to 4.4.3.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
4559 y = expand_normal (guard_decl); |
0 | 4560 |
4561 /* Allow the target to copy from Y to X without leaking Y into a | |
4562 register. */ | |
4563 if (HAVE_stack_protect_set) | |
4564 { | |
4565 rtx insn = gen_stack_protect_set (x, y); | |
4566 if (insn) | |
4567 { | |
4568 emit_insn (insn); | |
4569 return; | |
4570 } | |
4571 } | |
4572 | |
4573 /* Otherwise do a straight move. */ | |
4574 emit_move_insn (x, y); | |
4575 } | |
4576 | |
4577 /* Expand code to verify the stack_protect_guard. This is invoked at | |
4578 the end of a function to be protected. */ | |
4579 | |
4580 #ifndef HAVE_stack_protect_test | |
4581 # define HAVE_stack_protect_test 0 | |
4582 # define gen_stack_protect_test(x, y, z) (gcc_unreachable (), NULL_RTX) | |
4583 #endif | |
4584 | |
4585 void | |
4586 stack_protect_epilogue (void) | |
4587 { | |
4588 tree guard_decl = targetm.stack_protect_guard (); | |
4589 rtx label = gen_label_rtx (); | |
4590 rtx x, y, tmp; | |
4591 | |
47
3bfb6c00c1e0
update it from 4.4.2 to 4.4.3.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
4592 x = expand_normal (crtl->stack_protect_guard); |
3bfb6c00c1e0
update it from 4.4.2 to 4.4.3.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
4593 y = expand_normal (guard_decl); |
0 | 4594 |
4595 /* Allow the target to compare Y with X without leaking either into | |
4596 a register. */ | |
4597 switch (HAVE_stack_protect_test != 0) | |
4598 { | |
4599 case 1: | |
4600 tmp = gen_stack_protect_test (x, y, label); | |
4601 if (tmp) | |
4602 { | |
4603 emit_insn (tmp); | |
4604 break; | |
4605 } | |
4606 /* FALLTHRU */ | |
4607 | |
4608 default: | |
4609 emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label); | |
4610 break; | |
4611 } | |
4612 | |
4613 /* The noreturn predictor has been moved to the tree level. The rtl-level | |
4614 predictors estimate this branch about 20%, which isn't enough to get | |
4615 things moved out of line. Since this is the only extant case of adding | |
4616 a noreturn function at the rtl level, it doesn't seem worth doing ought | |
4617 except adding the prediction by hand. */ | |
4618 tmp = get_last_insn (); | |
4619 if (JUMP_P (tmp)) | |
4620 predict_insn_def (tmp, PRED_NORETURN, TAKEN); | |
4621 | |
4622 expand_expr_stmt (targetm.stack_protect_fail ()); | |
4623 emit_label (label); | |
4624 } | |
4625 | |
4626 /* Start the RTL for a new function, and set variables used for | |
4627 emitting RTL. | |
4628 SUBR is the FUNCTION_DECL node. | |
4629 PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with | |
4630 the function's parameters, which must be run at any return statement. */ | |
4631 | |
4632 void | |
4633 expand_function_start (tree subr) | |
4634 { | |
4635 /* Make sure volatile mem refs aren't considered | |
4636 valid operands of arithmetic insns. */ | |
4637 init_recog_no_volatile (); | |
4638 | |
4639 crtl->profile | |
4640 = (profile_flag | |
4641 && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr)); | |
4642 | |
4643 crtl->limit_stack | |
4644 = (stack_limit_rtx != NULL_RTX && ! DECL_NO_LIMIT_STACK (subr)); | |
4645 | |
4646 /* Make the label for return statements to jump to. Do not special | |
4647 case machines with special return instructions -- they will be | |
4648 handled later during jump, ifcvt, or epilogue creation. */ | |
4649 return_label = gen_label_rtx (); | |
4650 | |
4651 /* Initialize rtx used to return the value. */ | |
4652 /* Do this before assign_parms so that we copy the struct value address | |
4653 before any library calls that assign parms might generate. */ | |
4654 | |
4655 /* Decide whether to return the value in memory or in a register. */ | |
4656 if (aggregate_value_p (DECL_RESULT (subr), subr)) | |
4657 { | |
4658 /* Returning something that won't go in a register. */ | |
4659 rtx value_address = 0; | |
4660 | |
4661 #ifdef PCC_STATIC_STRUCT_RETURN | |
4662 if (cfun->returns_pcc_struct) | |
4663 { | |
4664 int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr))); | |
4665 value_address = assemble_static_space (size); | |
4666 } | |
4667 else | |
4668 #endif | |
4669 { | |
4670 rtx sv = targetm.calls.struct_value_rtx (TREE_TYPE (subr), 2); | |
4671 /* Expect to be passed the address of a place to store the value. | |
4672 If it is passed as an argument, assign_parms will take care of | |
4673 it. */ | |
4674 if (sv) | |
4675 { | |
4676 value_address = gen_reg_rtx (Pmode); | |
4677 emit_move_insn (value_address, sv); | |
4678 } | |
4679 } | |
4680 if (value_address) | |
4681 { | |
4682 rtx x = value_address; | |
4683 if (!DECL_BY_REFERENCE (DECL_RESULT (subr))) | |
4684 { | |
4685 x = gen_rtx_MEM (DECL_MODE (DECL_RESULT (subr)), x); | |
4686 set_mem_attributes (x, DECL_RESULT (subr), 1); | |
4687 } | |
4688 SET_DECL_RTL (DECL_RESULT (subr), x); | |
4689 } | |
4690 } | |
4691 else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode) | |
4692 /* If return mode is void, this decl rtl should not be used. */ | |
4693 SET_DECL_RTL (DECL_RESULT (subr), NULL_RTX); | |
4694 else | |
4695 { | |
4696 /* Compute the return values into a pseudo reg, which we will copy | |
4697 into the true return register after the cleanups are done. */ | |
4698 tree return_type = TREE_TYPE (DECL_RESULT (subr)); | |
4699 if (TYPE_MODE (return_type) != BLKmode | |
4700 && targetm.calls.return_in_msb (return_type)) | |
4701 /* expand_function_end will insert the appropriate padding in | |
4702 this case. Use the return value's natural (unpadded) mode | |
4703 within the function proper. */ | |
4704 SET_DECL_RTL (DECL_RESULT (subr), | |
4705 gen_reg_rtx (TYPE_MODE (return_type))); | |
4706 else | |
4707 { | |
4708 /* In order to figure out what mode to use for the pseudo, we | |
4709 figure out what the mode of the eventual return register will | |
4710 actually be, and use that. */ | |
4711 rtx hard_reg = hard_function_value (return_type, subr, 0, 1); | |
4712 | |
4713 /* Structures that are returned in registers are not | |
4714 aggregate_value_p, so we may see a PARALLEL or a REG. */ | |
4715 if (REG_P (hard_reg)) | |
4716 SET_DECL_RTL (DECL_RESULT (subr), | |
4717 gen_reg_rtx (GET_MODE (hard_reg))); | |
4718 else | |
4719 { | |
4720 gcc_assert (GET_CODE (hard_reg) == PARALLEL); | |
4721 SET_DECL_RTL (DECL_RESULT (subr), gen_group_rtx (hard_reg)); | |
4722 } | |
4723 } | |
4724 | |
4725 /* Set DECL_REGISTER flag so that expand_function_end will copy the | |
4726 result to the real return register(s). */ | |
4727 DECL_REGISTER (DECL_RESULT (subr)) = 1; | |
4728 } | |
4729 | |
4730 /* Initialize rtx for parameters and local variables. | |
4731 In some cases this requires emitting insns. */ | |
4732 assign_parms (subr); | |
4733 | |
4734 /* If function gets a static chain arg, store it. */ | |
4735 if (cfun->static_chain_decl) | |
4736 { | |
4737 tree parm = cfun->static_chain_decl; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4738 rtx local, chain, insn; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4739 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4740 local = gen_reg_rtx (Pmode); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4741 chain = targetm.calls.static_chain (current_function_decl, true); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4742 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4743 set_decl_incoming_rtl (parm, chain, false); |
0 | 4744 SET_DECL_RTL (parm, local); |
4745 mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm)))); | |
4746 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4747 insn = emit_move_insn (local, chain); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4748 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4749 /* Mark the register as eliminable, similar to parameters. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4750 if (MEM_P (chain) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4751 && reg_mentioned_p (arg_pointer_rtx, XEXP (chain, 0))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4752 set_unique_reg_note (insn, REG_EQUIV, chain); |
0 | 4753 } |
4754 | |
4755 /* If the function receives a non-local goto, then store the | |
4756 bits we need to restore the frame pointer. */ | |
4757 if (cfun->nonlocal_goto_save_area) | |
4758 { | |
4759 tree t_save; | |
4760 rtx r_save; | |
4761 | |
4762 /* ??? We need to do this save early. Unfortunately here is | |
4763 before the frame variable gets declared. Help out... */ | |
4764 tree var = TREE_OPERAND (cfun->nonlocal_goto_save_area, 0); | |
4765 if (!DECL_RTL_SET_P (var)) | |
4766 expand_decl (var); | |
4767 | |
4768 t_save = build4 (ARRAY_REF, ptr_type_node, | |
4769 cfun->nonlocal_goto_save_area, | |
4770 integer_zero_node, NULL_TREE, NULL_TREE); | |
4771 r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE); | |
4772 r_save = convert_memory_address (Pmode, r_save); | |
4773 | |
4774 emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ()); | |
4775 update_nonlocal_goto_save_area (); | |
4776 } | |
4777 | |
4778 /* The following was moved from init_function_start. | |
4779 The move is supposed to make sdb output more accurate. */ | |
4780 /* Indicate the beginning of the function body, | |
4781 as opposed to parm setup. */ | |
4782 emit_note (NOTE_INSN_FUNCTION_BEG); | |
4783 | |
4784 gcc_assert (NOTE_P (get_last_insn ())); | |
4785 | |
4786 parm_birth_insn = get_last_insn (); | |
4787 | |
4788 if (crtl->profile) | |
4789 { | |
4790 #ifdef PROFILE_HOOK | |
4791 PROFILE_HOOK (current_function_funcdef_no); | |
4792 #endif | |
4793 } | |
4794 | |
4795 /* After the display initializations is where the stack checking | |
4796 probe should go. */ | |
4797 if(flag_stack_check) | |
4798 stack_check_probe_note = emit_note (NOTE_INSN_DELETED); | |
4799 | |
4800 /* Make sure there is a line number after the function entry setup code. */ | |
4801 force_next_line_note (); | |
4802 } | |
4803 | |
4804 /* Undo the effects of init_dummy_function_start. */ | |
4805 void | |
4806 expand_dummy_function_end (void) | |
4807 { | |
4808 gcc_assert (in_dummy_function); | |
4809 | |
4810 /* End any sequences that failed to be closed due to syntax errors. */ | |
4811 while (in_sequence_p ()) | |
4812 end_sequence (); | |
4813 | |
4814 /* Outside function body, can't compute type's actual size | |
4815 until next function's body starts. */ | |
4816 | |
4817 free_after_parsing (cfun); | |
4818 free_after_compilation (cfun); | |
4819 pop_cfun (); | |
4820 in_dummy_function = false; | |
4821 } | |
4822 | |
4823 /* Call DOIT for each hard register used as a return value from | |
4824 the current function. */ | |
4825 | |
4826 void | |
4827 diddle_return_value (void (*doit) (rtx, void *), void *arg) | |
4828 { | |
4829 rtx outgoing = crtl->return_rtx; | |
4830 | |
4831 if (! outgoing) | |
4832 return; | |
4833 | |
4834 if (REG_P (outgoing)) | |
4835 (*doit) (outgoing, arg); | |
4836 else if (GET_CODE (outgoing) == PARALLEL) | |
4837 { | |
4838 int i; | |
4839 | |
4840 for (i = 0; i < XVECLEN (outgoing, 0); i++) | |
4841 { | |
4842 rtx x = XEXP (XVECEXP (outgoing, 0, i), 0); | |
4843 | |
4844 if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER) | |
4845 (*doit) (x, arg); | |
4846 } | |
4847 } | |
4848 } | |
4849 | |
4850 static void | |
4851 do_clobber_return_reg (rtx reg, void *arg ATTRIBUTE_UNUSED) | |
4852 { | |
4853 emit_clobber (reg); | |
4854 } | |
4855 | |
4856 void | |
4857 clobber_return_register (void) | |
4858 { | |
4859 diddle_return_value (do_clobber_return_reg, NULL); | |
4860 | |
4861 /* In case we do use pseudo to return value, clobber it too. */ | |
4862 if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl))) | |
4863 { | |
4864 tree decl_result = DECL_RESULT (current_function_decl); | |
4865 rtx decl_rtl = DECL_RTL (decl_result); | |
4866 if (REG_P (decl_rtl) && REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER) | |
4867 { | |
4868 do_clobber_return_reg (decl_rtl, NULL); | |
4869 } | |
4870 } | |
4871 } | |
4872 | |
4873 static void | |
4874 do_use_return_reg (rtx reg, void *arg ATTRIBUTE_UNUSED) | |
4875 { | |
4876 emit_use (reg); | |
4877 } | |
4878 | |
4879 static void | |
4880 use_return_register (void) | |
4881 { | |
4882 diddle_return_value (do_use_return_reg, NULL); | |
4883 } | |
4884 | |
4885 /* Possibly warn about unused parameters. */ | |
4886 void | |
4887 do_warn_unused_parameter (tree fn) | |
4888 { | |
4889 tree decl; | |
4890 | |
4891 for (decl = DECL_ARGUMENTS (fn); | |
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
|
4892 decl; decl = DECL_CHAIN (decl)) |
0 | 4893 if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL |
4894 && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) | |
4895 && !TREE_NO_WARNING (decl)) | |
4896 warning (OPT_Wunused_parameter, "unused parameter %q+D", decl); | |
4897 } | |
4898 | |
4899 static GTY(()) rtx initial_trampoline; | |
4900 | |
4901 /* Generate RTL for the end of the current function. */ | |
4902 | |
4903 void | |
4904 expand_function_end (void) | |
4905 { | |
4906 rtx clobber_after; | |
4907 | |
4908 /* If arg_pointer_save_area was referenced only from a nested | |
4909 function, we will not have initialized it yet. Do that now. */ | |
4910 if (arg_pointer_save_area && ! crtl->arg_pointer_save_area_init) | |
4911 get_arg_pointer_save_area (); | |
4912 | |
4913 /* If we are doing generic stack checking and this function makes calls, | |
4914 do a stack probe at the start of the function to ensure we have enough | |
4915 space for another stack frame. */ | |
4916 if (flag_stack_check == GENERIC_STACK_CHECK) | |
4917 { | |
4918 rtx insn, seq; | |
4919 | |
4920 for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) | |
4921 if (CALL_P (insn)) | |
4922 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4923 rtx max_frame_size = GEN_INT (STACK_CHECK_MAX_FRAME_SIZE); |
0 | 4924 start_sequence (); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4925 if (STACK_CHECK_MOVING_SP) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4926 anti_adjust_stack_and_probe (max_frame_size, true); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4927 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
4928 probe_stack_range (STACK_OLD_CHECK_PROTECT, max_frame_size); |
0 | 4929 seq = get_insns (); |
4930 end_sequence (); | |
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
|
4931 set_insn_locators (seq, prologue_locator); |
0 | 4932 emit_insn_before (seq, stack_check_probe_note); |
4933 break; | |
4934 } | |
4935 } | |
4936 | |
4937 /* End any sequences that failed to be closed due to syntax errors. */ | |
4938 while (in_sequence_p ()) | |
4939 end_sequence (); | |
4940 | |
4941 clear_pending_stack_adjust (); | |
4942 do_pending_stack_adjust (); | |
4943 | |
4944 /* Output a linenumber for the end of the function. | |
4945 SDB depends on this. */ | |
4946 force_next_line_note (); | |
4947 set_curr_insn_source_location (input_location); | |
4948 | |
4949 /* Before the return label (if any), clobber the return | |
4950 registers so that they are not propagated live to the rest of | |
4951 the function. This can only happen with functions that drop | |
4952 through; if there had been a return statement, there would | |
4953 have either been a return rtx, or a jump to the return label. | |
4954 | |
4955 We delay actual code generation after the current_function_value_rtx | |
4956 is computed. */ | |
4957 clobber_after = get_last_insn (); | |
4958 | |
4959 /* Output the label for the actual return from the function. */ | |
4960 emit_label (return_label); | |
4961 | |
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
|
4962 if (targetm.except_unwind_info (&global_options) == UI_SJLJ) |
0 | 4963 { |
4964 /* Let except.c know where it should emit the call to unregister | |
4965 the function context for sjlj exceptions. */ | |
4966 if (flag_exceptions) | |
4967 sjlj_emit_function_exit_after (get_last_insn ()); | |
4968 } | |
4969 else | |
4970 { | |
4971 /* We want to ensure that instructions that may trap are not | |
4972 moved into the epilogue by scheduling, because we don't | |
4973 always emit unwind information for the epilogue. */ | |
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
|
4974 if (cfun->can_throw_non_call_exceptions) |
0 | 4975 emit_insn (gen_blockage ()); |
4976 } | |
4977 | |
4978 /* If this is an implementation of throw, do what's necessary to | |
4979 communicate between __builtin_eh_return and the epilogue. */ | |
4980 expand_eh_return (); | |
4981 | |
4982 /* If scalar return value was computed in a pseudo-reg, or was a named | |
4983 return value that got dumped to the stack, copy that to the hard | |
4984 return register. */ | |
4985 if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl))) | |
4986 { | |
4987 tree decl_result = DECL_RESULT (current_function_decl); | |
4988 rtx decl_rtl = DECL_RTL (decl_result); | |
4989 | |
4990 if (REG_P (decl_rtl) | |
4991 ? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER | |
4992 : DECL_REGISTER (decl_result)) | |
4993 { | |
4994 rtx real_decl_rtl = crtl->return_rtx; | |
4995 | |
4996 /* This should be set in assign_parms. */ | |
4997 gcc_assert (REG_FUNCTION_VALUE_P (real_decl_rtl)); | |
4998 | |
4999 /* If this is a BLKmode structure being returned in registers, | |
5000 then use the mode computed in expand_return. Note that if | |
5001 decl_rtl is memory, then its mode may have been changed, | |
5002 but that crtl->return_rtx has not. */ | |
5003 if (GET_MODE (real_decl_rtl) == BLKmode) | |
5004 PUT_MODE (real_decl_rtl, GET_MODE (decl_rtl)); | |
5005 | |
5006 /* If a non-BLKmode return value should be padded at the least | |
5007 significant end of the register, shift it left by the appropriate | |
5008 amount. BLKmode results are handled using the group load/store | |
5009 machinery. */ | |
5010 if (TYPE_MODE (TREE_TYPE (decl_result)) != BLKmode | |
5011 && targetm.calls.return_in_msb (TREE_TYPE (decl_result))) | |
5012 { | |
5013 emit_move_insn (gen_rtx_REG (GET_MODE (decl_rtl), | |
5014 REGNO (real_decl_rtl)), | |
5015 decl_rtl); | |
5016 shift_return_value (GET_MODE (decl_rtl), true, real_decl_rtl); | |
5017 } | |
5018 /* If a named return value dumped decl_return to memory, then | |
5019 we may need to re-do the PROMOTE_MODE signed/unsigned | |
5020 extension. */ | |
5021 else if (GET_MODE (real_decl_rtl) != GET_MODE (decl_rtl)) | |
5022 { | |
5023 int unsignedp = TYPE_UNSIGNED (TREE_TYPE (decl_result)); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5024 promote_function_mode (TREE_TYPE (decl_result), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5025 GET_MODE (decl_rtl), &unsignedp, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5026 TREE_TYPE (current_function_decl), 1); |
0 | 5027 |
5028 convert_move (real_decl_rtl, decl_rtl, unsignedp); | |
5029 } | |
5030 else if (GET_CODE (real_decl_rtl) == PARALLEL) | |
5031 { | |
5032 /* If expand_function_start has created a PARALLEL for decl_rtl, | |
5033 move the result to the real return registers. Otherwise, do | |
5034 a group load from decl_rtl for a named return. */ | |
5035 if (GET_CODE (decl_rtl) == PARALLEL) | |
5036 emit_group_move (real_decl_rtl, decl_rtl); | |
5037 else | |
5038 emit_group_load (real_decl_rtl, decl_rtl, | |
5039 TREE_TYPE (decl_result), | |
5040 int_size_in_bytes (TREE_TYPE (decl_result))); | |
5041 } | |
5042 /* In the case of complex integer modes smaller than a word, we'll | |
5043 need to generate some non-trivial bitfield insertions. Do that | |
5044 on a pseudo and not the hard register. */ | |
5045 else if (GET_CODE (decl_rtl) == CONCAT | |
5046 && GET_MODE_CLASS (GET_MODE (decl_rtl)) == MODE_COMPLEX_INT | |
5047 && GET_MODE_BITSIZE (GET_MODE (decl_rtl)) <= BITS_PER_WORD) | |
5048 { | |
5049 int old_generating_concat_p; | |
5050 rtx tmp; | |
5051 | |
5052 old_generating_concat_p = generating_concat_p; | |
5053 generating_concat_p = 0; | |
5054 tmp = gen_reg_rtx (GET_MODE (decl_rtl)); | |
5055 generating_concat_p = old_generating_concat_p; | |
5056 | |
5057 emit_move_insn (tmp, decl_rtl); | |
5058 emit_move_insn (real_decl_rtl, tmp); | |
5059 } | |
5060 else | |
5061 emit_move_insn (real_decl_rtl, decl_rtl); | |
5062 } | |
5063 } | |
5064 | |
5065 /* If returning a structure, arrange to return the address of the value | |
5066 in a place where debuggers expect to find it. | |
5067 | |
5068 If returning a structure PCC style, | |
5069 the caller also depends on this value. | |
5070 And cfun->returns_pcc_struct is not necessarily set. */ | |
5071 if (cfun->returns_struct | |
5072 || cfun->returns_pcc_struct) | |
5073 { | |
5074 rtx value_address = DECL_RTL (DECL_RESULT (current_function_decl)); | |
5075 tree type = TREE_TYPE (DECL_RESULT (current_function_decl)); | |
5076 rtx outgoing; | |
5077 | |
5078 if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl))) | |
5079 type = TREE_TYPE (type); | |
5080 else | |
5081 value_address = XEXP (value_address, 0); | |
5082 | |
5083 outgoing = targetm.calls.function_value (build_pointer_type (type), | |
5084 current_function_decl, true); | |
5085 | |
5086 /* Mark this as a function return value so integrate will delete the | |
5087 assignment and USE below when inlining this function. */ | |
5088 REG_FUNCTION_VALUE_P (outgoing) = 1; | |
5089 | |
5090 /* The address may be ptr_mode and OUTGOING may be Pmode. */ | |
5091 value_address = convert_memory_address (GET_MODE (outgoing), | |
5092 value_address); | |
5093 | |
5094 emit_move_insn (outgoing, value_address); | |
5095 | |
5096 /* Show return register used to hold result (in this case the address | |
5097 of the result. */ | |
5098 crtl->return_rtx = outgoing; | |
5099 } | |
5100 | |
5101 /* Emit the actual code to clobber return register. */ | |
5102 { | |
5103 rtx seq; | |
5104 | |
5105 start_sequence (); | |
5106 clobber_return_register (); | |
5107 seq = get_insns (); | |
5108 end_sequence (); | |
5109 | |
5110 emit_insn_after (seq, clobber_after); | |
5111 } | |
5112 | |
5113 /* Output the label for the naked return from the function. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5114 if (naked_return_label) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5115 emit_label (naked_return_label); |
0 | 5116 |
5117 /* @@@ This is a kludge. We want to ensure that instructions that | |
5118 may trap are not moved into the epilogue by scheduling, because | |
5119 we don't always emit unwind information for the epilogue. */ | |
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
|
5120 if (cfun->can_throw_non_call_exceptions |
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
|
5121 && targetm.except_unwind_info (&global_options) != UI_SJLJ) |
0 | 5122 emit_insn (gen_blockage ()); |
5123 | |
5124 /* If stack protection is enabled for this function, check the guard. */ | |
5125 if (crtl->stack_protect_guard) | |
5126 stack_protect_epilogue (); | |
5127 | |
5128 /* If we had calls to alloca, and this machine needs | |
5129 an accurate stack pointer to exit the function, | |
5130 insert some code to save and restore the stack pointer. */ | |
5131 if (! EXIT_IGNORE_STACK | |
5132 && cfun->calls_alloca) | |
5133 { | |
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
|
5134 rtx tem = 0, seq; |
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
|
5135 |
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
|
5136 start_sequence (); |
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
|
5137 emit_stack_save (SAVE_FUNCTION, &tem); |
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
|
5138 seq = get_insns (); |
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
|
5139 end_sequence (); |
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
|
5140 emit_insn_before (seq, parm_birth_insn); |
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
|
5141 |
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
|
5142 emit_stack_restore (SAVE_FUNCTION, tem); |
0 | 5143 } |
5144 | |
5145 /* ??? This should no longer be necessary since stupid is no longer with | |
5146 us, but there are some parts of the compiler (eg reload_combine, and | |
5147 sh mach_dep_reorg) that still try and compute their own lifetime info | |
5148 instead of using the general framework. */ | |
5149 use_return_register (); | |
5150 } | |
5151 | |
5152 rtx | |
5153 get_arg_pointer_save_area (void) | |
5154 { | |
5155 rtx ret = arg_pointer_save_area; | |
5156 | |
5157 if (! ret) | |
5158 { | |
5159 ret = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0); | |
5160 arg_pointer_save_area = ret; | |
5161 } | |
5162 | |
5163 if (! crtl->arg_pointer_save_area_init) | |
5164 { | |
5165 rtx seq; | |
5166 | |
5167 /* Save the arg pointer at the beginning of the function. The | |
5168 generated stack slot may not be a valid memory address, so we | |
5169 have to check it and fix it if necessary. */ | |
5170 start_sequence (); | |
5171 emit_move_insn (validize_mem (ret), | |
5172 crtl->args.internal_arg_pointer); | |
5173 seq = get_insns (); | |
5174 end_sequence (); | |
5175 | |
5176 push_topmost_sequence (); | |
5177 emit_insn_after (seq, entry_of_function ()); | |
5178 pop_topmost_sequence (); | |
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
|
5179 |
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
|
5180 crtl->arg_pointer_save_area_init = true; |
0 | 5181 } |
5182 | |
5183 return ret; | |
5184 } | |
5185 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5186 /* Add a list of INSNS to the hash HASHP, possibly allocating HASHP |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5187 for the first time. */ |
0 | 5188 |
5189 static void | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5190 record_insns (rtx insns, rtx end, htab_t *hashp) |
0 | 5191 { |
5192 rtx tmp; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5193 htab_t hash = *hashp; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5194 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5195 if (hash == NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5196 *hashp = hash |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5197 = htab_create_ggc (17, htab_hash_pointer, htab_eq_pointer, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5198 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5199 for (tmp = insns; tmp != end; tmp = NEXT_INSN (tmp)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5200 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5201 void **slot = htab_find_slot (hash, tmp, INSERT); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5202 gcc_assert (*slot == NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5203 *slot = tmp; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5204 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5205 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5206 |
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
|
5207 /* INSN has been duplicated or replaced by as COPY, perhaps by duplicating a |
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
|
5208 basic block, splitting or peepholes. If INSN is a prologue or epilogue |
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
|
5209 insn, then record COPY as well. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5210 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5211 void |
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
|
5212 maybe_copy_prologue_epilogue_insn (rtx insn, rtx copy) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5213 { |
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
|
5214 htab_t hash; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5215 void **slot; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5216 |
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
|
5217 hash = epilogue_insn_hash; |
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
|
5218 if (!hash || !htab_find (hash, insn)) |
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
|
5219 { |
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
|
5220 hash = prologue_insn_hash; |
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
|
5221 if (!hash || !htab_find (hash, insn)) |
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
|
5222 return; |
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
|
5223 } |
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
|
5224 |
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
|
5225 slot = htab_find_slot (hash, copy, INSERT); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5226 gcc_assert (*slot == NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5227 *slot = copy; |
0 | 5228 } |
5229 | |
5230 /* Set the locator of the insn chain starting at INSN to LOC. */ | |
5231 static void | |
5232 set_insn_locators (rtx insn, int loc) | |
5233 { | |
5234 while (insn != NULL_RTX) | |
5235 { | |
5236 if (INSN_P (insn)) | |
5237 INSN_LOCATOR (insn) = loc; | |
5238 insn = NEXT_INSN (insn); | |
5239 } | |
5240 } | |
5241 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5242 /* Determine if any INSNs in HASH are, or are part of, INSN. Because |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5243 we can be running after reorg, SEQUENCE rtl is possible. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5244 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5245 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5246 contains (const_rtx insn, htab_t hash) |
0 | 5247 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5248 if (hash == NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5249 return false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5250 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5251 if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE) |
0 | 5252 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5253 int i; |
0 | 5254 for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5255 if (htab_find (hash, XVECEXP (PATTERN (insn), 0, i))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5256 return true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5257 return false; |
0 | 5258 } |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5259 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5260 return htab_find (hash, insn) != NULL; |
0 | 5261 } |
5262 | |
5263 int | |
5264 prologue_epilogue_contains (const_rtx insn) | |
5265 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5266 if (contains (insn, prologue_insn_hash)) |
0 | 5267 return 1; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5268 if (contains (insn, epilogue_insn_hash)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5269 return 1; |
0 | 5270 return 0; |
5271 } | |
5272 | |
5273 #ifdef HAVE_return | |
5274 /* Insert gen_return at the end of block BB. This also means updating | |
5275 block_for_insn appropriately. */ | |
5276 | |
5277 static void | |
5278 emit_return_into_block (basic_block bb) | |
5279 { | |
5280 emit_jump_insn_after (gen_return (), BB_END (bb)); | |
5281 } | |
5282 #endif /* HAVE_return */ | |
5283 | |
5284 /* Generate the prologue and epilogue RTL if the machine supports it. Thread | |
5285 this into place with notes indicating where the prologue ends and where | |
5286 the epilogue begins. Update the basic block information when possible. */ | |
5287 | |
5288 static void | |
5289 thread_prologue_and_epilogue_insns (void) | |
5290 { | |
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
|
5291 bool inserted; |
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
|
5292 rtx seq ATTRIBUTE_UNUSED, epilogue_end ATTRIBUTE_UNUSED; |
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
|
5293 edge entry_edge ATTRIBUTE_UNUSED; |
0 | 5294 edge e; |
5295 edge_iterator ei; | |
5296 | |
5297 rtl_profile_for_bb (ENTRY_BLOCK_PTR); | |
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
|
5298 |
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
|
5299 inserted = false; |
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
|
5300 seq = NULL_RTX; |
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
|
5301 epilogue_end = NULL_RTX; |
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
|
5302 |
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
|
5303 /* Can't deal with multiple successors of the entry block at the |
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
|
5304 moment. Function should always have at least one entry |
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
|
5305 point. */ |
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
|
5306 gcc_assert (single_succ_p (ENTRY_BLOCK_PTR)); |
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
|
5307 entry_edge = single_succ_edge (ENTRY_BLOCK_PTR); |
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
|
5308 |
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
|
5309 if (flag_split_stack |
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
|
5310 && (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl)) |
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
|
5311 == NULL)) |
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
|
5312 { |
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
|
5313 #ifndef HAVE_split_stack_prologue |
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
|
5314 gcc_unreachable (); |
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
|
5315 #else |
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
|
5316 gcc_assert (HAVE_split_stack_prologue); |
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
|
5317 |
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
|
5318 start_sequence (); |
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
|
5319 emit_insn (gen_split_stack_prologue ()); |
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
|
5320 seq = get_insns (); |
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
|
5321 end_sequence (); |
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
|
5322 |
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
|
5323 record_insns (seq, NULL, &prologue_insn_hash); |
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
|
5324 set_insn_locators (seq, prologue_locator); |
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
|
5325 |
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
|
5326 /* This relies on the fact that committing the edge insertion |
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
|
5327 will look for basic blocks within the inserted instructions, |
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
|
5328 which in turn relies on the fact that we are not in CFG |
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
|
5329 layout mode here. */ |
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
|
5330 insert_insn_on_edge (seq, entry_edge); |
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
|
5331 inserted = true; |
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
|
5332 #endif |
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
|
5333 } |
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
|
5334 |
0 | 5335 #ifdef HAVE_prologue |
5336 if (HAVE_prologue) | |
5337 { | |
5338 start_sequence (); | |
5339 seq = gen_prologue (); | |
5340 emit_insn (seq); | |
5341 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5342 /* Insert an explicit USE for the frame pointer |
0 | 5343 if the profiling is on and the frame pointer is required. */ |
5344 if (crtl->profile && frame_pointer_needed) | |
5345 emit_use (hard_frame_pointer_rtx); | |
5346 | |
5347 /* Retain a map of the prologue insns. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5348 record_insns (seq, NULL, &prologue_insn_hash); |
0 | 5349 emit_note (NOTE_INSN_PROLOGUE_END); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5350 |
0 | 5351 /* Ensure that instructions are not moved into the prologue when |
5352 profiling is on. The call to the profiling routine can be | |
5353 emitted within the live range of a call-clobbered register. */ | |
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
|
5354 if (!targetm.profile_before_prologue () && crtl->profile) |
0 | 5355 emit_insn (gen_blockage ()); |
5356 | |
5357 seq = get_insns (); | |
5358 end_sequence (); | |
5359 set_insn_locators (seq, prologue_locator); | |
5360 | |
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
|
5361 insert_insn_on_edge (seq, entry_edge); |
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
|
5362 inserted = true; |
0 | 5363 } |
5364 #endif | |
5365 | |
5366 /* If the exit block has no non-fake predecessors, we don't need | |
5367 an epilogue. */ | |
5368 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) | |
5369 if ((e->flags & EDGE_FAKE) == 0) | |
5370 break; | |
5371 if (e == NULL) | |
5372 goto epilogue_done; | |
5373 | |
5374 rtl_profile_for_bb (EXIT_BLOCK_PTR); | |
5375 #ifdef HAVE_return | |
5376 if (optimize && HAVE_return) | |
5377 { | |
5378 /* If we're allowed to generate a simple return instruction, | |
5379 then by definition we don't need a full epilogue. Examine | |
5380 the block that falls through to EXIT. If it does not | |
5381 contain any code, examine its predecessors and try to | |
5382 emit (conditional) return instructions. */ | |
5383 | |
5384 basic_block last; | |
5385 rtx label; | |
5386 | |
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
|
5387 e = find_fallthru_edge (EXIT_BLOCK_PTR->preds); |
0 | 5388 if (e == NULL) |
5389 goto epilogue_done; | |
5390 last = e->src; | |
5391 | |
5392 /* Verify that there are no active instructions in the last block. */ | |
5393 label = BB_END (last); | |
5394 while (label && !LABEL_P (label)) | |
5395 { | |
5396 if (active_insn_p (label)) | |
5397 break; | |
5398 label = PREV_INSN (label); | |
5399 } | |
5400 | |
5401 if (BB_HEAD (last) == label && LABEL_P (label)) | |
5402 { | |
5403 edge_iterator ei2; | |
5404 | |
5405 for (ei2 = ei_start (last->preds); (e = ei_safe_edge (ei2)); ) | |
5406 { | |
5407 basic_block bb = e->src; | |
5408 rtx jump; | |
5409 | |
5410 if (bb == ENTRY_BLOCK_PTR) | |
5411 { | |
5412 ei_next (&ei2); | |
5413 continue; | |
5414 } | |
5415 | |
5416 jump = BB_END (bb); | |
5417 if (!JUMP_P (jump) || JUMP_LABEL (jump) != label) | |
5418 { | |
5419 ei_next (&ei2); | |
5420 continue; | |
5421 } | |
5422 | |
5423 /* If we have an unconditional jump, we can replace that | |
5424 with a simple return instruction. */ | |
5425 if (simplejump_p (jump)) | |
5426 { | |
5427 emit_return_into_block (bb); | |
5428 delete_insn (jump); | |
5429 } | |
5430 | |
5431 /* If we have a conditional jump, we can try to replace | |
5432 that with a conditional return instruction. */ | |
5433 else if (condjump_p (jump)) | |
5434 { | |
5435 if (! redirect_jump (jump, 0, 0)) | |
5436 { | |
5437 ei_next (&ei2); | |
5438 continue; | |
5439 } | |
5440 | |
5441 /* If this block has only one successor, it both jumps | |
5442 and falls through to the fallthru block, so we can't | |
5443 delete the edge. */ | |
5444 if (single_succ_p (bb)) | |
5445 { | |
5446 ei_next (&ei2); | |
5447 continue; | |
5448 } | |
5449 } | |
5450 else | |
5451 { | |
5452 ei_next (&ei2); | |
5453 continue; | |
5454 } | |
5455 | |
5456 /* Fix up the CFG for the successful change we just made. */ | |
5457 redirect_edge_succ (e, EXIT_BLOCK_PTR); | |
5458 } | |
5459 | |
5460 /* Emit a return insn for the exit fallthru block. Whether | |
5461 this is still reachable will be determined later. */ | |
5462 | |
5463 emit_barrier_after (BB_END (last)); | |
5464 emit_return_into_block (last); | |
5465 epilogue_end = BB_END (last); | |
5466 single_succ_edge (last)->flags &= ~EDGE_FALLTHRU; | |
5467 goto epilogue_done; | |
5468 } | |
5469 } | |
5470 #endif | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5471 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5472 /* A small fib -- epilogue is not yet completed, but we wish to re-use |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5473 this marker for the splits of EH_RETURN patterns, and nothing else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5474 uses the flag in the meantime. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5475 epilogue_completed = 1; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5476 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5477 #ifdef HAVE_eh_return |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5478 /* Find non-fallthru edges that end with EH_RETURN instructions. On |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5479 some targets, these get split to a special version of the epilogue |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5480 code. In order to be able to properly annotate these with unwind |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5481 info, try to split them now. If we get a valid split, drop an |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5482 EPILOGUE_BEG note and mark the insns as epilogue insns. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5483 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5484 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5485 rtx prev, last, trial; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5486 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5487 if (e->flags & EDGE_FALLTHRU) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5488 continue; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5489 last = BB_END (e->src); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5490 if (!eh_returnjump_p (last)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5491 continue; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5492 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5493 prev = PREV_INSN (last); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5494 trial = try_split (PATTERN (last), last, 1); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5495 if (trial == last) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5496 continue; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5497 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5498 record_insns (NEXT_INSN (prev), NEXT_INSN (trial), &epilogue_insn_hash); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5499 emit_note_after (NOTE_INSN_EPILOGUE_BEG, prev); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5500 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5501 #endif |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5502 |
0 | 5503 /* Find the edge that falls through to EXIT. Other edges may exist |
5504 due to RETURN instructions, but those don't need epilogues. | |
5505 There really shouldn't be a mixture -- either all should have | |
5506 been converted or none, however... */ | |
5507 | |
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
|
5508 e = find_fallthru_edge (EXIT_BLOCK_PTR->preds); |
0 | 5509 if (e == NULL) |
5510 goto epilogue_done; | |
5511 | |
5512 #ifdef HAVE_epilogue | |
5513 if (HAVE_epilogue) | |
5514 { | |
5515 start_sequence (); | |
5516 epilogue_end = emit_note (NOTE_INSN_EPILOGUE_BEG); | |
5517 seq = gen_epilogue (); | |
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
|
5518 if (seq) |
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
|
5519 emit_jump_insn (seq); |
0 | 5520 |
5521 /* Retain a map of the epilogue insns. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5522 record_insns (seq, NULL, &epilogue_insn_hash); |
0 | 5523 set_insn_locators (seq, epilogue_locator); |
5524 | |
5525 seq = get_insns (); | |
5526 end_sequence (); | |
5527 | |
5528 insert_insn_on_edge (seq, e); | |
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
|
5529 inserted = true; |
0 | 5530 } |
5531 else | |
5532 #endif | |
5533 { | |
5534 basic_block cur_bb; | |
5535 | |
5536 if (! next_active_insn (BB_END (e->src))) | |
5537 goto epilogue_done; | |
5538 /* We have a fall-through edge to the exit block, the source is not | |
5539 at the end of the function, and there will be an assembler epilogue | |
5540 at the end of the function. | |
5541 We can't use force_nonfallthru here, because that would try to | |
5542 use return. Inserting a jump 'by hand' is extremely messy, so | |
5543 we take advantage of cfg_layout_finalize using | |
5544 fixup_fallthru_exit_predecessor. */ | |
5545 cfg_layout_initialize (0); | |
5546 FOR_EACH_BB (cur_bb) | |
5547 if (cur_bb->index >= NUM_FIXED_BLOCKS | |
5548 && cur_bb->next_bb->index >= NUM_FIXED_BLOCKS) | |
5549 cur_bb->aux = cur_bb->next_bb; | |
5550 cfg_layout_finalize (); | |
5551 } | |
5552 epilogue_done: | |
5553 default_rtl_profile (); | |
5554 | |
5555 if (inserted) | |
5556 { | |
5557 commit_edge_insertions (); | |
5558 | |
5559 /* The epilogue insns we inserted may cause the exit edge to no longer | |
5560 be fallthru. */ | |
5561 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) | |
5562 { | |
5563 if (((e->flags & EDGE_FALLTHRU) != 0) | |
5564 && returnjump_p (BB_END (e->src))) | |
5565 e->flags &= ~EDGE_FALLTHRU; | |
5566 } | |
5567 } | |
5568 | |
5569 #ifdef HAVE_sibcall_epilogue | |
5570 /* Emit sibling epilogues before any sibling call sites. */ | |
5571 for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); ) | |
5572 { | |
5573 basic_block bb = e->src; | |
5574 rtx insn = BB_END (bb); | |
5575 | |
5576 if (!CALL_P (insn) | |
5577 || ! SIBLING_CALL_P (insn)) | |
5578 { | |
5579 ei_next (&ei); | |
5580 continue; | |
5581 } | |
5582 | |
5583 start_sequence (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5584 emit_note (NOTE_INSN_EPILOGUE_BEG); |
0 | 5585 emit_insn (gen_sibcall_epilogue ()); |
5586 seq = get_insns (); | |
5587 end_sequence (); | |
5588 | |
5589 /* Retain a map of the epilogue insns. Used in life analysis to | |
5590 avoid getting rid of sibcall epilogue insns. Do this before we | |
5591 actually emit the sequence. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5592 record_insns (seq, NULL, &epilogue_insn_hash); |
0 | 5593 set_insn_locators (seq, epilogue_locator); |
5594 | |
5595 emit_insn_before (seq, insn); | |
5596 ei_next (&ei); | |
5597 } | |
5598 #endif | |
5599 | |
5600 #ifdef HAVE_epilogue | |
5601 if (epilogue_end) | |
5602 { | |
5603 rtx insn, next; | |
5604 | |
5605 /* Similarly, move any line notes that appear after the epilogue. | |
5606 There is no need, however, to be quite so anal about the existence | |
5607 of such a note. Also possibly move | |
5608 NOTE_INSN_FUNCTION_BEG notes, as those can be relevant for debug | |
5609 info generation. */ | |
5610 for (insn = epilogue_end; insn; insn = next) | |
5611 { | |
5612 next = NEXT_INSN (insn); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5613 if (NOTE_P (insn) |
0 | 5614 && (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG)) |
5615 reorder_insns (insn, insn, PREV_INSN (epilogue_end)); | |
5616 } | |
5617 } | |
5618 #endif | |
5619 | |
5620 /* Threading the prologue and epilogue changes the artificial refs | |
5621 in the entry and exit blocks. */ | |
5622 epilogue_completed = 1; | |
5623 df_update_entry_exit_and_calls (); | |
5624 } | |
5625 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5626 /* Reposition the prologue-end and epilogue-begin notes after |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5627 instruction scheduling. */ |
0 | 5628 |
5629 void | |
5630 reposition_prologue_and_epilogue_notes (void) | |
5631 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5632 #if defined (HAVE_prologue) || defined (HAVE_epilogue) \ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5633 || defined (HAVE_sibcall_epilogue) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5634 /* Since the hash table is created on demand, the fact that it is |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5635 non-null is a signal that it is non-empty. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5636 if (prologue_insn_hash != NULL) |
0 | 5637 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5638 size_t len = htab_elements (prologue_insn_hash); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5639 rtx insn, last = NULL, note = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5640 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5641 /* Scan from the beginning until we reach the last prologue insn. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5642 /* ??? While we do have the CFG intact, there are two problems: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5643 (1) The prologue can contain loops (typically probing the stack), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5644 which means that the end of the prologue isn't in the first bb. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5645 (2) Sometimes the PROLOGUE_END note gets pushed into the next bb. */ |
0 | 5646 for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) |
5647 { | |
5648 if (NOTE_P (insn)) | |
5649 { | |
5650 if (NOTE_KIND (insn) == NOTE_INSN_PROLOGUE_END) | |
5651 note = insn; | |
5652 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5653 else if (contains (insn, prologue_insn_hash)) |
0 | 5654 { |
5655 last = insn; | |
5656 if (--len == 0) | |
5657 break; | |
5658 } | |
5659 } | |
5660 | |
5661 if (last) | |
5662 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5663 if (note == NULL) |
0 | 5664 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5665 /* Scan forward looking for the PROLOGUE_END note. It should |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5666 be right at the beginning of the block, possibly with other |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5667 insn notes that got moved there. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5668 for (note = NEXT_INSN (last); ; note = NEXT_INSN (note)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5669 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5670 if (NOTE_P (note) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5671 && NOTE_KIND (note) == NOTE_INSN_PROLOGUE_END) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5672 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5673 } |
0 | 5674 } |
5675 | |
5676 /* Avoid placing note between CODE_LABEL and BASIC_BLOCK note. */ | |
5677 if (LABEL_P (last)) | |
5678 last = NEXT_INSN (last); | |
5679 reorder_insns (note, note, last); | |
5680 } | |
5681 } | |
5682 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5683 if (epilogue_insn_hash != NULL) |
0 | 5684 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5685 edge_iterator ei; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5686 edge e; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5687 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5688 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) |
0 | 5689 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5690 rtx insn, first = NULL, note = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5691 basic_block bb = e->src; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5692 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5693 /* Scan from the beginning until we reach the first epilogue insn. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5694 FOR_BB_INSNS (bb, insn) |
0 | 5695 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5696 if (NOTE_P (insn)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5697 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5698 if (NOTE_KIND (insn) == NOTE_INSN_EPILOGUE_BEG) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5699 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5700 note = insn; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5701 if (first != NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5702 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5703 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5704 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5705 else if (first == NULL && contains (insn, epilogue_insn_hash)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5706 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5707 first = insn; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5708 if (note != NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5709 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5710 } |
0 | 5711 } |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5712 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5713 if (note) |
0 | 5714 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5715 /* If the function has a single basic block, and no real |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5716 epilogue insns (e.g. sibcall with no cleanup), the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5717 epilogue note can get scheduled before the prologue |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5718 note. If we have frame related prologue insns, having |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5719 them scanned during the epilogue will result in a crash. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5720 In this case re-order the epilogue note to just before |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5721 the last insn in the block. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5722 if (first == NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5723 first = BB_END (bb); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5724 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5725 if (PREV_INSN (first) != note) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5726 reorder_insns (note, note, PREV_INSN (first)); |
0 | 5727 } |
5728 } | |
5729 } | |
5730 #endif /* HAVE_prologue or HAVE_epilogue */ | |
5731 } | |
5732 | |
5733 /* Returns the name of the current function. */ | |
5734 const char * | |
5735 current_function_name (void) | |
5736 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5737 if (cfun == NULL) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5738 return "<none>"; |
0 | 5739 return lang_hooks.decl_printable_name (cfun->decl, 2); |
5740 } | |
5741 | |
5742 | |
5743 static unsigned int | |
5744 rest_of_handle_check_leaf_regs (void) | |
5745 { | |
5746 #ifdef LEAF_REGISTERS | |
5747 current_function_uses_only_leaf_regs | |
5748 = optimize > 0 && only_leaf_regs_used () && leaf_function_p (); | |
5749 #endif | |
5750 return 0; | |
5751 } | |
5752 | |
5753 /* Insert a TYPE into the used types hash table of CFUN. */ | |
36 | 5754 |
0 | 5755 static void |
5756 used_types_insert_helper (tree type, struct function *func) | |
5757 { | |
5758 if (type != NULL && func != NULL) | |
5759 { | |
5760 void **slot; | |
5761 | |
5762 if (func->used_types_hash == NULL) | |
5763 func->used_types_hash = htab_create_ggc (37, htab_hash_pointer, | |
5764 htab_eq_pointer, NULL); | |
5765 slot = htab_find_slot (func->used_types_hash, type, INSERT); | |
5766 if (*slot == NULL) | |
5767 *slot = type; | |
5768 } | |
5769 } | |
5770 | |
5771 /* Given a type, insert it into the used hash table in cfun. */ | |
5772 void | |
5773 used_types_insert (tree t) | |
5774 { | |
5775 while (POINTER_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE) | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5776 if (TYPE_NAME (t)) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5777 break; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5778 else |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5779 t = TREE_TYPE (t); |
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
|
5780 if (TREE_CODE (t) == ERROR_MARK) |
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
|
5781 return; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5782 if (TYPE_NAME (t) == NULL_TREE |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5783 || TYPE_NAME (t) == TYPE_NAME (TYPE_MAIN_VARIANT (t))) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
5784 t = TYPE_MAIN_VARIANT (t); |
0 | 5785 if (debug_info_level > DINFO_LEVEL_NONE) |
36 | 5786 { |
5787 if (cfun) | |
5788 used_types_insert_helper (t, cfun); | |
5789 else | |
5790 /* So this might be a type referenced by a global variable. | |
5791 Record that type so that we can later decide to emit its debug | |
5792 information. */ | |
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
|
5793 VEC_safe_push (tree, gc, types_used_by_cur_var_decl, t); |
36 | 5794 } |
5795 } | |
5796 | |
5797 /* Helper to Hash a struct types_used_by_vars_entry. */ | |
5798 | |
5799 static hashval_t | |
5800 hash_types_used_by_vars_entry (const struct types_used_by_vars_entry *entry) | |
5801 { | |
5802 gcc_assert (entry && entry->var_decl && entry->type); | |
5803 | |
5804 return iterative_hash_object (entry->type, | |
5805 iterative_hash_object (entry->var_decl, 0)); | |
5806 } | |
5807 | |
5808 /* Hash function of the types_used_by_vars_entry hash table. */ | |
5809 | |
5810 hashval_t | |
5811 types_used_by_vars_do_hash (const void *x) | |
5812 { | |
5813 const struct types_used_by_vars_entry *entry = | |
5814 (const struct types_used_by_vars_entry *) x; | |
5815 | |
5816 return hash_types_used_by_vars_entry (entry); | |
5817 } | |
5818 | |
5819 /*Equality function of the types_used_by_vars_entry hash table. */ | |
5820 | |
5821 int | |
5822 types_used_by_vars_eq (const void *x1, const void *x2) | |
5823 { | |
5824 const struct types_used_by_vars_entry *e1 = | |
5825 (const struct types_used_by_vars_entry *) x1; | |
5826 const struct types_used_by_vars_entry *e2 = | |
5827 (const struct types_used_by_vars_entry *)x2; | |
5828 | |
5829 return (e1->var_decl == e2->var_decl && e1->type == e2->type); | |
5830 } | |
5831 | |
5832 /* Inserts an entry into the types_used_by_vars_hash hash table. */ | |
5833 | |
5834 void | |
5835 types_used_by_var_decl_insert (tree type, tree var_decl) | |
5836 { | |
5837 if (type != NULL && var_decl != NULL) | |
5838 { | |
5839 void **slot; | |
5840 struct types_used_by_vars_entry e; | |
5841 e.var_decl = var_decl; | |
5842 e.type = type; | |
5843 if (types_used_by_vars_hash == NULL) | |
5844 types_used_by_vars_hash = | |
5845 htab_create_ggc (37, types_used_by_vars_do_hash, | |
5846 types_used_by_vars_eq, NULL); | |
5847 slot = htab_find_slot_with_hash (types_used_by_vars_hash, &e, | |
5848 hash_types_used_by_vars_entry (&e), INSERT); | |
5849 if (*slot == NULL) | |
5850 { | |
5851 struct types_used_by_vars_entry *entry; | |
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
|
5852 entry = ggc_alloc_types_used_by_vars_entry (); |
36 | 5853 entry->type = type; |
5854 entry->var_decl = var_decl; | |
5855 *slot = entry; | |
5856 } | |
5857 } | |
0 | 5858 } |
5859 | |
5860 struct rtl_opt_pass pass_leaf_regs = | |
5861 { | |
5862 { | |
5863 RTL_PASS, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5864 "*leaf_regs", /* name */ |
0 | 5865 NULL, /* gate */ |
5866 rest_of_handle_check_leaf_regs, /* execute */ | |
5867 NULL, /* sub */ | |
5868 NULL, /* next */ | |
5869 0, /* static_pass_number */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5870 TV_NONE, /* tv_id */ |
0 | 5871 0, /* properties_required */ |
5872 0, /* properties_provided */ | |
5873 0, /* properties_destroyed */ | |
5874 0, /* todo_flags_start */ | |
5875 0 /* todo_flags_finish */ | |
5876 } | |
5877 }; | |
5878 | |
5879 static unsigned int | |
5880 rest_of_handle_thread_prologue_and_epilogue (void) | |
5881 { | |
5882 if (optimize) | |
5883 cleanup_cfg (CLEANUP_EXPENSIVE); | |
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
|
5884 |
0 | 5885 /* On some machines, the prologue and epilogue code, or parts thereof, |
5886 can be represented as RTL. Doing so lets us schedule insns between | |
5887 it and the rest of the code and also allows delayed branch | |
5888 scheduling to operate in the epilogue. */ | |
5889 thread_prologue_and_epilogue_insns (); | |
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
|
5890 |
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
|
5891 /* The stack usage info is finalized during prologue expansion. */ |
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
|
5892 if (flag_stack_usage) |
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
|
5893 output_stack_usage (); |
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
|
5894 |
0 | 5895 return 0; |
5896 } | |
5897 | |
5898 struct rtl_opt_pass pass_thread_prologue_and_epilogue = | |
5899 { | |
5900 { | |
5901 RTL_PASS, | |
5902 "pro_and_epilogue", /* name */ | |
5903 NULL, /* gate */ | |
5904 rest_of_handle_thread_prologue_and_epilogue, /* execute */ | |
5905 NULL, /* sub */ | |
5906 NULL, /* next */ | |
5907 0, /* static_pass_number */ | |
5908 TV_THREAD_PROLOGUE_AND_EPILOGUE, /* tv_id */ | |
5909 0, /* properties_required */ | |
5910 0, /* properties_provided */ | |
5911 0, /* properties_destroyed */ | |
5912 TODO_verify_flow, /* todo_flags_start */ | |
5913 TODO_dump_func | | |
5914 TODO_df_verify | | |
5915 TODO_df_finish | TODO_verify_rtl_sharing | | |
5916 TODO_ggc_collect /* todo_flags_finish */ | |
5917 } | |
5918 }; | |
5919 | |
5920 | |
5921 /* This mini-pass fixes fall-out from SSA in asm statements that have | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
5922 in-out constraints. Say you start with |
0 | 5923 |
5924 orig = inout; | |
5925 asm ("": "+mr" (inout)); | |
5926 use (orig); | |
5927 | |
5928 which is transformed very early to use explicit output and match operands: | |
5929 | |
5930 orig = inout; | |
5931 asm ("": "=mr" (inout) : "0" (inout)); | |
5932 use (orig); | |
5933 | |
5934 Or, after SSA and copyprop, | |
5935 | |
5936 asm ("": "=mr" (inout_2) : "0" (inout_1)); | |
5937 use (inout_1); | |
5938 | |
5939 Clearly inout_2 and inout_1 can't be coalesced easily anymore, as | |
5940 they represent two separate values, so they will get different pseudo | |
5941 registers during expansion. Then, since the two operands need to match | |
5942 per the constraints, but use different pseudo registers, reload can | |
5943 only register a reload for these operands. But reloads can only be | |
5944 satisfied by hardregs, not by memory, so we need a register for this | |
5945 reload, just because we are presented with non-matching operands. | |
5946 So, even though we allow memory for this operand, no memory can be | |
5947 used for it, just because the two operands don't match. This can | |
5948 cause reload failures on register-starved targets. | |
5949 | |
5950 So it's a symptom of reload not being able to use memory for reloads | |
5951 or, alternatively it's also a symptom of both operands not coming into | |
5952 reload as matching (in which case the pseudo could go to memory just | |
5953 fine, as the alternative allows it, and no reload would be necessary). | |
5954 We fix the latter problem here, by transforming | |
5955 | |
5956 asm ("": "=mr" (inout_2) : "0" (inout_1)); | |
5957 | |
5958 back to | |
5959 | |
5960 inout_2 = inout_1; | |
5961 asm ("": "=mr" (inout_2) : "0" (inout_2)); */ | |
5962 | |
5963 static void | |
5964 match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs) | |
5965 { | |
5966 int i; | |
5967 bool changed = false; | |
5968 rtx op = SET_SRC (p_sets[0]); | |
5969 int ninputs = ASM_OPERANDS_INPUT_LENGTH (op); | |
5970 rtvec inputs = ASM_OPERANDS_INPUT_VEC (op); | |
5971 bool *output_matched = XALLOCAVEC (bool, noutputs); | |
5972 | |
5973 memset (output_matched, 0, noutputs * sizeof (bool)); | |
5974 for (i = 0; i < ninputs; i++) | |
5975 { | |
5976 rtx input, output, insns; | |
5977 const char *constraint = ASM_OPERANDS_INPUT_CONSTRAINT (op, i); | |
5978 char *end; | |
5979 int match, j; | |
5980 | |
5981 if (*constraint == '%') | |
5982 constraint++; | |
5983 | |
5984 match = strtoul (constraint, &end, 10); | |
5985 if (end == constraint) | |
5986 continue; | |
5987 | |
5988 gcc_assert (match < noutputs); | |
5989 output = SET_DEST (p_sets[match]); | |
5990 input = RTVEC_ELT (inputs, i); | |
5991 /* Only do the transformation for pseudos. */ | |
5992 if (! REG_P (output) | |
5993 || rtx_equal_p (output, input) | |
5994 || (GET_MODE (input) != VOIDmode | |
5995 && GET_MODE (input) != GET_MODE (output))) | |
5996 continue; | |
5997 | |
5998 /* We can't do anything if the output is also used as input, | |
5999 as we're going to overwrite it. */ | |
6000 for (j = 0; j < ninputs; j++) | |
6001 if (reg_overlap_mentioned_p (output, RTVEC_ELT (inputs, j))) | |
6002 break; | |
6003 if (j != ninputs) | |
6004 continue; | |
6005 | |
6006 /* Avoid changing the same input several times. For | |
6007 asm ("" : "=mr" (out1), "=mr" (out2) : "0" (in), "1" (in)); | |
6008 only change in once (to out1), rather than changing it | |
6009 first to out1 and afterwards to out2. */ | |
6010 if (i > 0) | |
6011 { | |
6012 for (j = 0; j < noutputs; j++) | |
6013 if (output_matched[j] && input == SET_DEST (p_sets[j])) | |
6014 break; | |
6015 if (j != noutputs) | |
6016 continue; | |
6017 } | |
6018 output_matched[match] = true; | |
6019 | |
6020 start_sequence (); | |
6021 emit_move_insn (output, input); | |
6022 insns = get_insns (); | |
6023 end_sequence (); | |
6024 emit_insn_before (insns, insn); | |
6025 | |
6026 /* Now replace all mentions of the input with output. We can't | |
6027 just replace the occurrence in inputs[i], as the register might | |
6028 also be used in some other input (or even in an address of an | |
6029 output), which would mean possibly increasing the number of | |
6030 inputs by one (namely 'output' in addition), which might pose | |
6031 a too complicated problem for reload to solve. E.g. this situation: | |
6032 | |
6033 asm ("" : "=r" (output), "=m" (input) : "0" (input)) | |
6034 | |
6035 Here 'input' is used in two occurrences as input (once for the | |
6036 input operand, once for the address in the second output operand). | |
6037 If we would replace only the occurrence of the input operand (to | |
6038 make the matching) we would be left with this: | |
6039 | |
6040 output = input | |
6041 asm ("" : "=r" (output), "=m" (input) : "0" (output)) | |
6042 | |
6043 Now we suddenly have two different input values (containing the same | |
6044 value, but different pseudos) where we formerly had only one. | |
6045 With more complicated asms this might lead to reload failures | |
6046 which wouldn't have happen without this pass. So, iterate over | |
6047 all operands and replace all occurrences of the register used. */ | |
6048 for (j = 0; j < noutputs; j++) | |
6049 if (!rtx_equal_p (SET_DEST (p_sets[j]), input) | |
6050 && reg_overlap_mentioned_p (input, SET_DEST (p_sets[j]))) | |
6051 SET_DEST (p_sets[j]) = replace_rtx (SET_DEST (p_sets[j]), | |
6052 input, output); | |
6053 for (j = 0; j < ninputs; j++) | |
6054 if (reg_overlap_mentioned_p (input, RTVEC_ELT (inputs, j))) | |
6055 RTVEC_ELT (inputs, j) = replace_rtx (RTVEC_ELT (inputs, j), | |
6056 input, output); | |
6057 | |
6058 changed = true; | |
6059 } | |
6060 | |
6061 if (changed) | |
6062 df_insn_rescan (insn); | |
6063 } | |
6064 | |
6065 static unsigned | |
6066 rest_of_match_asm_constraints (void) | |
6067 { | |
6068 basic_block bb; | |
6069 rtx insn, pat, *p_sets; | |
6070 int noutputs; | |
6071 | |
6072 if (!crtl->has_asm_statement) | |
6073 return 0; | |
6074 | |
6075 df_set_flags (DF_DEFER_INSN_RESCAN); | |
6076 FOR_EACH_BB (bb) | |
6077 { | |
6078 FOR_BB_INSNS (bb, insn) | |
6079 { | |
6080 if (!INSN_P (insn)) | |
6081 continue; | |
6082 | |
6083 pat = PATTERN (insn); | |
6084 if (GET_CODE (pat) == PARALLEL) | |
6085 p_sets = &XVECEXP (pat, 0, 0), noutputs = XVECLEN (pat, 0); | |
6086 else if (GET_CODE (pat) == SET) | |
6087 p_sets = &PATTERN (insn), noutputs = 1; | |
6088 else | |
6089 continue; | |
6090 | |
6091 if (GET_CODE (*p_sets) == SET | |
6092 && GET_CODE (SET_SRC (*p_sets)) == ASM_OPERANDS) | |
6093 match_asm_constraints_1 (insn, p_sets, noutputs); | |
6094 } | |
6095 } | |
6096 | |
6097 return TODO_df_finish; | |
6098 } | |
6099 | |
6100 struct rtl_opt_pass pass_match_asm_constraints = | |
6101 { | |
6102 { | |
6103 RTL_PASS, | |
6104 "asmcons", /* name */ | |
6105 NULL, /* gate */ | |
6106 rest_of_match_asm_constraints, /* execute */ | |
6107 NULL, /* sub */ | |
6108 NULL, /* next */ | |
6109 0, /* static_pass_number */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
6110 TV_NONE, /* tv_id */ |
0 | 6111 0, /* properties_required */ |
6112 0, /* properties_provided */ | |
6113 0, /* properties_destroyed */ | |
6114 0, /* todo_flags_start */ | |
6115 TODO_dump_func /* todo_flags_finish */ | |
6116 } | |
6117 }; | |
6118 | |
6119 | |
6120 #include "gt-function.h" |