]>
Commit | Line | Data |
---|---|---|
11bb1f11 | 1 | /* Subroutines for insn-output.c for Matsushita MN10300 series |
9024ea92 | 2 | Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 |
92547f12 | 3 | Free Software Foundation, Inc. |
11bb1f11 JL |
4 | Contributed by Jeff Law (law@cygnus.com). |
5 | ||
7ec022b2 | 6 | This file is part of GCC. |
11bb1f11 | 7 | |
7ec022b2 | 8 | GCC is free software; you can redistribute it and/or modify |
11bb1f11 JL |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
7ec022b2 | 13 | GCC is distributed in the hope that it will be useful, |
11bb1f11 JL |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
7ec022b2 | 19 | along with GCC; see the file COPYING. If not, write to |
11bb1f11 JL |
20 | the Free Software Foundation, 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
11bb1f11 | 23 | #include "config.h" |
c5c76735 | 24 | #include "system.h" |
4977bab6 ZW |
25 | #include "coretypes.h" |
26 | #include "tm.h" | |
11bb1f11 | 27 | #include "rtl.h" |
bf6bb899 | 28 | #include "tree.h" |
11bb1f11 JL |
29 | #include "regs.h" |
30 | #include "hard-reg-set.h" | |
31 | #include "real.h" | |
32 | #include "insn-config.h" | |
33 | #include "conditions.h" | |
11bb1f11 JL |
34 | #include "output.h" |
35 | #include "insn-attr.h" | |
36 | #include "flags.h" | |
37 | #include "recog.h" | |
38 | #include "expr.h" | |
e78d8e51 | 39 | #include "optabs.h" |
bf6bb899 | 40 | #include "function.h" |
11bb1f11 | 41 | #include "obstack.h" |
69bc71fa KG |
42 | #include "toplev.h" |
43 | #include "tm_p.h" | |
672a6f42 NB |
44 | #include "target.h" |
45 | #include "target-def.h" | |
11bb1f11 | 46 | |
d1776069 AO |
47 | /* This is used by GOTaddr2picreg to uniquely identify |
48 | UNSPEC_INT_LABELs. */ | |
49 | int mn10300_unspec_int_label_counter; | |
50 | ||
2beef00e AO |
51 | /* This is used in the am33_2.0-linux-gnu port, in which global symbol |
52 | names are not prefixed by underscores, to tell whether to prefix a | |
53 | label with a plus sign or not, so that the assembler can tell | |
54 | symbol names from register names. */ | |
55 | int mn10300_protect_label; | |
56 | ||
4d1a91c2 JL |
57 | /* The size of the callee register save area. Right now we save everything |
58 | on entry since it costs us nothing in code size. It does cost us from a | |
59 | speed standpoint, so we want to optimize this sooner or later. */ | |
980d0e81 JL |
60 | #define REG_SAVE_BYTES (4 * regs_ever_live[2] \ |
61 | + 4 * regs_ever_live[3] \ | |
705ac34f JL |
62 | + 4 * regs_ever_live[6] \ |
63 | + 4 * regs_ever_live[7] \ | |
64 | + 16 * (regs_ever_live[14] || regs_ever_live[15] \ | |
65 | || regs_ever_live[16] || regs_ever_live[17])) | |
3c50106f RH |
66 | |
67 | ||
7f682641 SB |
68 | static int mn10300_address_cost_1 (rtx, int *); |
69 | static int mn10300_address_cost (rtx); | |
70 | static bool mn10300_rtx_costs (rtx, int, int, int *); | |
71 | static void mn10300_file_start (void); | |
9024ea92 KH |
72 | static bool mn10300_return_in_memory (tree, tree); |
73 | static rtx mn10300_builtin_saveregs (void); | |
3c50106f | 74 | |
672a6f42 NB |
75 | \f |
76 | /* Initialize the GCC target structure. */ | |
301d03af RS |
77 | #undef TARGET_ASM_ALIGNED_HI_OP |
78 | #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t" | |
4d1a91c2 | 79 | |
3c50106f RH |
80 | #undef TARGET_RTX_COSTS |
81 | #define TARGET_RTX_COSTS mn10300_rtx_costs | |
dcefdf67 RH |
82 | #undef TARGET_ADDRESS_COST |
83 | #define TARGET_ADDRESS_COST mn10300_address_cost | |
3c50106f | 84 | |
1bc7c5b6 ZW |
85 | #undef TARGET_ASM_FILE_START |
86 | #define TARGET_ASM_FILE_START mn10300_file_start | |
87 | #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE | |
88 | #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true | |
89 | ||
d1776069 AO |
90 | #undef TARGET_ENCODE_SECTION_INFO |
91 | #define TARGET_ENCODE_SECTION_INFO mn10300_encode_section_info | |
92 | ||
9024ea92 KH |
93 | #undef TARGET_PROMOTE_PROTOTYPES |
94 | #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true | |
95 | ||
9024ea92 KH |
96 | #undef TARGET_RETURN_IN_MEMORY |
97 | #define TARGET_RETURN_IN_MEMORY mn10300_return_in_memory | |
98 | ||
99 | #undef TARGET_EXPAND_BUILTIN_SAVEREGS | |
100 | #define TARGET_EXPAND_BUILTIN_SAVEREGS mn10300_builtin_saveregs | |
101 | ||
d1776069 | 102 | static void mn10300_encode_section_info (tree, rtx, int); |
f6897b10 | 103 | struct gcc_target targetm = TARGET_INITIALIZER; |
672a6f42 | 104 | \f |
1bc7c5b6 | 105 | static void |
f1777882 | 106 | mn10300_file_start (void) |
11bb1f11 | 107 | { |
1bc7c5b6 | 108 | default_file_start (); |
705ac34f | 109 | |
18e9d2f9 AO |
110 | if (TARGET_AM33_2) |
111 | fprintf (asm_out_file, "\t.am33_2\n"); | |
112 | else if (TARGET_AM33) | |
1bc7c5b6 | 113 | fprintf (asm_out_file, "\t.am33\n"); |
11bb1f11 JL |
114 | } |
115 | \f | |
116 | ||
11bb1f11 JL |
117 | /* Print operand X using operand code CODE to assembly language output file |
118 | FILE. */ | |
119 | ||
120 | void | |
f1777882 | 121 | print_operand (FILE *file, rtx x, int code) |
11bb1f11 JL |
122 | { |
123 | switch (code) | |
124 | { | |
125 | case 'b': | |
126 | case 'B': | |
18e9d2f9 AO |
127 | if (cc_status.mdep.fpCC) |
128 | { | |
129 | switch (code == 'b' ? GET_CODE (x) | |
130 | : reverse_condition_maybe_unordered (GET_CODE (x))) | |
131 | { | |
132 | case NE: | |
133 | fprintf (file, "ne"); | |
134 | break; | |
135 | case EQ: | |
136 | fprintf (file, "eq"); | |
137 | break; | |
138 | case GE: | |
139 | fprintf (file, "ge"); | |
140 | break; | |
141 | case GT: | |
142 | fprintf (file, "gt"); | |
143 | break; | |
144 | case LE: | |
145 | fprintf (file, "le"); | |
146 | break; | |
147 | case LT: | |
148 | fprintf (file, "lt"); | |
149 | break; | |
150 | case ORDERED: | |
151 | fprintf (file, "lge"); | |
152 | break; | |
153 | case UNORDERED: | |
154 | fprintf (file, "uo"); | |
155 | break; | |
156 | case LTGT: | |
157 | fprintf (file, "lg"); | |
158 | break; | |
159 | case UNEQ: | |
160 | fprintf (file, "ue"); | |
161 | break; | |
162 | case UNGE: | |
163 | fprintf (file, "uge"); | |
164 | break; | |
165 | case UNGT: | |
166 | fprintf (file, "ug"); | |
167 | break; | |
168 | case UNLE: | |
169 | fprintf (file, "ule"); | |
170 | break; | |
171 | case UNLT: | |
172 | fprintf (file, "ul"); | |
173 | break; | |
174 | default: | |
175 | abort (); | |
176 | } | |
177 | break; | |
178 | } | |
11bb1f11 JL |
179 | /* These are normal and reversed branches. */ |
180 | switch (code == 'b' ? GET_CODE (x) : reverse_condition (GET_CODE (x))) | |
181 | { | |
182 | case NE: | |
183 | fprintf (file, "ne"); | |
184 | break; | |
185 | case EQ: | |
186 | fprintf (file, "eq"); | |
187 | break; | |
188 | case GE: | |
189 | fprintf (file, "ge"); | |
190 | break; | |
191 | case GT: | |
192 | fprintf (file, "gt"); | |
193 | break; | |
194 | case LE: | |
195 | fprintf (file, "le"); | |
196 | break; | |
197 | case LT: | |
198 | fprintf (file, "lt"); | |
199 | break; | |
200 | case GEU: | |
201 | fprintf (file, "cc"); | |
202 | break; | |
203 | case GTU: | |
204 | fprintf (file, "hi"); | |
205 | break; | |
206 | case LEU: | |
207 | fprintf (file, "ls"); | |
208 | break; | |
209 | case LTU: | |
210 | fprintf (file, "cs"); | |
211 | break; | |
212 | default: | |
213 | abort (); | |
214 | } | |
215 | break; | |
216 | case 'C': | |
217 | /* This is used for the operand to a call instruction; | |
218 | if it's a REG, enclose it in parens, else output | |
219 | the operand normally. */ | |
220 | if (GET_CODE (x) == REG) | |
221 | { | |
222 | fputc ('(', file); | |
223 | print_operand (file, x, 0); | |
224 | fputc (')', file); | |
225 | } | |
226 | else | |
227 | print_operand (file, x, 0); | |
228 | break; | |
229 | ||
18e9d2f9 AO |
230 | case 'D': |
231 | switch (GET_CODE (x)) | |
232 | { | |
233 | case MEM: | |
234 | fputc ('(', file); | |
235 | output_address (XEXP (x, 0)); | |
236 | fputc (')', file); | |
237 | break; | |
238 | ||
239 | case REG: | |
240 | fprintf (file, "fd%d", REGNO (x) - 18); | |
241 | break; | |
242 | ||
243 | default: | |
244 | abort (); | |
245 | } | |
246 | break; | |
247 | ||
38c37a0e JL |
248 | /* These are the least significant word in a 64bit value. */ |
249 | case 'L': | |
250 | switch (GET_CODE (x)) | |
251 | { | |
252 | case MEM: | |
253 | fputc ('(', file); | |
254 | output_address (XEXP (x, 0)); | |
255 | fputc (')', file); | |
256 | break; | |
257 | ||
258 | case REG: | |
259 | fprintf (file, "%s", reg_names[REGNO (x)]); | |
260 | break; | |
261 | ||
262 | case SUBREG: | |
ddef6bc7 | 263 | fprintf (file, "%s", reg_names[subreg_regno (x)]); |
38c37a0e JL |
264 | break; |
265 | ||
266 | case CONST_DOUBLE: | |
267 | { | |
268 | long val[2]; | |
269 | REAL_VALUE_TYPE rv; | |
270 | ||
271 | switch (GET_MODE (x)) | |
272 | { | |
273 | case DFmode: | |
274 | REAL_VALUE_FROM_CONST_DOUBLE (rv, x); | |
275 | REAL_VALUE_TO_TARGET_DOUBLE (rv, val); | |
cf31fafa | 276 | fprintf (file, "0x%lx", val[0]); |
38c37a0e JL |
277 | break;; |
278 | case SFmode: | |
279 | REAL_VALUE_FROM_CONST_DOUBLE (rv, x); | |
280 | REAL_VALUE_TO_TARGET_SINGLE (rv, val[0]); | |
cf31fafa | 281 | fprintf (file, "0x%lx", val[0]); |
38c37a0e JL |
282 | break;; |
283 | case VOIDmode: | |
284 | case DImode: | |
285 | print_operand_address (file, | |
286 | GEN_INT (CONST_DOUBLE_LOW (x))); | |
287 | break; | |
69bc71fa KG |
288 | default: |
289 | break; | |
38c37a0e JL |
290 | } |
291 | break; | |
292 | } | |
293 | ||
294 | case CONST_INT: | |
212bc5fa AO |
295 | { |
296 | rtx low, high; | |
297 | split_double (x, &low, &high); | |
298 | fprintf (file, "%ld", (long)INTVAL (low)); | |
299 | break; | |
300 | } | |
38c37a0e JL |
301 | |
302 | default: | |
303 | abort (); | |
304 | } | |
305 | break; | |
306 | ||
307 | /* Similarly, but for the most significant word. */ | |
308 | case 'H': | |
309 | switch (GET_CODE (x)) | |
310 | { | |
311 | case MEM: | |
312 | fputc ('(', file); | |
b72f00af | 313 | x = adjust_address (x, SImode, 4); |
38c37a0e JL |
314 | output_address (XEXP (x, 0)); |
315 | fputc (')', file); | |
316 | break; | |
317 | ||
318 | case REG: | |
319 | fprintf (file, "%s", reg_names[REGNO (x) + 1]); | |
320 | break; | |
321 | ||
322 | case SUBREG: | |
ddef6bc7 | 323 | fprintf (file, "%s", reg_names[subreg_regno (x) + 1]); |
38c37a0e JL |
324 | break; |
325 | ||
326 | case CONST_DOUBLE: | |
327 | { | |
328 | long val[2]; | |
329 | REAL_VALUE_TYPE rv; | |
330 | ||
331 | switch (GET_MODE (x)) | |
332 | { | |
333 | case DFmode: | |
334 | REAL_VALUE_FROM_CONST_DOUBLE (rv, x); | |
335 | REAL_VALUE_TO_TARGET_DOUBLE (rv, val); | |
cf31fafa | 336 | fprintf (file, "0x%lx", val[1]); |
38c37a0e JL |
337 | break;; |
338 | case SFmode: | |
339 | abort (); | |
340 | case VOIDmode: | |
341 | case DImode: | |
342 | print_operand_address (file, | |
343 | GEN_INT (CONST_DOUBLE_HIGH (x))); | |
344 | break; | |
69bc71fa KG |
345 | default: |
346 | break; | |
38c37a0e JL |
347 | } |
348 | break; | |
349 | } | |
350 | ||
351 | case CONST_INT: | |
212bc5fa AO |
352 | { |
353 | rtx low, high; | |
354 | split_double (x, &low, &high); | |
355 | fprintf (file, "%ld", (long)INTVAL (high)); | |
356 | break; | |
357 | } | |
358 | ||
38c37a0e JL |
359 | default: |
360 | abort (); | |
361 | } | |
362 | break; | |
363 | ||
364 | case 'A': | |
365 | fputc ('(', file); | |
366 | if (GET_CODE (XEXP (x, 0)) == REG) | |
a556fd39 | 367 | output_address (gen_rtx_PLUS (SImode, XEXP (x, 0), const0_rtx)); |
38c37a0e JL |
368 | else |
369 | output_address (XEXP (x, 0)); | |
370 | fputc (')', file); | |
371 | break; | |
372 | ||
6fafc523 | 373 | case 'N': |
a58be199 AO |
374 | if (INTVAL (x) < -128 || INTVAL (x) > 255) |
375 | abort (); | |
376 | fprintf (file, "%d", (int)((~INTVAL (x)) & 0xff)); | |
377 | break; | |
378 | ||
379 | case 'U': | |
380 | if (INTVAL (x) < -128 || INTVAL (x) > 255) | |
381 | abort (); | |
382 | fprintf (file, "%d", (int)(INTVAL (x) & 0xff)); | |
6fafc523 JL |
383 | break; |
384 | ||
576e5acc JL |
385 | /* For shift counts. The hardware ignores the upper bits of |
386 | any immediate, but the assembler will flag an out of range | |
387 | shift count as an error. So we mask off the high bits | |
388 | of the immediate here. */ | |
389 | case 'S': | |
390 | if (GET_CODE (x) == CONST_INT) | |
391 | { | |
a58be199 | 392 | fprintf (file, "%d", (int)(INTVAL (x) & 0x1f)); |
576e5acc JL |
393 | break; |
394 | } | |
395 | /* FALL THROUGH */ | |
396 | ||
11bb1f11 JL |
397 | default: |
398 | switch (GET_CODE (x)) | |
399 | { | |
400 | case MEM: | |
401 | fputc ('(', file); | |
402 | output_address (XEXP (x, 0)); | |
403 | fputc (')', file); | |
404 | break; | |
405 | ||
38c37a0e JL |
406 | case PLUS: |
407 | output_address (x); | |
408 | break; | |
409 | ||
11bb1f11 JL |
410 | case REG: |
411 | fprintf (file, "%s", reg_names[REGNO (x)]); | |
412 | break; | |
413 | ||
414 | case SUBREG: | |
ddef6bc7 | 415 | fprintf (file, "%s", reg_names[subreg_regno (x)]); |
11bb1f11 JL |
416 | break; |
417 | ||
38c37a0e JL |
418 | /* This will only be single precision.... */ |
419 | case CONST_DOUBLE: | |
420 | { | |
421 | unsigned long val; | |
422 | REAL_VALUE_TYPE rv; | |
423 | ||
424 | REAL_VALUE_FROM_CONST_DOUBLE (rv, x); | |
425 | REAL_VALUE_TO_TARGET_SINGLE (rv, val); | |
cf31fafa | 426 | fprintf (file, "0x%lx", val); |
38c37a0e JL |
427 | break; |
428 | } | |
429 | ||
11bb1f11 JL |
430 | case CONST_INT: |
431 | case SYMBOL_REF: | |
432 | case CONST: | |
433 | case LABEL_REF: | |
434 | case CODE_LABEL: | |
d1776069 | 435 | case UNSPEC: |
11bb1f11 JL |
436 | print_operand_address (file, x); |
437 | break; | |
438 | default: | |
439 | abort (); | |
440 | } | |
441 | break; | |
442 | } | |
443 | } | |
444 | ||
445 | /* Output assembly language output for the address ADDR to FILE. */ | |
446 | ||
447 | void | |
f1777882 | 448 | print_operand_address (FILE *file, rtx addr) |
11bb1f11 JL |
449 | { |
450 | switch (GET_CODE (addr)) | |
451 | { | |
705ac34f JL |
452 | case POST_INC: |
453 | print_operand_address (file, XEXP (addr, 0)); | |
454 | fputc ('+', file); | |
455 | break; | |
11bb1f11 | 456 | case REG: |
79e4122c | 457 | print_operand (file, addr, 0); |
11bb1f11 JL |
458 | break; |
459 | case PLUS: | |
460 | { | |
461 | rtx base, index; | |
462 | if (REG_P (XEXP (addr, 0)) | |
463 | && REG_OK_FOR_BASE_P (XEXP (addr, 0))) | |
464 | base = XEXP (addr, 0), index = XEXP (addr, 1); | |
465 | else if (REG_P (XEXP (addr, 1)) | |
466 | && REG_OK_FOR_BASE_P (XEXP (addr, 1))) | |
467 | base = XEXP (addr, 1), index = XEXP (addr, 0); | |
468 | else | |
469 | abort (); | |
470 | print_operand (file, index, 0); | |
471 | fputc (',', file); | |
472 | print_operand (file, base, 0);; | |
473 | break; | |
474 | } | |
475 | case SYMBOL_REF: | |
476 | output_addr_const (file, addr); | |
477 | break; | |
478 | default: | |
479 | output_addr_const (file, addr); | |
480 | break; | |
481 | } | |
482 | } | |
483 | ||
18e9d2f9 AO |
484 | /* Count the number of FP registers that have to be saved. */ |
485 | static int | |
f1777882 | 486 | fp_regs_to_save (void) |
18e9d2f9 AO |
487 | { |
488 | int i, n = 0; | |
489 | ||
490 | if (! TARGET_AM33_2) | |
491 | return 0; | |
492 | ||
493 | for (i = FIRST_FP_REGNUM; i <= LAST_FP_REGNUM; ++i) | |
494 | if (regs_ever_live[i] && ! call_used_regs[i]) | |
495 | ++n; | |
496 | ||
497 | return n; | |
498 | } | |
499 | ||
f6cd7c62 RS |
500 | /* Print a set of registers in the format required by "movm" and "ret". |
501 | Register K is saved if bit K of MASK is set. The data and address | |
502 | registers can be stored individually, but the extended registers cannot. | |
503 | We assume that the mask alread takes that into account. For instance, | |
8596d0a1 | 504 | bits 14 to 17 must have the same value. */ |
f6cd7c62 RS |
505 | |
506 | void | |
f1777882 | 507 | mn10300_print_reg_list (FILE *file, int mask) |
f6cd7c62 RS |
508 | { |
509 | int need_comma; | |
510 | int i; | |
511 | ||
512 | need_comma = 0; | |
513 | fputc ('[', file); | |
514 | ||
515 | for (i = 0; i < FIRST_EXTENDED_REGNUM; i++) | |
516 | if ((mask & (1 << i)) != 0) | |
517 | { | |
518 | if (need_comma) | |
519 | fputc (',', file); | |
520 | fputs (reg_names [i], file); | |
521 | need_comma = 1; | |
522 | } | |
523 | ||
524 | if ((mask & 0x3c000) != 0) | |
525 | { | |
526 | if ((mask & 0x3c000) != 0x3c000) | |
527 | abort(); | |
528 | if (need_comma) | |
529 | fputc (',', file); | |
530 | fputs ("exreg1", file); | |
531 | need_comma = 1; | |
532 | } | |
533 | ||
534 | fputc (']', file); | |
535 | } | |
536 | ||
38c37a0e | 537 | int |
f1777882 | 538 | can_use_return_insn (void) |
38c37a0e | 539 | { |
460f4b9d JL |
540 | /* size includes the fixed stack space needed for function calls. */ |
541 | int size = get_frame_size () + current_function_outgoing_args_size; | |
542 | ||
543 | /* And space for the return pointer. */ | |
544 | size += current_function_outgoing_args_size ? 4 : 0; | |
38c37a0e JL |
545 | |
546 | return (reload_completed | |
547 | && size == 0 | |
548 | && !regs_ever_live[2] | |
549 | && !regs_ever_live[3] | |
550 | && !regs_ever_live[6] | |
551 | && !regs_ever_live[7] | |
705ac34f JL |
552 | && !regs_ever_live[14] |
553 | && !regs_ever_live[15] | |
554 | && !regs_ever_live[16] | |
555 | && !regs_ever_live[17] | |
18e9d2f9 | 556 | && fp_regs_to_save () == 0 |
38c37a0e JL |
557 | && !frame_pointer_needed); |
558 | } | |
559 | ||
f6cd7c62 RS |
560 | /* Returns the set of live, callee-saved registers as a bitmask. The |
561 | callee-saved extended registers cannot be stored individually, so | |
8596d0a1 | 562 | all of them will be included in the mask if any one of them is used. */ |
f6cd7c62 RS |
563 | |
564 | int | |
f1777882 | 565 | mn10300_get_live_callee_saved_regs (void) |
f6cd7c62 RS |
566 | { |
567 | int mask; | |
568 | int i; | |
569 | ||
570 | mask = 0; | |
18e9d2f9 | 571 | for (i = 0; i <= LAST_EXTENDED_REGNUM; i++) |
f6cd7c62 RS |
572 | if (regs_ever_live[i] && ! call_used_regs[i]) |
573 | mask |= (1 << i); | |
574 | if ((mask & 0x3c000) != 0) | |
575 | mask |= 0x3c000; | |
576 | ||
577 | return mask; | |
578 | } | |
579 | ||
580 | /* Generate an instruction that pushes several registers onto the stack. | |
581 | Register K will be saved if bit K in MASK is set. The function does | |
582 | nothing if MASK is zero. | |
583 | ||
584 | To be compatible with the "movm" instruction, the lowest-numbered | |
585 | register must be stored in the lowest slot. If MASK is the set | |
586 | { R1,...,RN }, where R1...RN are ordered least first, the generated | |
587 | instruction will have the form: | |
588 | ||
589 | (parallel | |
590 | (set (reg:SI 9) (plus:SI (reg:SI 9) (const_int -N*4))) | |
591 | (set (mem:SI (plus:SI (reg:SI 9) | |
592 | (const_int -1*4))) | |
593 | (reg:SI RN)) | |
594 | ... | |
595 | (set (mem:SI (plus:SI (reg:SI 9) | |
596 | (const_int -N*4))) | |
597 | (reg:SI R1))) */ | |
598 | ||
599 | void | |
f1777882 | 600 | mn10300_gen_multiple_store (int mask) |
f6cd7c62 RS |
601 | { |
602 | if (mask != 0) | |
603 | { | |
604 | int i; | |
605 | int count; | |
606 | rtx par; | |
607 | int pari; | |
608 | ||
8596d0a1 | 609 | /* Count how many registers need to be saved. */ |
f6cd7c62 | 610 | count = 0; |
18e9d2f9 | 611 | for (i = 0; i <= LAST_EXTENDED_REGNUM; i++) |
f6cd7c62 RS |
612 | if ((mask & (1 << i)) != 0) |
613 | count += 1; | |
614 | ||
615 | /* We need one PARALLEL element to update the stack pointer and | |
8596d0a1 | 616 | an additional element for each register that is stored. */ |
f6cd7c62 RS |
617 | par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1)); |
618 | ||
8596d0a1 | 619 | /* Create the instruction that updates the stack pointer. */ |
f6cd7c62 RS |
620 | XVECEXP (par, 0, 0) |
621 | = gen_rtx_SET (SImode, | |
622 | stack_pointer_rtx, | |
623 | gen_rtx_PLUS (SImode, | |
624 | stack_pointer_rtx, | |
625 | GEN_INT (-count * 4))); | |
626 | ||
8596d0a1 | 627 | /* Create each store. */ |
f6cd7c62 | 628 | pari = 1; |
18e9d2f9 | 629 | for (i = LAST_EXTENDED_REGNUM; i >= 0; i--) |
f6cd7c62 RS |
630 | if ((mask & (1 << i)) != 0) |
631 | { | |
632 | rtx address = gen_rtx_PLUS (SImode, | |
633 | stack_pointer_rtx, | |
634 | GEN_INT (-pari * 4)); | |
635 | XVECEXP(par, 0, pari) | |
636 | = gen_rtx_SET (VOIDmode, | |
637 | gen_rtx_MEM (SImode, address), | |
638 | gen_rtx_REG (SImode, i)); | |
639 | pari += 1; | |
640 | } | |
641 | ||
642 | par = emit_insn (par); | |
643 | RTX_FRAME_RELATED_P (par) = 1; | |
644 | } | |
645 | } | |
646 | ||
11bb1f11 | 647 | void |
f1777882 | 648 | expand_prologue (void) |
11bb1f11 | 649 | { |
036182e7 | 650 | HOST_WIDE_INT size; |
3dbc43d1 | 651 | |
3dbc43d1 | 652 | /* SIZE includes the fixed stack space needed for function calls. */ |
460f4b9d JL |
653 | size = get_frame_size () + current_function_outgoing_args_size; |
654 | size += (current_function_outgoing_args_size ? 4 : 0); | |
11bb1f11 | 655 | |
8596d0a1 | 656 | /* If we use any of the callee-saved registers, save them now. */ |
f6cd7c62 | 657 | mn10300_gen_multiple_store (mn10300_get_live_callee_saved_regs ()); |
777fbf09 | 658 | |
18e9d2f9 AO |
659 | if (TARGET_AM33_2 && fp_regs_to_save ()) |
660 | { | |
661 | int num_regs_to_save = fp_regs_to_save (), i; | |
662 | HOST_WIDE_INT xsize; | |
663 | enum { save_sp_merge, | |
664 | save_sp_no_merge, | |
665 | save_sp_partial_merge, | |
666 | save_a0_merge, | |
667 | save_a0_no_merge } strategy; | |
668 | unsigned int strategy_size = (unsigned)-1, this_strategy_size; | |
669 | rtx reg; | |
670 | rtx insn; | |
671 | ||
672 | /* We have several different strategies to save FP registers. | |
673 | We can store them using SP offsets, which is beneficial if | |
674 | there are just a few registers to save, or we can use `a0' in | |
675 | post-increment mode (`a0' is the only call-clobbered address | |
676 | register that is never used to pass information to a | |
677 | function). Furthermore, if we don't need a frame pointer, we | |
678 | can merge the two SP adds into a single one, but this isn't | |
679 | always beneficial; sometimes we can just split the two adds | |
680 | so that we don't exceed a 16-bit constant size. The code | |
681 | below will select which strategy to use, so as to generate | |
682 | smallest code. Ties are broken in favor or shorter sequences | |
683 | (in terms of number of instructions). */ | |
684 | ||
685 | #define SIZE_ADD_AX(S) ((((S) >= (1 << 15)) || ((S) < -(1 << 15))) ? 6 \ | |
686 | : (((S) >= (1 << 7)) || ((S) < -(1 << 7))) ? 4 : 2) | |
687 | #define SIZE_ADD_SP(S) ((((S) >= (1 << 15)) || ((S) < -(1 << 15))) ? 6 \ | |
688 | : (((S) >= (1 << 7)) || ((S) < -(1 << 7))) ? 4 : 3) | |
689 | #define SIZE_FMOV_LIMIT(S,N,L,SIZE1,SIZE2,ELSE) \ | |
690 | (((S) >= (L)) ? (SIZE1) * (N) \ | |
691 | : ((S) + 4 * (N) >= (L)) ? (((L) - (S)) / 4 * (SIZE2) \ | |
692 | + ((S) + 4 * (N) - (L)) / 4 * (SIZE1)) \ | |
693 | : (ELSE)) | |
694 | #define SIZE_FMOV_SP_(S,N) \ | |
695 | (SIZE_FMOV_LIMIT ((S), (N), (1 << 24), 7, 6, \ | |
696 | SIZE_FMOV_LIMIT ((S), (N), (1 << 8), 6, 4, \ | |
697 | (S) ? 4 * (N) : 3 + 4 * ((N) - 1)))) | |
698 | #define SIZE_FMOV_SP(S,N) (SIZE_FMOV_SP_ ((unsigned HOST_WIDE_INT)(S), (N))) | |
699 | ||
700 | /* Consider alternative save_sp_merge only if we don't need the | |
4375e090 | 701 | frame pointer and size is nonzero. */ |
18e9d2f9 AO |
702 | if (! frame_pointer_needed && size) |
703 | { | |
704 | /* Insn: add -(size + 4 * num_regs_to_save), sp. */ | |
705 | this_strategy_size = SIZE_ADD_SP (-(size + 4 * num_regs_to_save)); | |
706 | /* Insn: fmov fs#, (##, sp), for each fs# to be saved. */ | |
707 | this_strategy_size += SIZE_FMOV_SP (size, num_regs_to_save); | |
708 | ||
709 | if (this_strategy_size < strategy_size) | |
710 | { | |
711 | strategy = save_sp_merge; | |
712 | strategy_size = this_strategy_size; | |
713 | } | |
714 | } | |
715 | ||
716 | /* Consider alternative save_sp_no_merge unconditionally. */ | |
717 | /* Insn: add -4 * num_regs_to_save, sp. */ | |
718 | this_strategy_size = SIZE_ADD_SP (-4 * num_regs_to_save); | |
719 | /* Insn: fmov fs#, (##, sp), for each fs# to be saved. */ | |
720 | this_strategy_size += SIZE_FMOV_SP (0, num_regs_to_save); | |
721 | if (size) | |
722 | { | |
723 | /* Insn: add -size, sp. */ | |
724 | this_strategy_size += SIZE_ADD_SP (-size); | |
725 | } | |
726 | ||
727 | if (this_strategy_size < strategy_size) | |
728 | { | |
729 | strategy = save_sp_no_merge; | |
730 | strategy_size = this_strategy_size; | |
731 | } | |
732 | ||
733 | /* Consider alternative save_sp_partial_merge only if we don't | |
734 | need a frame pointer and size is reasonably large. */ | |
735 | if (! frame_pointer_needed && size + 4 * num_regs_to_save > 128) | |
736 | { | |
737 | /* Insn: add -128, sp. */ | |
738 | this_strategy_size = SIZE_ADD_SP (-128); | |
739 | /* Insn: fmov fs#, (##, sp), for each fs# to be saved. */ | |
740 | this_strategy_size += SIZE_FMOV_SP (128 - 4 * num_regs_to_save, | |
741 | num_regs_to_save); | |
742 | if (size) | |
743 | { | |
744 | /* Insn: add 128-size, sp. */ | |
745 | this_strategy_size += SIZE_ADD_SP (128 - size); | |
746 | } | |
747 | ||
748 | if (this_strategy_size < strategy_size) | |
749 | { | |
750 | strategy = save_sp_partial_merge; | |
751 | strategy_size = this_strategy_size; | |
752 | } | |
753 | } | |
754 | ||
755 | /* Consider alternative save_a0_merge only if we don't need a | |
4375e090 | 756 | frame pointer, size is nonzero and the user hasn't |
18e9d2f9 AO |
757 | changed the calling conventions of a0. */ |
758 | if (! frame_pointer_needed && size | |
759 | && call_used_regs[FIRST_ADDRESS_REGNUM] | |
760 | && ! fixed_regs[FIRST_ADDRESS_REGNUM]) | |
761 | { | |
762 | /* Insn: add -(size + 4 * num_regs_to_save), sp. */ | |
763 | this_strategy_size = SIZE_ADD_SP (-(size + 4 * num_regs_to_save)); | |
764 | /* Insn: mov sp, a0. */ | |
765 | this_strategy_size++; | |
766 | if (size) | |
767 | { | |
768 | /* Insn: add size, a0. */ | |
769 | this_strategy_size += SIZE_ADD_AX (size); | |
770 | } | |
771 | /* Insn: fmov fs#, (a0+), for each fs# to be saved. */ | |
772 | this_strategy_size += 3 * num_regs_to_save; | |
773 | ||
774 | if (this_strategy_size < strategy_size) | |
775 | { | |
776 | strategy = save_a0_merge; | |
777 | strategy_size = this_strategy_size; | |
778 | } | |
779 | } | |
780 | ||
781 | /* Consider alternative save_a0_no_merge if the user hasn't | |
8596d0a1 | 782 | changed the calling conventions of a0. */ |
18e9d2f9 AO |
783 | if (call_used_regs[FIRST_ADDRESS_REGNUM] |
784 | && ! fixed_regs[FIRST_ADDRESS_REGNUM]) | |
785 | { | |
786 | /* Insn: add -4 * num_regs_to_save, sp. */ | |
787 | this_strategy_size = SIZE_ADD_SP (-4 * num_regs_to_save); | |
788 | /* Insn: mov sp, a0. */ | |
789 | this_strategy_size++; | |
790 | /* Insn: fmov fs#, (a0+), for each fs# to be saved. */ | |
791 | this_strategy_size += 3 * num_regs_to_save; | |
792 | if (size) | |
793 | { | |
794 | /* Insn: add -size, sp. */ | |
795 | this_strategy_size += SIZE_ADD_SP (-size); | |
796 | } | |
797 | ||
798 | if (this_strategy_size < strategy_size) | |
799 | { | |
800 | strategy = save_a0_no_merge; | |
801 | strategy_size = this_strategy_size; | |
802 | } | |
803 | } | |
804 | ||
805 | /* Emit the initial SP add, common to all strategies. */ | |
806 | switch (strategy) | |
807 | { | |
808 | case save_sp_no_merge: | |
809 | case save_a0_no_merge: | |
810 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
811 | stack_pointer_rtx, | |
812 | GEN_INT (-4 * num_regs_to_save))); | |
813 | xsize = 0; | |
814 | break; | |
815 | ||
816 | case save_sp_partial_merge: | |
817 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
818 | stack_pointer_rtx, | |
819 | GEN_INT (-128))); | |
820 | xsize = 128 - 4 * num_regs_to_save; | |
821 | size -= xsize; | |
822 | break; | |
823 | ||
824 | case save_sp_merge: | |
825 | case save_a0_merge: | |
826 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
827 | stack_pointer_rtx, | |
828 | GEN_INT (-(size + 4 * num_regs_to_save)))); | |
829 | /* We'll have to adjust FP register saves according to the | |
8596d0a1 | 830 | frame size. */ |
18e9d2f9 AO |
831 | xsize = size; |
832 | /* Since we've already created the stack frame, don't do it | |
8596d0a1 | 833 | again at the end of the function. */ |
18e9d2f9 AO |
834 | size = 0; |
835 | break; | |
836 | ||
837 | default: | |
838 | abort (); | |
839 | } | |
840 | ||
841 | /* Now prepare register a0, if we have decided to use it. */ | |
842 | switch (strategy) | |
843 | { | |
844 | case save_sp_merge: | |
845 | case save_sp_no_merge: | |
846 | case save_sp_partial_merge: | |
847 | reg = 0; | |
848 | break; | |
849 | ||
850 | case save_a0_merge: | |
851 | case save_a0_no_merge: | |
852 | reg = gen_rtx_REG (SImode, FIRST_ADDRESS_REGNUM); | |
853 | emit_insn (gen_movsi (reg, stack_pointer_rtx)); | |
854 | if (xsize) | |
855 | emit_insn (gen_addsi3 (reg, reg, GEN_INT (xsize))); | |
856 | reg = gen_rtx_POST_INC (SImode, reg); | |
857 | break; | |
858 | ||
859 | default: | |
860 | abort (); | |
861 | } | |
862 | ||
863 | /* Now actually save the FP registers. */ | |
864 | for (i = FIRST_FP_REGNUM; i <= LAST_FP_REGNUM; ++i) | |
865 | if (regs_ever_live[i] && ! call_used_regs[i]) | |
866 | { | |
867 | rtx addr; | |
868 | ||
869 | if (reg) | |
870 | addr = reg; | |
871 | else | |
872 | { | |
873 | /* If we aren't using `a0', use an SP offset. */ | |
874 | if (xsize) | |
875 | { | |
876 | addr = gen_rtx_PLUS (SImode, | |
877 | stack_pointer_rtx, | |
878 | GEN_INT (xsize)); | |
879 | } | |
880 | else | |
881 | addr = stack_pointer_rtx; | |
882 | ||
883 | xsize += 4; | |
884 | } | |
885 | ||
886 | insn = emit_insn (gen_movsi (gen_rtx_MEM (SImode, addr), | |
887 | gen_rtx_REG (SImode, i))); | |
888 | ||
889 | RTX_FRAME_RELATED_P (insn) = 1; | |
890 | } | |
891 | } | |
892 | ||
777fbf09 | 893 | /* Now put the frame pointer into the frame pointer register. */ |
11bb1f11 | 894 | if (frame_pointer_needed) |
6e86170d | 895 | emit_move_insn (frame_pointer_rtx, stack_pointer_rtx); |
11bb1f11 | 896 | |
777fbf09 | 897 | /* Allocate stack for this frame. */ |
11bb1f11 JL |
898 | if (size) |
899 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
900 | stack_pointer_rtx, | |
901 | GEN_INT (-size))); | |
d1776069 AO |
902 | if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM]) |
903 | { | |
904 | rtx insn = get_last_insn (); | |
905 | rtx last = emit_insn (gen_GOTaddr2picreg ()); | |
906 | ||
907 | /* Mark these insns as possibly dead. Sometimes, flow2 may | |
908 | delete all uses of the PIC register. In this case, let it | |
909 | delete the initialization too. */ | |
910 | do | |
911 | { | |
912 | insn = NEXT_INSN (insn); | |
913 | ||
914 | REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD, | |
915 | const0_rtx, | |
916 | REG_NOTES (insn)); | |
917 | } | |
918 | while (insn != last); | |
919 | } | |
11bb1f11 JL |
920 | } |
921 | ||
922 | void | |
f1777882 | 923 | expand_epilogue (void) |
11bb1f11 | 924 | { |
036182e7 | 925 | HOST_WIDE_INT size; |
3dbc43d1 | 926 | |
3dbc43d1 | 927 | /* SIZE includes the fixed stack space needed for function calls. */ |
460f4b9d JL |
928 | size = get_frame_size () + current_function_outgoing_args_size; |
929 | size += (current_function_outgoing_args_size ? 4 : 0); | |
11bb1f11 | 930 | |
18e9d2f9 AO |
931 | if (TARGET_AM33_2 && fp_regs_to_save ()) |
932 | { | |
933 | int num_regs_to_save = fp_regs_to_save (), i; | |
934 | rtx reg = 0; | |
935 | ||
936 | /* We have several options to restore FP registers. We could | |
937 | load them from SP offsets, but, if there are enough FP | |
938 | registers to restore, we win if we use a post-increment | |
939 | addressing mode. */ | |
940 | ||
941 | /* If we have a frame pointer, it's the best option, because we | |
942 | already know it has the value we want. */ | |
943 | if (frame_pointer_needed) | |
944 | reg = gen_rtx_REG (SImode, FRAME_POINTER_REGNUM); | |
945 | /* Otherwise, we may use `a1', since it's call-clobbered and | |
946 | it's never used for return values. But only do so if it's | |
947 | smaller than using SP offsets. */ | |
948 | else | |
949 | { | |
950 | enum { restore_sp_post_adjust, | |
951 | restore_sp_pre_adjust, | |
952 | restore_sp_partial_adjust, | |
953 | restore_a1 } strategy; | |
954 | unsigned int this_strategy_size, strategy_size = (unsigned)-1; | |
955 | ||
956 | /* Consider using sp offsets before adjusting sp. */ | |
957 | /* Insn: fmov (##,sp),fs#, for each fs# to be restored. */ | |
958 | this_strategy_size = SIZE_FMOV_SP (size, num_regs_to_save); | |
959 | /* If size is too large, we'll have to adjust SP with an | |
960 | add. */ | |
961 | if (size + 4 * num_regs_to_save + REG_SAVE_BYTES > 255) | |
962 | { | |
963 | /* Insn: add size + 4 * num_regs_to_save, sp. */ | |
964 | this_strategy_size += SIZE_ADD_SP (size + 4 * num_regs_to_save); | |
965 | } | |
966 | /* If we don't have to restore any non-FP registers, | |
967 | we'll be able to save one byte by using rets. */ | |
968 | if (! REG_SAVE_BYTES) | |
969 | this_strategy_size--; | |
970 | ||
971 | if (this_strategy_size < strategy_size) | |
972 | { | |
973 | strategy = restore_sp_post_adjust; | |
974 | strategy_size = this_strategy_size; | |
975 | } | |
976 | ||
977 | /* Consider using sp offsets after adjusting sp. */ | |
978 | /* Insn: add size, sp. */ | |
979 | this_strategy_size = SIZE_ADD_SP (size); | |
980 | /* Insn: fmov (##,sp),fs#, for each fs# to be restored. */ | |
981 | this_strategy_size += SIZE_FMOV_SP (0, num_regs_to_save); | |
982 | /* We're going to use ret to release the FP registers | |
8596d0a1 | 983 | save area, so, no savings. */ |
18e9d2f9 AO |
984 | |
985 | if (this_strategy_size < strategy_size) | |
986 | { | |
987 | strategy = restore_sp_pre_adjust; | |
988 | strategy_size = this_strategy_size; | |
989 | } | |
990 | ||
991 | /* Consider using sp offsets after partially adjusting sp. | |
992 | When size is close to 32Kb, we may be able to adjust SP | |
993 | with an imm16 add instruction while still using fmov | |
994 | (d8,sp). */ | |
995 | if (size + 4 * num_regs_to_save + REG_SAVE_BYTES > 255) | |
996 | { | |
997 | /* Insn: add size + 4 * num_regs_to_save | |
998 | + REG_SAVE_BYTES - 252,sp. */ | |
999 | this_strategy_size = SIZE_ADD_SP (size + 4 * num_regs_to_save | |
1000 | + REG_SAVE_BYTES - 252); | |
1001 | /* Insn: fmov (##,sp),fs#, fo each fs# to be restored. */ | |
1002 | this_strategy_size += SIZE_FMOV_SP (252 - REG_SAVE_BYTES | |
1003 | - 4 * num_regs_to_save, | |
1004 | num_regs_to_save); | |
1005 | /* We're going to use ret to release the FP registers | |
8596d0a1 | 1006 | save area, so, no savings. */ |
18e9d2f9 AO |
1007 | |
1008 | if (this_strategy_size < strategy_size) | |
1009 | { | |
1010 | strategy = restore_sp_partial_adjust; | |
1011 | strategy_size = this_strategy_size; | |
1012 | } | |
1013 | } | |
1014 | ||
1015 | /* Consider using a1 in post-increment mode, as long as the | |
1016 | user hasn't changed the calling conventions of a1. */ | |
1017 | if (call_used_regs[FIRST_ADDRESS_REGNUM+1] | |
1018 | && ! fixed_regs[FIRST_ADDRESS_REGNUM+1]) | |
1019 | { | |
1020 | /* Insn: mov sp,a1. */ | |
1021 | this_strategy_size = 1; | |
1022 | if (size) | |
1023 | { | |
1024 | /* Insn: add size,a1. */ | |
1025 | this_strategy_size += SIZE_ADD_AX (size); | |
1026 | } | |
1027 | /* Insn: fmov (a1+),fs#, for each fs# to be restored. */ | |
1028 | this_strategy_size += 3 * num_regs_to_save; | |
1029 | /* If size is large enough, we may be able to save a | |
1030 | couple of bytes. */ | |
1031 | if (size + 4 * num_regs_to_save + REG_SAVE_BYTES > 255) | |
1032 | { | |
1033 | /* Insn: mov a1,sp. */ | |
1034 | this_strategy_size += 2; | |
1035 | } | |
1036 | /* If we don't have to restore any non-FP registers, | |
1037 | we'll be able to save one byte by using rets. */ | |
1038 | if (! REG_SAVE_BYTES) | |
1039 | this_strategy_size--; | |
1040 | ||
1041 | if (this_strategy_size < strategy_size) | |
1042 | { | |
1043 | strategy = restore_a1; | |
1044 | strategy_size = this_strategy_size; | |
1045 | } | |
1046 | } | |
1047 | ||
1048 | switch (strategy) | |
1049 | { | |
1050 | case restore_sp_post_adjust: | |
1051 | break; | |
1052 | ||
1053 | case restore_sp_pre_adjust: | |
1054 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
1055 | stack_pointer_rtx, | |
1056 | GEN_INT (size))); | |
1057 | size = 0; | |
1058 | break; | |
1059 | ||
1060 | case restore_sp_partial_adjust: | |
1061 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
1062 | stack_pointer_rtx, | |
1063 | GEN_INT (size + 4 * num_regs_to_save | |
1064 | + REG_SAVE_BYTES - 252))); | |
1065 | size = 252 - REG_SAVE_BYTES - 4 * num_regs_to_save; | |
1066 | break; | |
1067 | ||
1068 | case restore_a1: | |
1069 | reg = gen_rtx_REG (SImode, FIRST_ADDRESS_REGNUM + 1); | |
1070 | emit_insn (gen_movsi (reg, stack_pointer_rtx)); | |
1071 | if (size) | |
1072 | emit_insn (gen_addsi3 (reg, reg, GEN_INT (size))); | |
1073 | break; | |
1074 | ||
1075 | default: | |
1076 | abort (); | |
1077 | } | |
1078 | } | |
1079 | ||
1080 | /* Adjust the selected register, if any, for post-increment. */ | |
1081 | if (reg) | |
1082 | reg = gen_rtx_POST_INC (SImode, reg); | |
1083 | ||
1084 | for (i = FIRST_FP_REGNUM; i <= LAST_FP_REGNUM; ++i) | |
1085 | if (regs_ever_live[i] && ! call_used_regs[i]) | |
1086 | { | |
1087 | rtx addr; | |
1088 | ||
1089 | if (reg) | |
1090 | addr = reg; | |
1091 | else if (size) | |
1092 | { | |
1093 | /* If we aren't using a post-increment register, use an | |
8596d0a1 | 1094 | SP offset. */ |
18e9d2f9 AO |
1095 | addr = gen_rtx_PLUS (SImode, |
1096 | stack_pointer_rtx, | |
1097 | GEN_INT (size)); | |
1098 | } | |
1099 | else | |
1100 | addr = stack_pointer_rtx; | |
1101 | ||
1102 | size += 4; | |
1103 | ||
1104 | emit_insn (gen_movsi (gen_rtx_REG (SImode, i), | |
1105 | gen_rtx_MEM (SImode, addr))); | |
1106 | } | |
1107 | ||
1108 | /* If we were using the restore_a1 strategy and the number of | |
1109 | bytes to be released won't fit in the `ret' byte, copy `a1' | |
1110 | to `sp', to avoid having to use `add' to adjust it. */ | |
1111 | if (! frame_pointer_needed && reg && size + REG_SAVE_BYTES > 255) | |
1112 | { | |
1113 | emit_move_insn (stack_pointer_rtx, XEXP (reg, 0)); | |
1114 | size = 0; | |
1115 | } | |
1116 | } | |
1117 | ||
5d29a95f JL |
1118 | /* Maybe cut back the stack, except for the register save area. |
1119 | ||
1120 | If the frame pointer exists, then use the frame pointer to | |
1121 | cut back the stack. | |
1122 | ||
1123 | If the stack size + register save area is more than 255 bytes, | |
1124 | then the stack must be cut back here since the size + register | |
1125 | save size is too big for a ret/retf instruction. | |
1126 | ||
1127 | Else leave it alone, it will be cut back as part of the | |
1128 | ret/retf instruction, or there wasn't any stack to begin with. | |
1129 | ||
dab66575 | 1130 | Under no circumstances should the register save area be |
5d29a95f JL |
1131 | deallocated here, that would leave a window where an interrupt |
1132 | could occur and trash the register save area. */ | |
11bb1f11 JL |
1133 | if (frame_pointer_needed) |
1134 | { | |
11bb1f11 | 1135 | emit_move_insn (stack_pointer_rtx, frame_pointer_rtx); |
4246e0c5 JL |
1136 | size = 0; |
1137 | } | |
ed6089d6 | 1138 | else if (size + REG_SAVE_BYTES > 255) |
4246e0c5 JL |
1139 | { |
1140 | emit_insn (gen_addsi3 (stack_pointer_rtx, | |
1141 | stack_pointer_rtx, | |
1142 | GEN_INT (size))); | |
1143 | size = 0; | |
11bb1f11 | 1144 | } |
11bb1f11 | 1145 | |
ed6089d6 AO |
1146 | /* Adjust the stack and restore callee-saved registers, if any. */ |
1147 | if (size || regs_ever_live[2] || regs_ever_live[3] | |
777fbf09 | 1148 | || regs_ever_live[6] || regs_ever_live[7] |
705ac34f JL |
1149 | || regs_ever_live[14] || regs_ever_live[15] |
1150 | || regs_ever_live[16] || regs_ever_live[17] | |
777fbf09 | 1151 | || frame_pointer_needed) |
ed6089d6 AO |
1152 | emit_jump_insn (gen_return_internal_regs |
1153 | (GEN_INT (size + REG_SAVE_BYTES))); | |
777fbf09 | 1154 | else |
ed6089d6 | 1155 | emit_jump_insn (gen_return_internal ()); |
11bb1f11 JL |
1156 | } |
1157 | ||
1158 | /* Update the condition code from the insn. */ | |
1159 | ||
1160 | void | |
f1777882 | 1161 | notice_update_cc (rtx body, rtx insn) |
11bb1f11 | 1162 | { |
11bb1f11 JL |
1163 | switch (get_attr_cc (insn)) |
1164 | { | |
1165 | case CC_NONE: | |
1166 | /* Insn does not affect CC at all. */ | |
1167 | break; | |
1168 | ||
1169 | case CC_NONE_0HIT: | |
1170 | /* Insn does not change CC, but the 0'th operand has been changed. */ | |
1171 | if (cc_status.value1 != 0 | |
1ccbefce | 1172 | && reg_overlap_mentioned_p (recog_data.operand[0], cc_status.value1)) |
11bb1f11 JL |
1173 | cc_status.value1 = 0; |
1174 | break; | |
1175 | ||
d116300b | 1176 | case CC_SET_ZN: |
1ccbefce | 1177 | /* Insn sets the Z,N flags of CC to recog_data.operand[0]. |
d116300b | 1178 | V,C are unusable. */ |
11bb1f11 | 1179 | CC_STATUS_INIT; |
d116300b | 1180 | cc_status.flags |= CC_NO_CARRY | CC_OVERFLOW_UNUSABLE; |
1ccbefce | 1181 | cc_status.value1 = recog_data.operand[0]; |
11bb1f11 JL |
1182 | break; |
1183 | ||
d116300b | 1184 | case CC_SET_ZNV: |
1ccbefce | 1185 | /* Insn sets the Z,N,V flags of CC to recog_data.operand[0]. |
d116300b | 1186 | C is unusable. */ |
82c6faa8 | 1187 | CC_STATUS_INIT; |
d116300b | 1188 | cc_status.flags |= CC_NO_CARRY; |
1ccbefce | 1189 | cc_status.value1 = recog_data.operand[0]; |
82c6faa8 JL |
1190 | break; |
1191 | ||
11bb1f11 JL |
1192 | case CC_COMPARE: |
1193 | /* The insn is a compare instruction. */ | |
1194 | CC_STATUS_INIT; | |
1195 | cc_status.value1 = SET_SRC (body); | |
18e9d2f9 AO |
1196 | if (GET_CODE (cc_status.value1) == COMPARE |
1197 | && GET_MODE (XEXP (cc_status.value1, 0)) == SFmode) | |
1198 | cc_status.mdep.fpCC = 1; | |
11bb1f11 JL |
1199 | break; |
1200 | ||
1201 | case CC_CLOBBER: | |
1202 | /* Insn doesn't leave CC in a usable state. */ | |
1203 | CC_STATUS_INIT; | |
1204 | break; | |
82c6faa8 JL |
1205 | |
1206 | default: | |
1207 | abort (); | |
11bb1f11 | 1208 | } |
11bb1f11 JL |
1209 | } |
1210 | ||
05713b80 | 1211 | /* Recognize the PARALLEL rtx generated by mn10300_gen_multiple_store(). |
f6cd7c62 RS |
1212 | This function is for MATCH_PARALLEL and so assumes OP is known to be |
1213 | parallel. If OP is a multiple store, return a mask indicating which | |
1214 | registers it saves. Return 0 otherwise. */ | |
1215 | ||
1216 | int | |
f1777882 | 1217 | store_multiple_operation (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
f6cd7c62 RS |
1218 | { |
1219 | int count; | |
1220 | int mask; | |
1221 | int i; | |
1222 | unsigned int last; | |
1223 | rtx elt; | |
1224 | ||
1225 | count = XVECLEN (op, 0); | |
1226 | if (count < 2) | |
1227 | return 0; | |
1228 | ||
1229 | /* Check that first instruction has the form (set (sp) (plus A B)) */ | |
1230 | elt = XVECEXP (op, 0, 0); | |
1231 | if (GET_CODE (elt) != SET | |
1232 | || GET_CODE (SET_DEST (elt)) != REG | |
1233 | || REGNO (SET_DEST (elt)) != STACK_POINTER_REGNUM | |
1234 | || GET_CODE (SET_SRC (elt)) != PLUS) | |
1235 | return 0; | |
1236 | ||
1237 | /* Check that A is the stack pointer and B is the expected stack size. | |
1238 | For OP to match, each subsequent instruction should push a word onto | |
1239 | the stack. We therefore expect the first instruction to create | |
8596d0a1 | 1240 | COUNT-1 stack slots. */ |
f6cd7c62 RS |
1241 | elt = SET_SRC (elt); |
1242 | if (GET_CODE (XEXP (elt, 0)) != REG | |
1243 | || REGNO (XEXP (elt, 0)) != STACK_POINTER_REGNUM | |
1244 | || GET_CODE (XEXP (elt, 1)) != CONST_INT | |
1245 | || INTVAL (XEXP (elt, 1)) != -(count - 1) * 4) | |
1246 | return 0; | |
1247 | ||
1248 | /* Now go through the rest of the vector elements. They must be | |
1249 | ordered so that the first instruction stores the highest-numbered | |
1250 | register to the highest stack slot and that subsequent instructions | |
1251 | store a lower-numbered register to the slot below. | |
1252 | ||
1253 | LAST keeps track of the smallest-numbered register stored so far. | |
8596d0a1 | 1254 | MASK is the set of stored registers. */ |
18e9d2f9 | 1255 | last = LAST_EXTENDED_REGNUM + 1; |
f6cd7c62 RS |
1256 | mask = 0; |
1257 | for (i = 1; i < count; i++) | |
1258 | { | |
8596d0a1 | 1259 | /* Check that element i is a (set (mem M) R) and that R is valid. */ |
f6cd7c62 RS |
1260 | elt = XVECEXP (op, 0, i); |
1261 | if (GET_CODE (elt) != SET | |
1262 | || GET_CODE (SET_DEST (elt)) != MEM | |
1263 | || GET_CODE (SET_SRC (elt)) != REG | |
1264 | || REGNO (SET_SRC (elt)) >= last) | |
1265 | return 0; | |
1266 | ||
1267 | /* R was OK, so provisionally add it to MASK. We return 0 in any | |
8596d0a1 | 1268 | case if the rest of the instruction has a flaw. */ |
f6cd7c62 RS |
1269 | last = REGNO (SET_SRC (elt)); |
1270 | mask |= (1 << last); | |
1271 | ||
1272 | /* Check that M has the form (plus (sp) (const_int -I*4)) */ | |
1273 | elt = XEXP (SET_DEST (elt), 0); | |
1274 | if (GET_CODE (elt) != PLUS | |
1275 | || GET_CODE (XEXP (elt, 0)) != REG | |
1276 | || REGNO (XEXP (elt, 0)) != STACK_POINTER_REGNUM | |
1277 | || GET_CODE (XEXP (elt, 1)) != CONST_INT | |
1278 | || INTVAL (XEXP (elt, 1)) != -i * 4) | |
1279 | return 0; | |
1280 | } | |
1281 | ||
8596d0a1 | 1282 | /* All or none of the callee-saved extended registers must be in the set. */ |
f6cd7c62 RS |
1283 | if ((mask & 0x3c000) != 0 |
1284 | && (mask & 0x3c000) != 0x3c000) | |
1285 | return 0; | |
1286 | ||
1287 | return mask; | |
1288 | } | |
1289 | ||
11bb1f11 JL |
1290 | /* Return true if OP is a valid call operand. */ |
1291 | ||
1292 | int | |
f1777882 | 1293 | call_address_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
11bb1f11 | 1294 | { |
d1776069 AO |
1295 | if (flag_pic) |
1296 | return (EXTRA_CONSTRAINT (op, 'S') || GET_CODE (op) == REG); | |
1297 | ||
11bb1f11 JL |
1298 | return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == REG); |
1299 | } | |
1300 | ||
1301 | /* What (if any) secondary registers are needed to move IN with mode | |
8493cfcb | 1302 | MODE into a register in register class CLASS. |
11bb1f11 JL |
1303 | |
1304 | We might be able to simplify this. */ | |
1305 | enum reg_class | |
f1777882 | 1306 | secondary_reload_class (enum reg_class class, enum machine_mode mode, rtx in) |
11bb1f11 | 1307 | { |
11bb1f11 JL |
1308 | /* Memory loads less than a full word wide can't have an |
1309 | address or stack pointer destination. They must use | |
1310 | a data register as an intermediate register. */ | |
15c09738 AH |
1311 | if ((GET_CODE (in) == MEM |
1312 | || (GET_CODE (in) == REG | |
1313 | && REGNO (in) >= FIRST_PSEUDO_REGISTER) | |
1314 | || (GET_CODE (in) == SUBREG | |
1315 | && GET_CODE (SUBREG_REG (in)) == REG | |
1316 | && REGNO (SUBREG_REG (in)) >= FIRST_PSEUDO_REGISTER)) | |
11bb1f11 | 1317 | && (mode == QImode || mode == HImode) |
15c09738 | 1318 | && (class == ADDRESS_REGS || class == SP_REGS |
842a0788 | 1319 | || class == SP_OR_ADDRESS_REGS)) |
4d1a91c2 | 1320 | { |
705ac34f JL |
1321 | if (TARGET_AM33) |
1322 | return DATA_OR_EXTENDED_REGS; | |
4d1a91c2 JL |
1323 | return DATA_REGS; |
1324 | } | |
11bb1f11 JL |
1325 | |
1326 | /* We can't directly load sp + const_int into a data register; | |
1327 | we must use an address register as an intermediate. */ | |
777fbf09 JL |
1328 | if (class != SP_REGS |
1329 | && class != ADDRESS_REGS | |
1330 | && class != SP_OR_ADDRESS_REGS | |
705ac34f JL |
1331 | && class != SP_OR_EXTENDED_REGS |
1332 | && class != ADDRESS_OR_EXTENDED_REGS | |
1333 | && class != SP_OR_ADDRESS_OR_EXTENDED_REGS | |
11bb1f11 JL |
1334 | && (in == stack_pointer_rtx |
1335 | || (GET_CODE (in) == PLUS | |
777fbf09 JL |
1336 | && (XEXP (in, 0) == stack_pointer_rtx |
1337 | || XEXP (in, 1) == stack_pointer_rtx)))) | |
11bb1f11 JL |
1338 | return ADDRESS_REGS; |
1339 | ||
4c742813 JL |
1340 | if (GET_CODE (in) == PLUS |
1341 | && (XEXP (in, 0) == stack_pointer_rtx | |
1342 | || XEXP (in, 1) == stack_pointer_rtx)) | |
4d1a91c2 | 1343 | { |
705ac34f JL |
1344 | if (TARGET_AM33) |
1345 | return DATA_OR_EXTENDED_REGS; | |
4d1a91c2 JL |
1346 | return DATA_REGS; |
1347 | } | |
4c742813 | 1348 | |
18e9d2f9 AO |
1349 | if (TARGET_AM33_2 && class == FP_REGS |
1350 | && GET_CODE (in) == MEM && ! OK_FOR_Q (in)) | |
1351 | { | |
1352 | if (TARGET_AM33) | |
1353 | return DATA_OR_EXTENDED_REGS; | |
1354 | return DATA_REGS; | |
1355 | } | |
1356 | ||
777fbf09 JL |
1357 | /* Otherwise assume no secondary reloads are needed. */ |
1358 | return NO_REGS; | |
1359 | } | |
1360 | ||
1361 | int | |
f1777882 | 1362 | initial_offset (int from, int to) |
777fbf09 | 1363 | { |
3dbc43d1 JL |
1364 | /* The difference between the argument pointer and the frame pointer |
1365 | is the size of the callee register save area. */ | |
777fbf09 | 1366 | if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM) |
11bb1f11 | 1367 | { |
777fbf09 JL |
1368 | if (regs_ever_live[2] || regs_ever_live[3] |
1369 | || regs_ever_live[6] || regs_ever_live[7] | |
705ac34f JL |
1370 | || regs_ever_live[14] || regs_ever_live[15] |
1371 | || regs_ever_live[16] || regs_ever_live[17] | |
18e9d2f9 | 1372 | || fp_regs_to_save () |
777fbf09 | 1373 | || frame_pointer_needed) |
18e9d2f9 AO |
1374 | return REG_SAVE_BYTES |
1375 | + 4 * fp_regs_to_save (); | |
777fbf09 | 1376 | else |
22ef4e9b | 1377 | return 0; |
11bb1f11 JL |
1378 | } |
1379 | ||
3dbc43d1 JL |
1380 | /* The difference between the argument pointer and the stack pointer is |
1381 | the sum of the size of this function's frame, the callee register save | |
1382 | area, and the fixed stack space needed for function calls (if any). */ | |
777fbf09 JL |
1383 | if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM) |
1384 | { | |
1385 | if (regs_ever_live[2] || regs_ever_live[3] | |
1386 | || regs_ever_live[6] || regs_ever_live[7] | |
705ac34f JL |
1387 | || regs_ever_live[14] || regs_ever_live[15] |
1388 | || regs_ever_live[16] || regs_ever_live[17] | |
18e9d2f9 | 1389 | || fp_regs_to_save () |
777fbf09 | 1390 | || frame_pointer_needed) |
4d1a91c2 | 1391 | return (get_frame_size () + REG_SAVE_BYTES |
18e9d2f9 | 1392 | + 4 * fp_regs_to_save () |
460f4b9d JL |
1393 | + (current_function_outgoing_args_size |
1394 | ? current_function_outgoing_args_size + 4 : 0)); | |
777fbf09 | 1395 | else |
460f4b9d JL |
1396 | return (get_frame_size () |
1397 | + (current_function_outgoing_args_size | |
1398 | ? current_function_outgoing_args_size + 4 : 0)); | |
777fbf09 | 1399 | } |
11bb1f11 | 1400 | |
3dbc43d1 JL |
1401 | /* The difference between the frame pointer and stack pointer is the sum |
1402 | of the size of this function's frame and the fixed stack space needed | |
1403 | for function calls (if any). */ | |
777fbf09 | 1404 | if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM) |
460f4b9d JL |
1405 | return (get_frame_size () |
1406 | + (current_function_outgoing_args_size | |
1407 | ? current_function_outgoing_args_size + 4 : 0)); | |
777fbf09 JL |
1408 | |
1409 | abort (); | |
11bb1f11 | 1410 | } |
22ef4e9b | 1411 | |
bd5bd7ac KH |
1412 | /* Worker function for TARGET_RETURN_IN_MEMORY. */ |
1413 | ||
9024ea92 KH |
1414 | static bool |
1415 | mn10300_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED) | |
1416 | { | |
1417 | /* Return values > 8 bytes in length in memory. */ | |
1418 | return int_size_in_bytes (type) > 8 || TYPE_MODE (type) == BLKmode; | |
1419 | } | |
1420 | ||
22ef4e9b JL |
1421 | /* Flush the argument registers to the stack for a stdarg function; |
1422 | return the new argument pointer. */ | |
9024ea92 | 1423 | static rtx |
f1777882 | 1424 | mn10300_builtin_saveregs (void) |
22ef4e9b | 1425 | { |
fc2acc87 | 1426 | rtx offset, mem; |
22ef4e9b JL |
1427 | tree fntype = TREE_TYPE (current_function_decl); |
1428 | int argadj = ((!(TYPE_ARG_TYPES (fntype) != 0 | |
1429 | && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype))) | |
1430 | != void_type_node))) | |
1431 | ? UNITS_PER_WORD : 0); | |
fc2acc87 | 1432 | int set = get_varargs_alias_set (); |
22ef4e9b JL |
1433 | |
1434 | if (argadj) | |
1435 | offset = plus_constant (current_function_arg_offset_rtx, argadj); | |
1436 | else | |
1437 | offset = current_function_arg_offset_rtx; | |
1438 | ||
fc2acc87 | 1439 | mem = gen_rtx_MEM (SImode, current_function_internal_arg_pointer); |
ba4828e0 | 1440 | set_mem_alias_set (mem, set); |
fc2acc87 RH |
1441 | emit_move_insn (mem, gen_rtx_REG (SImode, 0)); |
1442 | ||
1443 | mem = gen_rtx_MEM (SImode, | |
1444 | plus_constant (current_function_internal_arg_pointer, 4)); | |
ba4828e0 | 1445 | set_mem_alias_set (mem, set); |
fc2acc87 RH |
1446 | emit_move_insn (mem, gen_rtx_REG (SImode, 1)); |
1447 | ||
22ef4e9b JL |
1448 | return copy_to_reg (expand_binop (Pmode, add_optab, |
1449 | current_function_internal_arg_pointer, | |
1450 | offset, 0, 0, OPTAB_LIB_WIDEN)); | |
1451 | } | |
1452 | ||
fc2acc87 | 1453 | void |
f1777882 | 1454 | mn10300_va_start (tree valist, rtx nextarg) |
fc2acc87 | 1455 | { |
6c535c69 | 1456 | nextarg = expand_builtin_saveregs (); |
e5faf155 | 1457 | std_expand_builtin_va_start (valist, nextarg); |
fc2acc87 RH |
1458 | } |
1459 | ||
1460 | rtx | |
f1777882 | 1461 | mn10300_va_arg (tree valist, tree type) |
fc2acc87 RH |
1462 | { |
1463 | HOST_WIDE_INT align, rsize; | |
1464 | tree t, ptr, pptr; | |
1465 | ||
1466 | /* Compute the rounded size of the type. */ | |
1467 | align = PARM_BOUNDARY / BITS_PER_UNIT; | |
1468 | rsize = (((int_size_in_bytes (type) + align - 1) / align) * align); | |
1469 | ||
1470 | t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist, | |
1471 | build_int_2 ((rsize > 8 ? 4 : rsize), 0)); | |
1472 | TREE_SIDE_EFFECTS (t) = 1; | |
1473 | ||
1474 | ptr = build_pointer_type (type); | |
1475 | ||
1476 | /* "Large" types are passed by reference. */ | |
1477 | if (rsize > 8) | |
1478 | { | |
1479 | pptr = build_pointer_type (ptr); | |
1480 | t = build1 (NOP_EXPR, pptr, t); | |
1481 | TREE_SIDE_EFFECTS (t) = 1; | |
1482 | ||
1483 | t = build1 (INDIRECT_REF, ptr, t); | |
1484 | TREE_SIDE_EFFECTS (t) = 1; | |
1485 | } | |
1486 | else | |
1487 | { | |
1488 | t = build1 (NOP_EXPR, ptr, t); | |
1489 | TREE_SIDE_EFFECTS (t) = 1; | |
1490 | } | |
1491 | ||
1492 | /* Calculate! */ | |
1493 | return expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL); | |
1494 | } | |
1495 | ||
22ef4e9b JL |
1496 | /* Return an RTX to represent where a value with mode MODE will be returned |
1497 | from a function. If the result is 0, the argument is pushed. */ | |
1498 | ||
1499 | rtx | |
f1777882 KH |
1500 | function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, |
1501 | tree type, int named ATTRIBUTE_UNUSED) | |
22ef4e9b JL |
1502 | { |
1503 | rtx result = 0; | |
1504 | int size, align; | |
1505 | ||
1506 | /* We only support using 2 data registers as argument registers. */ | |
1507 | int nregs = 2; | |
1508 | ||
1509 | /* Figure out the size of the object to be passed. */ | |
1510 | if (mode == BLKmode) | |
1511 | size = int_size_in_bytes (type); | |
1512 | else | |
1513 | size = GET_MODE_SIZE (mode); | |
1514 | ||
1515 | /* Figure out the alignment of the object to be passed. */ | |
1516 | align = size; | |
1517 | ||
1518 | cum->nbytes = (cum->nbytes + 3) & ~3; | |
1519 | ||
1520 | /* Don't pass this arg via a register if all the argument registers | |
1521 | are used up. */ | |
1522 | if (cum->nbytes > nregs * UNITS_PER_WORD) | |
1523 | return 0; | |
1524 | ||
1525 | /* Don't pass this arg via a register if it would be split between | |
1526 | registers and memory. */ | |
1527 | if (type == NULL_TREE | |
1528 | && cum->nbytes + size > nregs * UNITS_PER_WORD) | |
1529 | return 0; | |
1530 | ||
1531 | switch (cum->nbytes / UNITS_PER_WORD) | |
1532 | { | |
1533 | case 0: | |
c5c76735 | 1534 | result = gen_rtx_REG (mode, 0); |
22ef4e9b JL |
1535 | break; |
1536 | case 1: | |
c5c76735 | 1537 | result = gen_rtx_REG (mode, 1); |
22ef4e9b JL |
1538 | break; |
1539 | default: | |
1540 | result = 0; | |
1541 | } | |
1542 | ||
1543 | return result; | |
1544 | } | |
1545 | ||
1546 | /* Return the number of registers to use for an argument passed partially | |
1547 | in registers and partially in memory. */ | |
1548 | ||
1549 | int | |
f1777882 KH |
1550 | function_arg_partial_nregs (CUMULATIVE_ARGS *cum, enum machine_mode mode, |
1551 | tree type, int named ATTRIBUTE_UNUSED) | |
22ef4e9b JL |
1552 | { |
1553 | int size, align; | |
1554 | ||
1555 | /* We only support using 2 data registers as argument registers. */ | |
1556 | int nregs = 2; | |
1557 | ||
1558 | /* Figure out the size of the object to be passed. */ | |
1559 | if (mode == BLKmode) | |
1560 | size = int_size_in_bytes (type); | |
1561 | else | |
1562 | size = GET_MODE_SIZE (mode); | |
1563 | ||
1564 | /* Figure out the alignment of the object to be passed. */ | |
1565 | align = size; | |
1566 | ||
1567 | cum->nbytes = (cum->nbytes + 3) & ~3; | |
1568 | ||
1569 | /* Don't pass this arg via a register if all the argument registers | |
1570 | are used up. */ | |
1571 | if (cum->nbytes > nregs * UNITS_PER_WORD) | |
1572 | return 0; | |
1573 | ||
1574 | if (cum->nbytes + size <= nregs * UNITS_PER_WORD) | |
1575 | return 0; | |
1576 | ||
1577 | /* Don't pass this arg via a register if it would be split between | |
1578 | registers and memory. */ | |
1579 | if (type == NULL_TREE | |
1580 | && cum->nbytes + size > nregs * UNITS_PER_WORD) | |
1581 | return 0; | |
1582 | ||
1583 | return (nregs * UNITS_PER_WORD - cum->nbytes) / UNITS_PER_WORD; | |
1584 | } | |
1585 | ||
1586 | /* Output a tst insn. */ | |
1943c2c1 | 1587 | const char * |
f1777882 | 1588 | output_tst (rtx operand, rtx insn) |
22ef4e9b | 1589 | { |
22ef4e9b JL |
1590 | rtx temp; |
1591 | int past_call = 0; | |
1592 | ||
1593 | /* We can save a byte if we can find a register which has the value | |
1594 | zero in it. */ | |
1595 | temp = PREV_INSN (insn); | |
74452ac3 | 1596 | while (optimize && temp) |
22ef4e9b JL |
1597 | { |
1598 | rtx set; | |
1599 | ||
1600 | /* We allow the search to go through call insns. We record | |
1601 | the fact that we've past a CALL_INSN and reject matches which | |
1602 | use call clobbered registers. */ | |
1603 | if (GET_CODE (temp) == CODE_LABEL | |
1604 | || GET_CODE (temp) == JUMP_INSN | |
1605 | || GET_CODE (temp) == BARRIER) | |
1606 | break; | |
1607 | ||
1608 | if (GET_CODE (temp) == CALL_INSN) | |
1609 | past_call = 1; | |
1610 | ||
1611 | if (GET_CODE (temp) == NOTE) | |
1612 | { | |
1613 | temp = PREV_INSN (temp); | |
1614 | continue; | |
1615 | } | |
1616 | ||
8596d0a1 | 1617 | /* It must be an insn, see if it is a simple set. */ |
22ef4e9b JL |
1618 | set = single_set (temp); |
1619 | if (!set) | |
1620 | { | |
1621 | temp = PREV_INSN (temp); | |
1622 | continue; | |
1623 | } | |
1624 | ||
1625 | /* Are we setting a data register to zero (this does not win for | |
1626 | address registers)? | |
1627 | ||
1628 | If it's a call clobbered register, have we past a call? | |
1629 | ||
1630 | Make sure the register we find isn't the same as ourself; | |
4d1a91c2 JL |
1631 | the mn10300 can't encode that. |
1632 | ||
1633 | ??? reg_set_between_p return nonzero anytime we pass a CALL_INSN | |
1634 | so the code to detect calls here isn't doing anything useful. */ | |
22ef4e9b JL |
1635 | if (REG_P (SET_DEST (set)) |
1636 | && SET_SRC (set) == CONST0_RTX (GET_MODE (SET_DEST (set))) | |
1637 | && !reg_set_between_p (SET_DEST (set), temp, insn) | |
74452ac3 JL |
1638 | && (REGNO_REG_CLASS (REGNO (SET_DEST (set))) |
1639 | == REGNO_REG_CLASS (REGNO (operand))) | |
705ac34f JL |
1640 | && REGNO_REG_CLASS (REGNO (SET_DEST (set))) != EXTENDED_REGS |
1641 | && REGNO (SET_DEST (set)) != REGNO (operand) | |
1642 | && (!past_call | |
1643 | || !call_used_regs[REGNO (SET_DEST (set))])) | |
1644 | { | |
1645 | rtx xoperands[2]; | |
1646 | xoperands[0] = operand; | |
1647 | xoperands[1] = SET_DEST (set); | |
1648 | ||
1649 | output_asm_insn ("cmp %1,%0", xoperands); | |
1650 | return ""; | |
1651 | } | |
1652 | ||
1653 | if (REGNO_REG_CLASS (REGNO (operand)) == EXTENDED_REGS | |
1654 | && REG_P (SET_DEST (set)) | |
1655 | && SET_SRC (set) == CONST0_RTX (GET_MODE (SET_DEST (set))) | |
1656 | && !reg_set_between_p (SET_DEST (set), temp, insn) | |
1657 | && (REGNO_REG_CLASS (REGNO (SET_DEST (set))) | |
1658 | != REGNO_REG_CLASS (REGNO (operand))) | |
1659 | && REGNO_REG_CLASS (REGNO (SET_DEST (set))) == EXTENDED_REGS | |
22ef4e9b JL |
1660 | && REGNO (SET_DEST (set)) != REGNO (operand) |
1661 | && (!past_call | |
1662 | || !call_used_regs[REGNO (SET_DEST (set))])) | |
1663 | { | |
1664 | rtx xoperands[2]; | |
1665 | xoperands[0] = operand; | |
1666 | xoperands[1] = SET_DEST (set); | |
1667 | ||
1668 | output_asm_insn ("cmp %1,%0", xoperands); | |
1669 | return ""; | |
1670 | } | |
1671 | temp = PREV_INSN (temp); | |
1672 | } | |
1673 | return "cmp 0,%0"; | |
1674 | } | |
460f4b9d JL |
1675 | |
1676 | int | |
f1777882 | 1677 | impossible_plus_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
460f4b9d | 1678 | { |
460f4b9d JL |
1679 | if (GET_CODE (op) != PLUS) |
1680 | return 0; | |
1681 | ||
4c742813 JL |
1682 | if (XEXP (op, 0) == stack_pointer_rtx |
1683 | || XEXP (op, 1) == stack_pointer_rtx) | |
460f4b9d JL |
1684 | return 1; |
1685 | ||
460f4b9d JL |
1686 | return 0; |
1687 | } | |
e9ad4573 | 1688 | |
f8912297 JL |
1689 | /* Return 1 if X is a CONST_INT that is only 8 bits wide. This is used |
1690 | for the btst insn which may examine memory or a register (the memory | |
1691 | variant only allows an unsigned 8 bit integer). */ | |
1692 | int | |
f1777882 | 1693 | const_8bit_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
f8912297 JL |
1694 | { |
1695 | return (GET_CODE (op) == CONST_INT | |
1696 | && INTVAL (op) >= 0 | |
1697 | && INTVAL (op) < 256); | |
1698 | } | |
1699 | ||
18e9d2f9 AO |
1700 | /* Return true if the operand is the 1.0f constant. */ |
1701 | int | |
f1777882 | 1702 | const_1f_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
18e9d2f9 AO |
1703 | { |
1704 | return (op == CONST1_RTX (SFmode)); | |
1705 | } | |
1706 | ||
f8912297 JL |
1707 | /* Similarly, but when using a zero_extract pattern for a btst where |
1708 | the source operand might end up in memory. */ | |
1709 | int | |
f1777882 | 1710 | mask_ok_for_mem_btst (int len, int bit) |
f8912297 | 1711 | { |
4977bab6 | 1712 | unsigned int mask = 0; |
f8912297 JL |
1713 | |
1714 | while (len > 0) | |
1715 | { | |
1716 | mask |= (1 << bit); | |
1717 | bit++; | |
1718 | len--; | |
1719 | } | |
1720 | ||
1721 | /* MASK must bit into an 8bit value. */ | |
1722 | return (((mask & 0xff) == mask) | |
1723 | || ((mask & 0xff00) == mask) | |
1724 | || ((mask & 0xff0000) == mask) | |
1725 | || ((mask & 0xff000000) == mask)); | |
1726 | } | |
1727 | ||
e9ad4573 JL |
1728 | /* Return 1 if X contains a symbolic expression. We know these |
1729 | expressions will have one of a few well defined forms, so | |
1730 | we need only check those forms. */ | |
1731 | int | |
f1777882 | 1732 | symbolic_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) |
e9ad4573 JL |
1733 | { |
1734 | switch (GET_CODE (op)) | |
1735 | { | |
1736 | case SYMBOL_REF: | |
1737 | case LABEL_REF: | |
1738 | return 1; | |
1739 | case CONST: | |
1740 | op = XEXP (op, 0); | |
1741 | return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF | |
1742 | || GET_CODE (XEXP (op, 0)) == LABEL_REF) | |
1743 | && GET_CODE (XEXP (op, 1)) == CONST_INT); | |
1744 | default: | |
1745 | return 0; | |
1746 | } | |
1747 | } | |
1748 | ||
1749 | /* Try machine dependent ways of modifying an illegitimate address | |
1750 | to be legitimate. If we find one, return the new valid address. | |
1751 | This macro is used in only one place: `memory_address' in explow.c. | |
1752 | ||
1753 | OLDX is the address as it was before break_out_memory_refs was called. | |
1754 | In some cases it is useful to look at this to decide what needs to be done. | |
1755 | ||
1756 | MODE and WIN are passed so that this macro can use | |
1757 | GO_IF_LEGITIMATE_ADDRESS. | |
1758 | ||
1759 | Normally it is always safe for this macro to do nothing. It exists to | |
1760 | recognize opportunities to optimize the output. | |
1761 | ||
1762 | But on a few ports with segmented architectures and indexed addressing | |
1763 | (mn10300, hppa) it is used to rewrite certain problematical addresses. */ | |
1764 | rtx | |
f1777882 KH |
1765 | legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, |
1766 | enum machine_mode mode ATTRIBUTE_UNUSED) | |
e9ad4573 | 1767 | { |
d1776069 AO |
1768 | if (flag_pic && ! legitimate_pic_operand_p (x)) |
1769 | x = legitimize_pic_address (oldx, NULL_RTX); | |
1770 | ||
e9ad4573 JL |
1771 | /* Uh-oh. We might have an address for x[n-100000]. This needs |
1772 | special handling to avoid creating an indexed memory address | |
1773 | with x-100000 as the base. */ | |
1774 | if (GET_CODE (x) == PLUS | |
1775 | && symbolic_operand (XEXP (x, 1), VOIDmode)) | |
1776 | { | |
1777 | /* Ugly. We modify things here so that the address offset specified | |
1778 | by the index expression is computed first, then added to x to form | |
1779 | the entire address. */ | |
1780 | ||
69bc71fa | 1781 | rtx regx1, regy1, regy2, y; |
e9ad4573 JL |
1782 | |
1783 | /* Strip off any CONST. */ | |
1784 | y = XEXP (x, 1); | |
1785 | if (GET_CODE (y) == CONST) | |
1786 | y = XEXP (y, 0); | |
1787 | ||
bf4219f0 JL |
1788 | if (GET_CODE (y) == PLUS || GET_CODE (y) == MINUS) |
1789 | { | |
1790 | regx1 = force_reg (Pmode, force_operand (XEXP (x, 0), 0)); | |
1791 | regy1 = force_reg (Pmode, force_operand (XEXP (y, 0), 0)); | |
1792 | regy2 = force_reg (Pmode, force_operand (XEXP (y, 1), 0)); | |
1793 | regx1 = force_reg (Pmode, | |
1c563bed | 1794 | gen_rtx_fmt_ee (GET_CODE (y), Pmode, regx1, regy2)); |
c5c76735 | 1795 | return force_reg (Pmode, gen_rtx_PLUS (Pmode, regx1, regy1)); |
bf4219f0 | 1796 | } |
e9ad4573 | 1797 | } |
371036e0 | 1798 | return x; |
e9ad4573 | 1799 | } |
460ad325 | 1800 | |
d1776069 | 1801 | /* Convert a non-PIC address in `orig' to a PIC address using @GOT or |
8596d0a1 | 1802 | @GOTOFF in `reg'. */ |
d1776069 | 1803 | rtx |
f1777882 | 1804 | legitimize_pic_address (rtx orig, rtx reg) |
d1776069 AO |
1805 | { |
1806 | if (GET_CODE (orig) == LABEL_REF | |
1807 | || (GET_CODE (orig) == SYMBOL_REF | |
1808 | && (CONSTANT_POOL_ADDRESS_P (orig) | |
1809 | || ! MN10300_GLOBAL_P (orig)))) | |
1810 | { | |
1811 | if (reg == 0) | |
1812 | reg = gen_reg_rtx (Pmode); | |
1813 | ||
1814 | emit_insn (gen_symGOTOFF2reg (reg, orig)); | |
1815 | return reg; | |
1816 | } | |
1817 | else if (GET_CODE (orig) == SYMBOL_REF) | |
1818 | { | |
1819 | if (reg == 0) | |
1820 | reg = gen_reg_rtx (Pmode); | |
1821 | ||
1822 | emit_insn (gen_symGOT2reg (reg, orig)); | |
1823 | return reg; | |
1824 | } | |
1825 | return orig; | |
1826 | } | |
1827 | ||
1828 | /* Return zero if X references a SYMBOL_REF or LABEL_REF whose symbol | |
4375e090 | 1829 | isn't protected by a PIC unspec; nonzero otherwise. */ |
d1776069 | 1830 | int |
f1777882 | 1831 | legitimate_pic_operand_p (rtx x) |
d1776069 AO |
1832 | { |
1833 | register const char *fmt; | |
1834 | register int i; | |
1835 | ||
1836 | if (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF) | |
1837 | return 0; | |
1838 | ||
1839 | if (GET_CODE (x) == UNSPEC | |
1840 | && (XINT (x, 1) == UNSPEC_PIC | |
1841 | || XINT (x, 1) == UNSPEC_GOT | |
1842 | || XINT (x, 1) == UNSPEC_GOTOFF | |
1843 | || XINT (x, 1) == UNSPEC_PLT)) | |
1844 | return 1; | |
1845 | ||
1846 | if (GET_CODE (x) == QUEUED) | |
1847 | return legitimate_pic_operand_p (QUEUED_VAR (x)); | |
1848 | ||
1849 | fmt = GET_RTX_FORMAT (GET_CODE (x)); | |
1850 | for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--) | |
1851 | { | |
1852 | if (fmt[i] == 'E') | |
1853 | { | |
1854 | register int j; | |
1855 | ||
1856 | for (j = XVECLEN (x, i) - 1; j >= 0; j--) | |
1857 | if (! legitimate_pic_operand_p (XVECEXP (x, i, j))) | |
1858 | return 0; | |
1859 | } | |
1860 | else if (fmt[i] == 'e' && ! legitimate_pic_operand_p (XEXP (x, i))) | |
1861 | return 0; | |
1862 | } | |
1863 | ||
1864 | return 1; | |
1865 | } | |
1866 | ||
e733134f AO |
1867 | /* Return TRUE if the address X, taken from a (MEM:MODE X) rtx, is |
1868 | legitimate, and FALSE otherwise. */ | |
1869 | bool | |
1870 | legitimate_address_p (enum machine_mode mode, rtx x, int strict) | |
1871 | { | |
1872 | if (CONSTANT_ADDRESS_P (x) | |
1873 | && (! flag_pic || legitimate_pic_operand_p (x))) | |
1874 | return TRUE; | |
1875 | ||
1876 | if (RTX_OK_FOR_BASE_P (x, strict)) | |
1877 | return TRUE; | |
1878 | ||
1879 | if (TARGET_AM33 | |
1880 | && GET_CODE (x) == POST_INC | |
1881 | && RTX_OK_FOR_BASE_P (XEXP (x, 0), strict) | |
1882 | && (mode == SImode || mode == SFmode || mode == HImode)) | |
1883 | return TRUE; | |
1884 | ||
1885 | if (GET_CODE (x) == PLUS) | |
1886 | { | |
1887 | rtx base = 0, index = 0; | |
1888 | ||
1889 | if (REG_P (XEXP (x, 0)) | |
1890 | && REGNO_STRICT_OK_FOR_BASE_P (REGNO (XEXP (x, 0)), strict)) | |
1891 | { | |
1892 | base = XEXP (x, 0); | |
1893 | index = XEXP (x, 1); | |
1894 | } | |
1895 | ||
1896 | if (REG_P (XEXP (x, 1)) | |
1897 | && REGNO_STRICT_OK_FOR_BASE_P (REGNO (XEXP (x, 1)), strict)) | |
1898 | { | |
1899 | base = XEXP (x, 1); | |
1900 | index = XEXP (x, 0); | |
1901 | } | |
1902 | ||
1903 | if (base != 0 && index != 0) | |
1904 | { | |
1905 | if (GET_CODE (index) == CONST_INT) | |
1906 | return TRUE; | |
1907 | if (GET_CODE (index) == CONST | |
1908 | && (! flag_pic | |
1909 | || legitimate_pic_operand_p (index))) | |
1910 | return TRUE; | |
1911 | } | |
1912 | } | |
1913 | ||
1914 | return FALSE; | |
1915 | } | |
1916 | ||
dcefdf67 | 1917 | static int |
f1777882 | 1918 | mn10300_address_cost_1 (rtx x, int *unsig) |
460ad325 | 1919 | { |
460ad325 AO |
1920 | switch (GET_CODE (x)) |
1921 | { | |
1922 | case REG: | |
1923 | switch (REGNO_REG_CLASS (REGNO (x))) | |
1924 | { | |
1925 | case SP_REGS: | |
1926 | *unsig = 1; | |
1927 | return 0; | |
1928 | ||
1929 | case ADDRESS_REGS: | |
1930 | return 1; | |
1931 | ||
1932 | case DATA_REGS: | |
1933 | case EXTENDED_REGS: | |
18e9d2f9 | 1934 | case FP_REGS: |
460ad325 AO |
1935 | return 3; |
1936 | ||
1937 | case NO_REGS: | |
1938 | return 5; | |
1939 | ||
1940 | default: | |
1941 | abort (); | |
1942 | } | |
1943 | ||
1944 | case PLUS: | |
1945 | case MINUS: | |
d82704fb AO |
1946 | case ASHIFT: |
1947 | case AND: | |
460ad325 | 1948 | case IOR: |
dcefdf67 RH |
1949 | return (mn10300_address_cost_1 (XEXP (x, 0), unsig) |
1950 | + mn10300_address_cost_1 (XEXP (x, 1), unsig)); | |
460ad325 AO |
1951 | |
1952 | case EXPR_LIST: | |
1953 | case SUBREG: | |
1954 | case MEM: | |
dcefdf67 | 1955 | return mn10300_address_cost (XEXP (x, 0)); |
460ad325 AO |
1956 | |
1957 | case ZERO_EXTEND: | |
1958 | *unsig = 1; | |
dcefdf67 | 1959 | return mn10300_address_cost_1 (XEXP (x, 0), unsig); |
460ad325 AO |
1960 | |
1961 | case CONST_INT: | |
1962 | if (INTVAL (x) == 0) | |
1963 | return 0; | |
1964 | if (INTVAL (x) + (*unsig ? 0 : 0x80) < 0x100) | |
1965 | return 1; | |
1966 | if (INTVAL (x) + (*unsig ? 0 : 0x8000) < 0x10000) | |
1967 | return 3; | |
1968 | if (INTVAL (x) + (*unsig ? 0 : 0x800000) < 0x1000000) | |
1969 | return 5; | |
1970 | return 7; | |
1971 | ||
1972 | case CONST: | |
1973 | case SYMBOL_REF: | |
d82704fb | 1974 | case LABEL_REF: |
460ad325 AO |
1975 | return 8; |
1976 | ||
460ad325 AO |
1977 | default: |
1978 | abort (); | |
1979 | ||
1980 | } | |
1981 | } | |
3c50106f | 1982 | |
dcefdf67 | 1983 | static int |
f1777882 | 1984 | mn10300_address_cost (rtx x) |
dcefdf67 RH |
1985 | { |
1986 | int s = 0; | |
1987 | return mn10300_address_cost_1 (x, &s); | |
1988 | } | |
1989 | ||
3c50106f | 1990 | static bool |
f1777882 | 1991 | mn10300_rtx_costs (rtx x, int code, int outer_code, int *total) |
3c50106f RH |
1992 | { |
1993 | switch (code) | |
1994 | { | |
1995 | case CONST_INT: | |
1996 | /* Zeros are extremely cheap. */ | |
1997 | if (INTVAL (x) == 0 && outer_code == SET) | |
1998 | *total = 0; | |
1999 | /* If it fits in 8 bits, then it's still relatively cheap. */ | |
2000 | else if (INT_8_BITS (INTVAL (x))) | |
2001 | *total = 1; | |
2002 | /* This is the "base" cost, includes constants where either the | |
2003 | upper or lower 16bits are all zeros. */ | |
2004 | else if (INT_16_BITS (INTVAL (x)) | |
2005 | || (INTVAL (x) & 0xffff) == 0 | |
2006 | || (INTVAL (x) & 0xffff0000) == 0) | |
2007 | *total = 2; | |
2008 | else | |
2009 | *total = 4; | |
2010 | return true; | |
2011 | ||
2012 | case CONST: | |
2013 | case LABEL_REF: | |
2014 | case SYMBOL_REF: | |
2015 | /* These are more costly than a CONST_INT, but we can relax them, | |
2016 | so they're less costly than a CONST_DOUBLE. */ | |
2017 | *total = 6; | |
2018 | return true; | |
2019 | ||
2020 | case CONST_DOUBLE: | |
2021 | /* We don't optimize CONST_DOUBLEs well nor do we relax them well, | |
2022 | so their cost is very high. */ | |
2023 | *total = 8; | |
2024 | return true; | |
2025 | ||
2026 | /* ??? This probably needs more work. */ | |
2027 | case MOD: | |
2028 | case DIV: | |
2029 | case MULT: | |
2030 | *total = 8; | |
2031 | return true; | |
2032 | ||
2033 | default: | |
2034 | return false; | |
2035 | } | |
2036 | } | |
fe7496dd AO |
2037 | |
2038 | /* Check whether a constant used to initialize a DImode or DFmode can | |
2039 | use a clr instruction. The code here must be kept in sync with | |
2040 | movdf and movdi. */ | |
2041 | ||
2042 | bool | |
f1777882 | 2043 | mn10300_wide_const_load_uses_clr (rtx operands[2]) |
fe7496dd AO |
2044 | { |
2045 | long val[2]; | |
2046 | ||
2047 | if (GET_CODE (operands[0]) != REG | |
2048 | || REGNO_REG_CLASS (REGNO (operands[0])) != DATA_REGS) | |
2049 | return false; | |
2050 | ||
2051 | switch (GET_CODE (operands[1])) | |
2052 | { | |
2053 | case CONST_INT: | |
2054 | { | |
2055 | rtx low, high; | |
2056 | split_double (operands[1], &low, &high); | |
2057 | val[0] = INTVAL (low); | |
2058 | val[1] = INTVAL (high); | |
2059 | } | |
2060 | break; | |
2061 | ||
2062 | case CONST_DOUBLE: | |
2063 | if (GET_MODE (operands[1]) == DFmode) | |
2064 | { | |
2065 | REAL_VALUE_TYPE rv; | |
2066 | ||
2067 | REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]); | |
2068 | REAL_VALUE_TO_TARGET_DOUBLE (rv, val); | |
2069 | } | |
2070 | else if (GET_MODE (operands[1]) == VOIDmode | |
2071 | || GET_MODE (operands[1]) == DImode) | |
2072 | { | |
2073 | val[0] = CONST_DOUBLE_LOW (operands[1]); | |
2074 | val[1] = CONST_DOUBLE_HIGH (operands[1]); | |
2075 | } | |
2076 | break; | |
2077 | ||
2078 | default: | |
2079 | return false; | |
2080 | } | |
2081 | ||
2082 | return val[0] == 0 || val[1] == 0; | |
2083 | } | |
d1776069 AO |
2084 | /* If using PIC, mark a SYMBOL_REF for a non-global symbol so that we |
2085 | may access it using GOTOFF instead of GOT. */ | |
2086 | ||
2087 | static void | |
3bc5e4ef | 2088 | mn10300_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED) |
d1776069 AO |
2089 | { |
2090 | rtx symbol; | |
2091 | ||
2092 | if (GET_CODE (rtl) != MEM) | |
2093 | return; | |
2094 | symbol = XEXP (rtl, 0); | |
2095 | if (GET_CODE (symbol) != SYMBOL_REF) | |
2096 | return; | |
2097 | ||
2098 | if (flag_pic) | |
2099 | SYMBOL_REF_FLAG (symbol) = (*targetm.binds_local_p) (decl); | |
2100 | } |