Mercurial > hg > CbC > CbC_gcc
annotate gcc/config/fr30/fr30.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
rev | line source |
---|---|
0 | 1 /* FR30 specific functions. |
131 | 2 Copyright (C) 1998-2018 Free Software Foundation, Inc. |
0 | 3 Contributed by Cygnus Solutions. |
4 | |
5 This file is part of GCC. | |
6 | |
7 GCC is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 3, or (at your option) | |
10 any later version. | |
11 | |
12 GCC is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GCC; see the file COPYING3. If not see | |
19 <http://www.gnu.org/licenses/>. */ | |
20 | |
21 /*{{{ Includes */ | |
22 | |
131 | 23 #define IN_TARGET_CODE 1 |
24 | |
0 | 25 #include "config.h" |
26 #include "system.h" | |
27 #include "coretypes.h" | |
111 | 28 #include "backend.h" |
29 #include "target.h" | |
0 | 30 #include "rtl.h" |
31 #include "tree.h" | |
111 | 32 #include "stringpool.h" |
33 #include "attribs.h" | |
34 #include "df.h" | |
35 #include "memmodel.h" | |
36 #include "emit-rtl.h" | |
37 #include "stor-layout.h" | |
38 #include "varasm.h" | |
0 | 39 #include "output.h" |
40 #include "expr.h" | |
111 | 41 #include "builtins.h" |
42 | |
43 /* This file should be included last. */ | |
0 | 44 #include "target-def.h" |
45 | |
46 /*}}}*/ | |
47 /*{{{ Function Prologues & Epilogues */ | |
48 | |
49 /* The FR30 stack looks like this: | |
50 | |
51 Before call After call | |
52 FP ->| | | | | |
53 +-----------------------+ +-----------------------+ high | |
54 | | | | memory | |
55 | local variables, | | local variables, | | |
56 | reg save area, etc. | | reg save area, etc. | | |
57 | | | | | |
58 +-----------------------+ +-----------------------+ | |
59 | | | | | |
60 | args to the func that | | args to this func. | | |
61 | is being called that | | | | |
62 SP ->| do not fit in regs | | | | |
63 +-----------------------+ +-----------------------+ | |
64 | args that used to be | \ | |
65 | in regs; only created | | pretend_size | |
66 AP-> | for vararg funcs | / | |
67 +-----------------------+ | |
68 | | \ | |
69 | register save area | | | |
70 | | | | |
71 +-----------------------+ | reg_size | |
72 | return address | | | |
73 +-----------------------+ | | |
74 FP ->| previous frame ptr | / | |
75 +-----------------------+ | |
76 | | \ | |
77 | local variables | | var_size | |
78 | | / | |
79 +-----------------------+ | |
80 | | \ | |
81 low | room for args to | | | |
82 memory | other funcs called | | args_size | |
83 | from this one | | | |
84 SP ->| | / | |
85 +-----------------------+ | |
86 | |
87 Note, AP is a fake hard register. It will be eliminated in favor of | |
88 SP or FP as appropriate. | |
89 | |
90 Note, Some or all of the stack sections above may be omitted if they | |
91 are not needed. */ | |
92 | |
93 /* Structure to be filled in by fr30_compute_frame_size() with register | |
94 save masks, and offsets for the current function. */ | |
95 struct fr30_frame_info | |
96 { | |
97 unsigned int total_size; /* # Bytes that the entire frame takes up. */ | |
98 unsigned int pretend_size; /* # Bytes we push and pretend caller did. */ | |
99 unsigned int args_size; /* # Bytes that outgoing arguments take up. */ | |
100 unsigned int reg_size; /* # Bytes needed to store regs. */ | |
101 unsigned int var_size; /* # Bytes that variables take up. */ | |
102 unsigned int frame_size; /* # Bytes in current frame. */ | |
103 unsigned int gmask; /* Mask of saved registers. */ | |
104 unsigned int save_fp; /* Nonzero if frame pointer must be saved. */ | |
105 unsigned int save_rp; /* Nonzero if return pointer must be saved. */ | |
106 int initialised; /* Nonzero if frame size already calculated. */ | |
107 }; | |
108 | |
109 /* Current frame information calculated by fr30_compute_frame_size(). */ | |
110 static struct fr30_frame_info current_frame_info; | |
111 | |
112 /* Zero structure to initialize current_frame_info. */ | |
113 static struct fr30_frame_info zero_frame_info; | |
114 | |
111 | 115 static void fr30_setup_incoming_varargs (cumulative_args_t, machine_mode, |
0 | 116 tree, int *, int); |
111 | 117 static bool fr30_must_pass_in_stack (machine_mode, const_tree); |
118 static int fr30_arg_partial_bytes (cumulative_args_t, machine_mode, | |
0 | 119 tree, bool); |
111 | 120 static rtx fr30_function_arg (cumulative_args_t, machine_mode, |
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
|
121 const_tree, bool); |
111 | 122 static void fr30_function_arg_advance (cumulative_args_t, machine_mode, |
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
|
123 const_tree, bool); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
124 static bool fr30_frame_pointer_required (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
|
125 static rtx fr30_function_value (const_tree, const_tree, bool); |
111 | 126 static rtx fr30_libcall_value (machine_mode, const_rtx); |
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
|
127 static bool fr30_function_value_regno_p (const unsigned int); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
128 static bool fr30_can_eliminate (const int, const int); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
129 static void fr30_asm_trampoline_template (FILE *); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
130 static void fr30_trampoline_init (rtx, tree, rtx); |
111 | 131 static int fr30_num_arg_regs (machine_mode, const_tree); |
0 | 132 |
133 #define FRAME_POINTER_MASK (1 << (FRAME_POINTER_REGNUM)) | |
134 #define RETURN_POINTER_MASK (1 << (RETURN_POINTER_REGNUM)) | |
135 | |
136 /* Tell prologue and epilogue if register REGNO should be saved / restored. | |
137 The return address and frame pointer are treated separately. | |
138 Don't consider them here. */ | |
139 #define MUST_SAVE_REGISTER(regno) \ | |
140 ( (regno) != RETURN_POINTER_REGNUM \ | |
141 && (regno) != FRAME_POINTER_REGNUM \ | |
142 && df_regs_ever_live_p (regno) \ | |
143 && ! call_used_regs [regno] ) | |
144 | |
145 #define MUST_SAVE_FRAME_POINTER (df_regs_ever_live_p (FRAME_POINTER_REGNUM) || frame_pointer_needed) | |
146 #define MUST_SAVE_RETURN_POINTER (df_regs_ever_live_p (RETURN_POINTER_REGNUM) || crtl->profile) | |
147 | |
148 #if UNITS_PER_WORD == 4 | |
149 #define WORD_ALIGN(SIZE) (((SIZE) + 3) & ~3) | |
150 #endif | |
151 | |
152 /* Initialize the GCC target structure. */ | |
153 #undef TARGET_ASM_ALIGNED_HI_OP | |
154 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t" | |
155 #undef TARGET_ASM_ALIGNED_SI_OP | |
156 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t" | |
157 | |
158 #undef TARGET_PROMOTE_PROTOTYPES | |
159 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true | |
160 #undef TARGET_PASS_BY_REFERENCE | |
161 #define TARGET_PASS_BY_REFERENCE hook_pass_by_reference_must_pass_in_stack | |
162 #undef TARGET_ARG_PARTIAL_BYTES | |
163 #define TARGET_ARG_PARTIAL_BYTES fr30_arg_partial_bytes | |
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
|
164 #undef TARGET_FUNCTION_ARG |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
165 #define TARGET_FUNCTION_ARG fr30_function_arg |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
166 #undef TARGET_FUNCTION_ARG_ADVANCE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
167 #define TARGET_FUNCTION_ARG_ADVANCE fr30_function_arg_advance |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
168 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
169 #undef TARGET_FUNCTION_VALUE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
170 #define TARGET_FUNCTION_VALUE fr30_function_value |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
171 #undef TARGET_LIBCALL_VALUE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
172 #define TARGET_LIBCALL_VALUE fr30_libcall_value |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
173 #undef TARGET_FUNCTION_VALUE_REGNO_P |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
174 #define TARGET_FUNCTION_VALUE_REGNO_P fr30_function_value_regno_p |
0 | 175 |
176 #undef TARGET_SETUP_INCOMING_VARARGS | |
177 #define TARGET_SETUP_INCOMING_VARARGS fr30_setup_incoming_varargs | |
178 #undef TARGET_MUST_PASS_IN_STACK | |
179 #define TARGET_MUST_PASS_IN_STACK fr30_must_pass_in_stack | |
180 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
181 #undef TARGET_FRAME_POINTER_REQUIRED |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
182 #define TARGET_FRAME_POINTER_REQUIRED fr30_frame_pointer_required |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
183 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
184 #undef TARGET_CAN_ELIMINATE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
185 #define TARGET_CAN_ELIMINATE fr30_can_eliminate |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
186 |
111 | 187 #undef TARGET_LRA_P |
188 #define TARGET_LRA_P hook_bool_void_false | |
189 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
190 #undef TARGET_ASM_TRAMPOLINE_TEMPLATE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
191 #define TARGET_ASM_TRAMPOLINE_TEMPLATE fr30_asm_trampoline_template |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
192 #undef TARGET_TRAMPOLINE_INIT |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
193 #define TARGET_TRAMPOLINE_INIT fr30_trampoline_init |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
194 |
111 | 195 #undef TARGET_CONSTANT_ALIGNMENT |
196 #define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings | |
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
|
197 |
131 | 198 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE |
199 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed | |
200 | |
0 | 201 struct gcc_target targetm = TARGET_INITIALIZER; |
202 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
203 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
204 /* Worker function for TARGET_CAN_ELIMINATE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
205 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
206 bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
207 fr30_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
208 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
209 return (to == FRAME_POINTER_REGNUM || ! frame_pointer_needed); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
210 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
211 |
0 | 212 /* Returns the number of bytes offset between FROM_REG and TO_REG |
213 for the current function. As a side effect it fills in the | |
214 current_frame_info structure, if the data is available. */ | |
215 unsigned int | |
216 fr30_compute_frame_size (int from_reg, int to_reg) | |
217 { | |
218 int regno; | |
219 unsigned int return_value; | |
220 unsigned int var_size; | |
221 unsigned int args_size; | |
222 unsigned int pretend_size; | |
223 unsigned int reg_size; | |
224 unsigned int gmask; | |
225 | |
226 var_size = WORD_ALIGN (get_frame_size ()); | |
227 args_size = WORD_ALIGN (crtl->outgoing_args_size); | |
228 pretend_size = crtl->args.pretend_args_size; | |
229 | |
230 reg_size = 0; | |
231 gmask = 0; | |
232 | |
233 /* Calculate space needed for registers. */ | |
234 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno ++) | |
235 { | |
236 if (MUST_SAVE_REGISTER (regno)) | |
237 { | |
238 reg_size += UNITS_PER_WORD; | |
239 gmask |= 1 << regno; | |
240 } | |
241 } | |
242 | |
243 current_frame_info.save_fp = MUST_SAVE_FRAME_POINTER; | |
244 current_frame_info.save_rp = MUST_SAVE_RETURN_POINTER; | |
245 | |
246 reg_size += (current_frame_info.save_fp + current_frame_info.save_rp) | |
247 * UNITS_PER_WORD; | |
248 | |
249 /* Save computed information. */ | |
250 current_frame_info.pretend_size = pretend_size; | |
251 current_frame_info.var_size = var_size; | |
252 current_frame_info.args_size = args_size; | |
253 current_frame_info.reg_size = reg_size; | |
254 current_frame_info.frame_size = args_size + var_size; | |
255 current_frame_info.total_size = args_size + var_size + reg_size + pretend_size; | |
256 current_frame_info.gmask = gmask; | |
257 current_frame_info.initialised = reload_completed; | |
258 | |
259 /* Calculate the required distance. */ | |
260 return_value = 0; | |
261 | |
262 if (to_reg == STACK_POINTER_REGNUM) | |
263 return_value += args_size + var_size; | |
264 | |
265 if (from_reg == ARG_POINTER_REGNUM) | |
266 return_value += reg_size; | |
267 | |
268 return return_value; | |
269 } | |
270 | |
271 /* Called after register allocation to add any instructions needed for the | |
272 prologue. Using a prologue insn is favored compared to putting all of the | |
273 instructions in output_function_prologue(), since it allows the scheduler | |
274 to intermix instructions with the saves of the caller saved registers. In | |
275 some cases, it might be necessary to emit a barrier instruction as the last | |
276 insn to prevent such scheduling. */ | |
277 | |
278 void | |
279 fr30_expand_prologue (void) | |
280 { | |
281 int regno; | |
282 rtx insn; | |
283 | |
284 if (! current_frame_info.initialised) | |
285 fr30_compute_frame_size (0, 0); | |
286 | |
287 /* This cases shouldn't happen. Catch it now. */ | |
288 gcc_assert (current_frame_info.total_size || !current_frame_info.gmask); | |
289 | |
290 /* Allocate space for register arguments if this is a variadic function. */ | |
291 if (current_frame_info.pretend_size) | |
292 { | |
293 int regs_to_save = current_frame_info.pretend_size / UNITS_PER_WORD; | |
294 | |
295 /* Push argument registers into the pretend arg area. */ | |
296 for (regno = FIRST_ARG_REGNUM + FR30_NUM_ARG_REGS; regno --, regs_to_save --;) | |
297 { | |
298 insn = emit_insn (gen_movsi_push (gen_rtx_REG (Pmode, regno))); | |
299 RTX_FRAME_RELATED_P (insn) = 1; | |
300 } | |
301 } | |
302 | |
303 if (current_frame_info.gmask) | |
304 { | |
305 /* Save any needed call-saved regs. */ | |
306 for (regno = STACK_POINTER_REGNUM; regno--;) | |
307 { | |
308 if ((current_frame_info.gmask & (1 << regno)) != 0) | |
309 { | |
310 insn = emit_insn (gen_movsi_push (gen_rtx_REG (Pmode, regno))); | |
311 RTX_FRAME_RELATED_P (insn) = 1; | |
312 } | |
313 } | |
314 } | |
315 | |
316 /* Save return address if necessary. */ | |
317 if (current_frame_info.save_rp) | |
318 { | |
319 insn = emit_insn (gen_movsi_push (gen_rtx_REG (Pmode, | |
320 RETURN_POINTER_REGNUM))); | |
321 RTX_FRAME_RELATED_P (insn) = 1; | |
322 } | |
323 | |
324 /* Save old frame pointer and create new one, if necessary. */ | |
325 if (current_frame_info.save_fp) | |
326 { | |
327 if (current_frame_info.frame_size < ((1 << 10) - UNITS_PER_WORD)) | |
328 { | |
329 int enter_size = current_frame_info.frame_size + UNITS_PER_WORD; | |
330 rtx pattern; | |
331 | |
332 insn = emit_insn (gen_enter_func (GEN_INT (enter_size))); | |
333 RTX_FRAME_RELATED_P (insn) = 1; | |
334 | |
335 pattern = PATTERN (insn); | |
336 | |
337 /* Also mark all 3 subexpressions as RTX_FRAME_RELATED_P. */ | |
338 if (GET_CODE (pattern) == PARALLEL) | |
339 { | |
340 int x; | |
341 for (x = XVECLEN (pattern, 0); x--;) | |
342 { | |
343 rtx part = XVECEXP (pattern, 0, x); | |
344 | |
345 /* One of the insns in the ENTER pattern updates the | |
346 frame pointer. If we do not actually need the frame | |
347 pointer in this function then this is a side effect | |
348 rather than a desired effect, so we do not mark that | |
349 insn as being related to the frame set up. Doing this | |
350 allows us to compile the crash66.C test file in the | |
351 G++ testsuite. */ | |
352 if (! frame_pointer_needed | |
353 && GET_CODE (part) == SET | |
354 && SET_DEST (part) == hard_frame_pointer_rtx) | |
355 RTX_FRAME_RELATED_P (part) = 0; | |
356 else | |
357 RTX_FRAME_RELATED_P (part) = 1; | |
358 } | |
359 } | |
360 } | |
361 else | |
362 { | |
363 insn = emit_insn (gen_movsi_push (frame_pointer_rtx)); | |
364 RTX_FRAME_RELATED_P (insn) = 1; | |
365 | |
366 if (frame_pointer_needed) | |
367 { | |
368 insn = emit_insn (gen_movsi (frame_pointer_rtx, stack_pointer_rtx)); | |
369 RTX_FRAME_RELATED_P (insn) = 1; | |
370 } | |
371 } | |
372 } | |
373 | |
374 /* Allocate the stack frame. */ | |
375 if (current_frame_info.frame_size == 0) | |
376 ; /* Nothing to do. */ | |
377 else if (current_frame_info.save_fp | |
378 && current_frame_info.frame_size < ((1 << 10) - UNITS_PER_WORD)) | |
379 ; /* Nothing to do. */ | |
380 else if (current_frame_info.frame_size <= 512) | |
381 { | |
382 insn = emit_insn (gen_add_to_stack | |
383 (GEN_INT (- (signed) current_frame_info.frame_size))); | |
384 RTX_FRAME_RELATED_P (insn) = 1; | |
385 } | |
386 else | |
387 { | |
388 rtx tmp = gen_rtx_REG (Pmode, PROLOGUE_TMP_REGNUM); | |
389 insn = emit_insn (gen_movsi (tmp, GEN_INT (current_frame_info.frame_size))); | |
390 RTX_FRAME_RELATED_P (insn) = 1; | |
391 insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, tmp)); | |
392 RTX_FRAME_RELATED_P (insn) = 1; | |
393 } | |
394 | |
395 if (crtl->profile) | |
396 emit_insn (gen_blockage ()); | |
397 } | |
398 | |
399 /* Called after register allocation to add any instructions needed for the | |
400 epilogue. Using an epilogue insn is favored compared to putting all of the | |
401 instructions in output_function_epilogue(), since it allows the scheduler | |
402 to intermix instructions with the restores of the caller saved registers. | |
403 In some cases, it might be necessary to emit a barrier instruction as the | |
404 first insn to prevent such scheduling. */ | |
405 void | |
406 fr30_expand_epilogue (void) | |
407 { | |
408 int regno; | |
409 | |
410 /* Perform the inversion operations of the prologue. */ | |
411 gcc_assert (current_frame_info.initialised); | |
412 | |
413 /* Pop local variables and arguments off the stack. | |
414 If frame_pointer_needed is TRUE then the frame pointer register | |
415 has actually been used as a frame pointer, and we can recover | |
416 the stack pointer from it, otherwise we must unwind the stack | |
417 manually. */ | |
418 if (current_frame_info.frame_size > 0) | |
419 { | |
420 if (current_frame_info.save_fp && frame_pointer_needed) | |
421 { | |
422 emit_insn (gen_leave_func ()); | |
423 current_frame_info.save_fp = 0; | |
424 } | |
425 else if (current_frame_info.frame_size <= 508) | |
426 emit_insn (gen_add_to_stack | |
427 (GEN_INT (current_frame_info.frame_size))); | |
428 else | |
429 { | |
430 rtx tmp = gen_rtx_REG (Pmode, PROLOGUE_TMP_REGNUM); | |
431 emit_insn (gen_movsi (tmp, GEN_INT (current_frame_info.frame_size))); | |
432 emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, tmp)); | |
433 } | |
434 } | |
435 | |
436 if (current_frame_info.save_fp) | |
437 emit_insn (gen_movsi_pop (frame_pointer_rtx)); | |
438 | |
439 /* Pop all the registers that were pushed. */ | |
440 if (current_frame_info.save_rp) | |
441 emit_insn (gen_movsi_pop (gen_rtx_REG (Pmode, RETURN_POINTER_REGNUM))); | |
442 | |
443 for (regno = 0; regno < STACK_POINTER_REGNUM; regno ++) | |
444 if (current_frame_info.gmask & (1 << regno)) | |
445 emit_insn (gen_movsi_pop (gen_rtx_REG (Pmode, regno))); | |
446 | |
447 if (current_frame_info.pretend_size) | |
448 emit_insn (gen_add_to_stack (GEN_INT (current_frame_info.pretend_size))); | |
449 | |
450 /* Reset state info for each function. */ | |
451 current_frame_info = zero_frame_info; | |
452 | |
453 emit_jump_insn (gen_return_from_func ()); | |
454 } | |
455 | |
456 /* Do any needed setup for a variadic function. We must create a register | |
457 parameter block, and then copy any anonymous arguments, plus the last | |
458 named argument, from registers into memory. * copying actually done in | |
459 fr30_expand_prologue(). | |
460 | |
461 ARG_REGS_USED_SO_FAR has *not* been updated for the last named argument | |
462 which has type TYPE and mode MODE, and we rely on this fact. */ | |
463 void | |
111 | 464 fr30_setup_incoming_varargs (cumulative_args_t arg_regs_used_so_far_v, |
465 machine_mode mode, | |
0 | 466 tree type ATTRIBUTE_UNUSED, |
467 int *pretend_size, | |
468 int second_time ATTRIBUTE_UNUSED) | |
469 { | |
111 | 470 CUMULATIVE_ARGS *arg_regs_used_so_far |
471 = get_cumulative_args (arg_regs_used_so_far_v); | |
0 | 472 int size; |
473 | |
474 /* All BLKmode values are passed by reference. */ | |
475 gcc_assert (mode != BLKmode); | |
476 | |
477 /* ??? This run-time test as well as the code inside the if | |
478 statement is probably unnecessary. */ | |
111 | 479 if (targetm.calls.strict_argument_naming (arg_regs_used_so_far_v)) |
0 | 480 /* If TARGET_STRICT_ARGUMENT_NAMING returns true, then the last named |
481 arg must not be treated as an anonymous arg. */ | |
111 | 482 /* ??? This is a pointer increment, which makes no sense. */ |
0 | 483 arg_regs_used_so_far += fr30_num_arg_regs (mode, type); |
484 | |
485 size = FR30_NUM_ARG_REGS - (* arg_regs_used_so_far); | |
486 | |
487 if (size <= 0) | |
488 return; | |
489 | |
490 * pretend_size = (size * UNITS_PER_WORD); | |
491 } | |
492 | |
493 /*}}}*/ | |
494 /*{{{ Printing operands */ | |
495 | |
496 /* Print a memory address as an operand to reference that memory location. */ | |
497 | |
498 void | |
499 fr30_print_operand_address (FILE *stream, rtx address) | |
500 { | |
501 switch (GET_CODE (address)) | |
502 { | |
503 case SYMBOL_REF: | |
504 output_addr_const (stream, address); | |
505 break; | |
506 | |
507 default: | |
508 fprintf (stderr, "code = %x\n", GET_CODE (address)); | |
509 debug_rtx (address); | |
510 output_operand_lossage ("fr30_print_operand_address: unhandled address"); | |
511 break; | |
512 } | |
513 } | |
514 | |
515 /* Print an operand. */ | |
516 | |
517 void | |
518 fr30_print_operand (FILE *file, rtx x, int code) | |
519 { | |
520 rtx x0; | |
521 | |
522 switch (code) | |
523 { | |
524 case '#': | |
525 /* Output a :D if this instruction is delayed. */ | |
526 if (dbr_sequence_length () != 0) | |
527 fputs (":D", file); | |
528 return; | |
529 | |
530 case 'p': | |
531 /* Compute the register name of the second register in a hi/lo | |
532 register pair. */ | |
533 if (GET_CODE (x) != REG) | |
534 output_operand_lossage ("fr30_print_operand: unrecognized %%p code"); | |
535 else | |
536 fprintf (file, "r%d", REGNO (x) + 1); | |
537 return; | |
538 | |
539 case 'b': | |
540 /* Convert GCC's comparison operators into FR30 comparison codes. */ | |
541 switch (GET_CODE (x)) | |
542 { | |
543 case EQ: fprintf (file, "eq"); break; | |
544 case NE: fprintf (file, "ne"); break; | |
545 case LT: fprintf (file, "lt"); break; | |
546 case LE: fprintf (file, "le"); break; | |
547 case GT: fprintf (file, "gt"); break; | |
548 case GE: fprintf (file, "ge"); break; | |
549 case LTU: fprintf (file, "c"); break; | |
550 case LEU: fprintf (file, "ls"); break; | |
551 case GTU: fprintf (file, "hi"); break; | |
552 case GEU: fprintf (file, "nc"); break; | |
553 default: | |
554 output_operand_lossage ("fr30_print_operand: unrecognized %%b code"); | |
555 break; | |
556 } | |
557 return; | |
558 | |
559 case 'B': | |
560 /* Convert GCC's comparison operators into the complimentary FR30 | |
561 comparison codes. */ | |
562 switch (GET_CODE (x)) | |
563 { | |
564 case EQ: fprintf (file, "ne"); break; | |
565 case NE: fprintf (file, "eq"); break; | |
566 case LT: fprintf (file, "ge"); break; | |
567 case LE: fprintf (file, "gt"); break; | |
568 case GT: fprintf (file, "le"); break; | |
569 case GE: fprintf (file, "lt"); break; | |
570 case LTU: fprintf (file, "nc"); break; | |
571 case LEU: fprintf (file, "hi"); break; | |
572 case GTU: fprintf (file, "ls"); break; | |
573 case GEU: fprintf (file, "c"); break; | |
574 default: | |
575 output_operand_lossage ("fr30_print_operand: unrecognized %%B code"); | |
576 break; | |
577 } | |
578 return; | |
579 | |
580 case 'A': | |
581 /* Print a signed byte value as an unsigned value. */ | |
582 if (GET_CODE (x) != CONST_INT) | |
583 output_operand_lossage ("fr30_print_operand: invalid operand to %%A code"); | |
584 else | |
585 { | |
586 HOST_WIDE_INT val; | |
587 | |
588 val = INTVAL (x); | |
589 | |
590 val &= 0xff; | |
591 | |
592 fprintf (file, HOST_WIDE_INT_PRINT_DEC, val); | |
593 } | |
594 return; | |
595 | |
596 case 'x': | |
597 if (GET_CODE (x) != CONST_INT | |
598 || INTVAL (x) < 16 | |
599 || INTVAL (x) > 32) | |
600 output_operand_lossage ("fr30_print_operand: invalid %%x code"); | |
601 else | |
602 fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) - 16); | |
603 return; | |
604 | |
605 case 'F': | |
606 if (GET_CODE (x) != CONST_DOUBLE) | |
607 output_operand_lossage ("fr30_print_operand: invalid %%F code"); | |
608 else | |
609 { | |
610 char str[30]; | |
611 | |
612 real_to_decimal (str, CONST_DOUBLE_REAL_VALUE (x), | |
613 sizeof (str), 0, 1); | |
614 fputs (str, file); | |
615 } | |
616 return; | |
617 | |
618 case 0: | |
619 /* Handled below. */ | |
620 break; | |
621 | |
622 default: | |
623 fprintf (stderr, "unknown code = %x\n", code); | |
624 output_operand_lossage ("fr30_print_operand: unknown code"); | |
625 return; | |
626 } | |
627 | |
628 switch (GET_CODE (x)) | |
629 { | |
630 case REG: | |
631 fputs (reg_names [REGNO (x)], file); | |
632 break; | |
633 | |
634 case MEM: | |
635 x0 = XEXP (x,0); | |
636 | |
637 switch (GET_CODE (x0)) | |
638 { | |
639 case REG: | |
640 gcc_assert ((unsigned) REGNO (x0) < ARRAY_SIZE (reg_names)); | |
641 fprintf (file, "@%s", reg_names [REGNO (x0)]); | |
642 break; | |
643 | |
644 case PLUS: | |
645 if (GET_CODE (XEXP (x0, 0)) != REG | |
646 || REGNO (XEXP (x0, 0)) < FRAME_POINTER_REGNUM | |
647 || REGNO (XEXP (x0, 0)) > STACK_POINTER_REGNUM | |
648 || GET_CODE (XEXP (x0, 1)) != CONST_INT) | |
649 { | |
650 fprintf (stderr, "bad INDEXed address:"); | |
651 debug_rtx (x); | |
652 output_operand_lossage ("fr30_print_operand: unhandled MEM"); | |
653 } | |
654 else if (REGNO (XEXP (x0, 0)) == FRAME_POINTER_REGNUM) | |
655 { | |
656 HOST_WIDE_INT val = INTVAL (XEXP (x0, 1)); | |
657 if (val < -(1 << 9) || val > ((1 << 9) - 4)) | |
658 { | |
659 fprintf (stderr, "frame INDEX out of range:"); | |
660 debug_rtx (x); | |
661 output_operand_lossage ("fr30_print_operand: unhandled MEM"); | |
662 } | |
663 fprintf (file, "@(r14, #" HOST_WIDE_INT_PRINT_DEC ")", val); | |
664 } | |
665 else | |
666 { | |
667 HOST_WIDE_INT val = INTVAL (XEXP (x0, 1)); | |
668 if (val < 0 || val > ((1 << 6) - 4)) | |
669 { | |
670 fprintf (stderr, "stack INDEX out of range:"); | |
671 debug_rtx (x); | |
672 output_operand_lossage ("fr30_print_operand: unhandled MEM"); | |
673 } | |
674 fprintf (file, "@(r15, #" HOST_WIDE_INT_PRINT_DEC ")", val); | |
675 } | |
676 break; | |
677 | |
678 case SYMBOL_REF: | |
111 | 679 output_address (VOIDmode, x0); |
0 | 680 break; |
681 | |
682 default: | |
683 fprintf (stderr, "bad MEM code = %x\n", GET_CODE (x0)); | |
684 debug_rtx (x); | |
685 output_operand_lossage ("fr30_print_operand: unhandled MEM"); | |
686 break; | |
687 } | |
688 break; | |
689 | |
690 case CONST_DOUBLE : | |
691 /* We handle SFmode constants here as output_addr_const doesn't. */ | |
692 if (GET_MODE (x) == SFmode) | |
693 { | |
694 long l; | |
695 | |
111 | 696 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l); |
0 | 697 fprintf (file, "0x%08lx", l); |
698 break; | |
699 } | |
700 | |
111 | 701 /* FALLTHRU */ |
702 /* Let output_addr_const deal with it. */ | |
0 | 703 default: |
704 output_addr_const (file, x); | |
705 break; | |
706 } | |
707 | |
708 return; | |
709 } | |
710 | |
711 /*}}}*/ | |
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
|
712 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
713 /* Implements TARGET_FUNCTION_VALUE. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
714 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
715 static 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
|
716 fr30_function_value (const_tree valtype, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
717 const_tree fntype_or_decli 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
|
718 bool outgoing 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
|
719 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
720 return gen_rtx_REG (TYPE_MODE (valtype), RETURN_VALUE_REGNUM); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
721 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
722 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
723 /* Implements TARGET_LIBCALL_VALUE. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
724 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
725 static rtx |
111 | 726 fr30_libcall_value (machine_mode mode, |
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
|
727 const_rtx fun 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
|
728 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
729 return gen_rtx_REG (mode, RETURN_VALUE_REGNUM); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
730 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
731 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
732 /* Implements TARGET_FUNCTION_VALUE_REGNO_P. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
733 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
734 static bool |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
735 fr30_function_value_regno_p (const unsigned int regno) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
736 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
737 return (regno == RETURN_VALUE_REGNUM); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
738 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
739 |
0 | 740 /*{{{ Function arguments */ |
741 | |
742 /* Return true if we should pass an argument on the stack rather than | |
743 in registers. */ | |
744 | |
745 static bool | |
111 | 746 fr30_must_pass_in_stack (machine_mode mode, const_tree type) |
0 | 747 { |
748 if (mode == BLKmode) | |
749 return true; | |
750 if (type == NULL) | |
751 return false; | |
752 return AGGREGATE_TYPE_P (type); | |
753 } | |
754 | |
755 /* Compute the number of word sized registers needed to hold a | |
756 function argument of mode INT_MODE and tree 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
|
757 static int |
111 | 758 fr30_num_arg_regs (machine_mode mode, const_tree type) |
0 | 759 { |
760 int size; | |
761 | |
762 if (targetm.calls.must_pass_in_stack (mode, type)) | |
763 return 0; | |
764 | |
765 if (type && mode == BLKmode) | |
766 size = int_size_in_bytes (type); | |
767 else | |
768 size = GET_MODE_SIZE (mode); | |
769 | |
770 return (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; | |
771 } | |
772 | |
773 /* Returns the number of bytes in which *part* of a parameter of machine | |
774 mode MODE and tree type TYPE (which may be NULL if the type is not known). | |
775 If the argument fits entirely in the argument registers, or entirely on | |
776 the stack, then 0 is returned. | |
777 CUM is the number of argument registers already used by earlier | |
778 parameters to the function. */ | |
779 | |
780 static int | |
111 | 781 fr30_arg_partial_bytes (cumulative_args_t cum_v, machine_mode mode, |
0 | 782 tree type, bool named) |
783 { | |
111 | 784 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); |
785 | |
0 | 786 /* Unnamed arguments, i.e. those that are prototyped as ... |
787 are always passed on the stack. | |
788 Also check here to see if all the argument registers are full. */ | |
789 if (named == 0 || *cum >= FR30_NUM_ARG_REGS) | |
790 return 0; | |
791 | |
792 /* Work out how many argument registers would be needed if this | |
793 parameter were to be passed entirely in registers. If there | |
794 are sufficient argument registers available (or if no registers | |
795 are needed because the parameter must be passed on the stack) | |
796 then return zero, as this parameter does not require partial | |
797 register, partial stack stack space. */ | |
798 if (*cum + fr30_num_arg_regs (mode, type) <= FR30_NUM_ARG_REGS) | |
799 return 0; | |
800 | |
801 return (FR30_NUM_ARG_REGS - *cum) * UNITS_PER_WORD; | |
802 } | |
803 | |
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
|
804 static rtx |
111 | 805 fr30_function_arg (cumulative_args_t cum_v, machine_mode mode, |
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
|
806 const_tree type, bool named) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
807 { |
111 | 808 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); |
809 | |
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
|
810 if (!named |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
811 || fr30_must_pass_in_stack (mode, 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
|
812 || *cum >= FR30_NUM_ARG_REGS) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
813 return 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
|
814 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
|
815 return gen_rtx_REG (mode, *cum + FIRST_ARG_REGNUM); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
816 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
817 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
818 /* A C statement (sans semicolon) to update the summarizer variable CUM to |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
819 advance past an argument in the argument list. The values MODE, TYPE and |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
820 NAMED describe that argument. Once this is done, the variable CUM is |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
821 suitable for analyzing the *following* argument with `FUNCTION_ARG', etc. |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
822 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
823 This macro need not do anything if the argument in question was passed on |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
824 the stack. The compiler knows how to track the amount of stack space used |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
825 for arguments without any special help. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
826 static void |
111 | 827 fr30_function_arg_advance (cumulative_args_t cum, machine_mode mode, |
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
|
828 const_tree type, bool named) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
829 { |
111 | 830 *get_cumulative_args (cum) += named * fr30_num_arg_regs (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
|
831 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
832 |
0 | 833 /*}}}*/ |
834 /*{{{ Operand predicates */ | |
835 | |
836 #ifndef Mmode | |
111 | 837 #define Mmode machine_mode |
0 | 838 #endif |
839 | |
840 /* Returns true iff all the registers in the operands array | |
841 are in descending or ascending order. */ | |
842 int | |
843 fr30_check_multiple_regs (rtx *operands, int num_operands, int descending) | |
844 { | |
845 if (descending) | |
846 { | |
847 unsigned int prev_regno = 0; | |
848 | |
849 while (num_operands --) | |
850 { | |
851 if (GET_CODE (operands [num_operands]) != REG) | |
852 return 0; | |
853 | |
854 if (REGNO (operands [num_operands]) < prev_regno) | |
855 return 0; | |
856 | |
857 prev_regno = REGNO (operands [num_operands]); | |
858 } | |
859 } | |
860 else | |
861 { | |
862 unsigned int prev_regno = CONDITION_CODE_REGNUM; | |
863 | |
864 while (num_operands --) | |
865 { | |
866 if (GET_CODE (operands [num_operands]) != REG) | |
867 return 0; | |
868 | |
869 if (REGNO (operands [num_operands]) > prev_regno) | |
870 return 0; | |
871 | |
872 prev_regno = REGNO (operands [num_operands]); | |
873 } | |
874 } | |
875 | |
876 return 1; | |
877 } | |
878 | |
879 int | |
880 fr30_const_double_is_zero (rtx operand) | |
881 { | |
882 if (operand == NULL || GET_CODE (operand) != CONST_DOUBLE) | |
883 return 0; | |
884 | |
111 | 885 return real_equal (CONST_DOUBLE_REAL_VALUE (operand), &dconst0); |
0 | 886 } |
887 | |
888 /*}}}*/ | |
889 /*{{{ Instruction Output Routines */ | |
890 | |
891 /* Output a double word move. | |
892 It must be REG<-REG, REG<-MEM, MEM<-REG or REG<-CONST. | |
893 On the FR30 we are constrained by the fact that it does not | |
894 support offsetable addresses, and so we have to load the | |
895 address of the secnd word into the second destination register | |
896 before we can use it. */ | |
897 | |
898 rtx | |
899 fr30_move_double (rtx * operands) | |
900 { | |
901 rtx src = operands[1]; | |
902 rtx dest = operands[0]; | |
903 enum rtx_code src_code = GET_CODE (src); | |
904 enum rtx_code dest_code = GET_CODE (dest); | |
111 | 905 machine_mode mode = GET_MODE (dest); |
0 | 906 rtx val; |
907 | |
908 start_sequence (); | |
909 | |
910 if (dest_code == REG) | |
911 { | |
912 if (src_code == REG) | |
913 { | |
914 int reverse = (REGNO (dest) == REGNO (src) + 1); | |
915 | |
916 /* We normally copy the low-numbered register first. However, if | |
917 the first register of operand 0 is the same as the second register | |
918 of operand 1, we must copy in the opposite order. */ | |
111 | 919 emit_insn (gen_rtx_SET (operand_subword (dest, reverse, TRUE, mode), |
0 | 920 operand_subword (src, reverse, TRUE, mode))); |
921 | |
111 | 922 emit_insn |
923 (gen_rtx_SET (operand_subword (dest, !reverse, TRUE, mode), | |
924 operand_subword (src, !reverse, TRUE, mode))); | |
0 | 925 } |
926 else if (src_code == MEM) | |
927 { | |
928 rtx addr = XEXP (src, 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
|
929 rtx dest0 = operand_subword (dest, 0, TRUE, 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
|
930 rtx dest1 = operand_subword (dest, 1, TRUE, mode); |
0 | 931 rtx new_mem; |
932 | |
933 gcc_assert (GET_CODE (addr) == REG); | |
934 | |
935 /* Copy the address before clobbering it. See PR 34174. */ | |
111 | 936 emit_insn (gen_rtx_SET (dest1, addr)); |
937 emit_insn (gen_rtx_SET (dest0, adjust_address (src, SImode, 0))); | |
938 emit_insn (gen_rtx_SET (dest1, plus_constant (SImode, dest1, | |
939 UNITS_PER_WORD))); | |
0 | 940 |
941 new_mem = gen_rtx_MEM (SImode, dest1); | |
942 MEM_COPY_ATTRIBUTES (new_mem, src); | |
943 | |
111 | 944 emit_insn (gen_rtx_SET (dest1, new_mem)); |
0 | 945 } |
946 else if (src_code == CONST_INT || src_code == CONST_DOUBLE) | |
947 { | |
948 rtx words[2]; | |
949 split_double (src, &words[0], &words[1]); | |
111 | 950 emit_insn (gen_rtx_SET (operand_subword (dest, 0, TRUE, mode), |
0 | 951 words[0])); |
952 | |
111 | 953 emit_insn (gen_rtx_SET (operand_subword (dest, 1, TRUE, mode), |
0 | 954 words[1])); |
955 } | |
956 } | |
957 else if (src_code == REG && dest_code == MEM) | |
958 { | |
959 rtx addr = XEXP (dest, 0); | |
960 rtx src0; | |
961 rtx src1; | |
962 | |
963 gcc_assert (GET_CODE (addr) == REG); | |
964 | |
965 src0 = operand_subword (src, 0, TRUE, mode); | |
966 src1 = operand_subword (src, 1, TRUE, mode); | |
967 | |
968 emit_move_insn (adjust_address (dest, SImode, 0), src0); | |
969 | |
970 if (REGNO (addr) == STACK_POINTER_REGNUM | |
971 || REGNO (addr) == FRAME_POINTER_REGNUM) | |
111 | 972 emit_insn (gen_rtx_SET (adjust_address (dest, SImode, UNITS_PER_WORD), |
0 | 973 src1)); |
974 else | |
975 { | |
976 rtx new_mem; | |
977 rtx scratch_reg_r0 = gen_rtx_REG (SImode, 0); | |
978 | |
979 /* We need a scratch register to hold the value of 'address + 4'. | |
980 We use r0 for this purpose. It is used for example for long | |
981 jumps and is already marked to not be used by normal register | |
982 allocation. */ | |
983 emit_insn (gen_movsi_internal (scratch_reg_r0, addr)); | |
984 emit_insn (gen_addsi_small_int (scratch_reg_r0, scratch_reg_r0, | |
985 GEN_INT (UNITS_PER_WORD))); | |
986 new_mem = gen_rtx_MEM (SImode, scratch_reg_r0); | |
987 MEM_COPY_ATTRIBUTES (new_mem, dest); | |
988 emit_move_insn (new_mem, src1); | |
989 emit_insn (gen_blockage ()); | |
990 } | |
991 } | |
992 else | |
993 /* This should have been prevented by the constraints on movdi_insn. */ | |
994 gcc_unreachable (); | |
995 | |
996 val = get_insns (); | |
997 end_sequence (); | |
998 | |
999 return val; | |
1000 } | |
1001 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1002 /* Implement TARGET_FRAME_POINTER_REQUIRED. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1003 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1004 bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1005 fr30_frame_pointer_required (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1006 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1007 return (flag_omit_frame_pointer == 0 || crtl->args.pretend_args_size > 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1008 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1009 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1010 /*}}}*/ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1011 /*{{{ Trampoline Output Routines */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1012 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1013 /* Implement TARGET_ASM_TRAMPOLINE_TEMPLATE. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1014 On the FR30, the trampoline is: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1015 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1016 nop |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1017 ldi:32 STATIC, r12 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1018 nop |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1019 ldi:32 FUNCTION, r0 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1020 jmp @r0 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1021 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1022 The no-ops are to guarantee that the static chain and final |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1023 target are 32 bit aligned within the trampoline. That allows us to |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1024 initialize those locations with simple SImode stores. The alternative |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1025 would be to use HImode stores. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1026 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1027 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1028 fr30_asm_trampoline_template (FILE *f) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1029 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1030 fprintf (f, "\tnop\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1031 fprintf (f, "\tldi:32\t#0, %s\n", reg_names [STATIC_CHAIN_REGNUM]); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1032 fprintf (f, "\tnop\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1033 fprintf (f, "\tldi:32\t#0, %s\n", reg_names [COMPILER_SCRATCH_REGISTER]); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1034 fprintf (f, "\tjmp\t@%s\n", reg_names [COMPILER_SCRATCH_REGISTER]); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1035 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1036 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1037 /* Implement TARGET_TRAMPOLINE_INIT. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1038 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1039 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1040 fr30_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1041 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1042 rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1043 rtx mem; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1044 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1045 emit_block_move (m_tramp, assemble_trampoline_template (), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1046 GEN_INT (TRAMPOLINE_SIZE), BLOCK_OP_NORMAL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1047 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1048 mem = adjust_address (m_tramp, SImode, 4); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1049 emit_move_insn (mem, chain_value); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1050 mem = adjust_address (m_tramp, SImode, 12); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1051 emit_move_insn (mem, fnaddr); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1052 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1053 |
0 | 1054 /*}}}*/ |
1055 /* Local Variables: */ | |
1056 /* folded-file: t */ | |
1057 /* End: */ |