1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 Free Software Foundation, Inc.
5 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 2, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the
21 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 MA 02110-1301, USA. */
26 #include "coretypes.h"
30 #include "hard-reg-set.h"
32 #include "insn-config.h"
33 #include "conditions.h"
34 #include "insn-attr.h"
44 #include "basic-block.h"
45 #include "integrate.h"
51 #include "target-def.h"
52 #include "langhooks.h"
54 #include "cfglayout.h"
55 #include "sched-int.h"
56 #include "tree-gimple.h"
59 #include "tm-constrs.h"
61 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
64 #include "gstab.h" /* for N_SLINE */
67 #ifndef TARGET_NO_PROTOTYPE
68 #define TARGET_NO_PROTOTYPE 0
71 #define min(A,B) ((A) < (B) ? (A) : (B))
72 #define max(A,B) ((A) > (B) ? (A) : (B))
74 /* Structure used to define the rs6000 stack */
75 typedef struct rs6000_stack {
76 int first_gp_reg_save; /* first callee saved GP register used */
77 int first_fp_reg_save; /* first callee saved FP register used */
78 int first_altivec_reg_save; /* first callee saved AltiVec register used */
79 int lr_save_p; /* true if the link reg needs to be saved */
80 int cr_save_p; /* true if the CR reg needs to be saved */
81 unsigned int vrsave_mask; /* mask of vec registers to save */
82 int push_p; /* true if we need to allocate stack space */
83 int calls_p; /* true if the function makes any calls */
84 int world_save_p; /* true if we're saving *everything*:
85 r13-r31, cr, f14-f31, vrsave, v20-v31 */
86 enum rs6000_abi abi; /* which ABI to use */
87 int gp_save_offset; /* offset to save GP regs from initial SP */
88 int fp_save_offset; /* offset to save FP regs from initial SP */
89 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
90 int lr_save_offset; /* offset to save LR from initial SP */
91 int cr_save_offset; /* offset to save CR from initial SP */
92 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
93 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
94 int varargs_save_offset; /* offset to save the varargs registers */
95 int ehrd_offset; /* offset to EH return data */
96 int reg_size; /* register size (4 or 8) */
97 HOST_WIDE_INT vars_size; /* variable save area size */
98 int parm_size; /* outgoing parameter size */
99 int save_size; /* save area size */
100 int fixed_size; /* fixed size of stack frame */
101 int gp_size; /* size of saved GP registers */
102 int fp_size; /* size of saved FP registers */
103 int altivec_size; /* size of saved AltiVec registers */
104 int cr_size; /* size to hold CR if not in save_size */
105 int vrsave_size; /* size to hold VRSAVE if not in save_size */
106 int altivec_padding_size; /* size of altivec alignment padding if
108 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
109 int spe_padding_size;
110 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
111 int spe_64bit_regs_used;
114 /* A C structure for machine-specific, per-function data.
115 This is added to the cfun structure. */
116 typedef struct machine_function GTY(())
118 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
119 int ra_needs_full_frame;
120 /* Some local-dynamic symbol. */
121 const char *some_ld_name;
122 /* Whether the instruction chain has been scanned already. */
123 int insn_chain_scanned_p;
124 /* Flags if __builtin_return_address (0) was used. */
126 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
127 varargs save area. */
128 HOST_WIDE_INT varargs_save_offset;
131 /* Target cpu type */
133 enum processor_type rs6000_cpu;
134 struct rs6000_cpu_select rs6000_select[3] =
136 /* switch name, tune arch */
137 { (const char *)0, "--with-cpu=", 1, 1 },
138 { (const char *)0, "-mcpu=", 1, 1 },
139 { (const char *)0, "-mtune=", 1, 0 },
142 static GTY(()) bool rs6000_cell_dont_microcode;
144 /* Always emit branch hint bits. */
145 static GTY(()) bool rs6000_always_hint;
147 /* Schedule instructions for group formation. */
148 static GTY(()) bool rs6000_sched_groups;
150 /* Align branch targets. */
151 static GTY(()) bool rs6000_align_branch_targets;
153 /* Support for -msched-costly-dep option. */
154 const char *rs6000_sched_costly_dep_str;
155 enum rs6000_dependence_cost rs6000_sched_costly_dep;
157 /* Support for -minsert-sched-nops option. */
158 const char *rs6000_sched_insert_nops_str;
159 enum rs6000_nop_insertion rs6000_sched_insert_nops;
161 /* Support targetm.vectorize.builtin_mask_for_load. */
162 static GTY(()) tree altivec_builtin_mask_for_load;
164 /* Size of long double. */
165 int rs6000_long_double_type_size;
167 /* IEEE quad extended precision long double. */
170 /* Whether -mabi=altivec has appeared. */
171 int rs6000_altivec_abi;
173 /* Nonzero if we want SPE ABI extensions. */
176 /* Nonzero if floating point operations are done in the GPRs. */
177 int rs6000_float_gprs = 0;
179 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
180 int rs6000_darwin64_abi;
182 /* Set to nonzero once AIX common-mode calls have been defined. */
183 static GTY(()) int common_mode_defined;
185 /* Save information from a "cmpxx" operation until the branch or scc is
187 rtx rs6000_compare_op0, rs6000_compare_op1;
188 int rs6000_compare_fp_p;
190 /* Label number of label created for -mrelocatable, to call to so we can
191 get the address of the GOT section */
192 int rs6000_pic_labelno;
195 /* Which abi to adhere to */
196 const char *rs6000_abi_name;
198 /* Semantics of the small data area */
199 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
201 /* Which small data model to use */
202 const char *rs6000_sdata_name = (char *)0;
204 /* Counter for labels which are to be placed in .fixup. */
205 int fixuplabelno = 0;
208 /* Bit size of immediate TLS offsets and string from which it is decoded. */
209 int rs6000_tls_size = 32;
210 const char *rs6000_tls_size_string;
212 /* ABI enumeration available for subtarget to use. */
213 enum rs6000_abi rs6000_current_abi;
215 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
219 const char *rs6000_debug_name;
220 int rs6000_debug_stack; /* debug stack applications */
221 int rs6000_debug_arg; /* debug argument handling */
223 /* Value is TRUE if register/mode pair is acceptable. */
224 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
226 /* Built in types. */
228 tree rs6000_builtin_types[RS6000_BTI_MAX];
229 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
231 const char *rs6000_traceback_name;
233 traceback_default = 0,
239 /* Flag to say the TOC is initialized */
241 char toc_label_name[10];
243 /* Cached value of rs6000_variable_issue. This is cached in
244 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
245 static short cached_can_issue_more;
247 static GTY(()) section *read_only_data_section;
248 static GTY(()) section *private_data_section;
249 static GTY(()) section *read_only_private_data_section;
250 static GTY(()) section *sdata2_section;
251 static GTY(()) section *toc_section;
253 /* Control alignment for fields within structures. */
254 /* String from -malign-XXXXX. */
255 int rs6000_alignment_flags;
257 /* True for any options that were explicitly set. */
259 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
260 bool alignment; /* True if -malign- was used. */
261 bool abi; /* True if -mabi=spe/nospe was used. */
262 bool spe; /* True if -mspe= was used. */
263 bool float_gprs; /* True if -mfloat-gprs= was used. */
264 bool isel; /* True if -misel was used. */
265 bool long_double; /* True if -mlong-double- was used. */
266 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
267 } rs6000_explicit_options;
269 struct builtin_description
271 /* mask is not const because we're going to alter it below. This
272 nonsense will go away when we rewrite the -march infrastructure
273 to give us more target flag bits. */
275 const enum insn_code icode;
276 const char *const name;
277 const enum rs6000_builtins code;
280 /* Target cpu costs. */
282 struct processor_costs {
283 const int mulsi; /* cost of SImode multiplication. */
284 const int mulsi_const; /* cost of SImode multiplication by constant. */
285 const int mulsi_const9; /* cost of SImode mult by short constant. */
286 const int muldi; /* cost of DImode multiplication. */
287 const int divsi; /* cost of SImode division. */
288 const int divdi; /* cost of DImode division. */
289 const int fp; /* cost of simple SFmode and DFmode insns. */
290 const int dmul; /* cost of DFmode multiplication (and fmadd). */
291 const int sdiv; /* cost of SFmode division (fdivs). */
292 const int ddiv; /* cost of DFmode division (fdiv). */
295 const struct processor_costs *rs6000_cost;
297 /* Processor costs (relative to an add) */
299 /* Instruction size costs on 32bit processors. */
301 struct processor_costs size32_cost = {
302 COSTS_N_INSNS (1), /* mulsi */
303 COSTS_N_INSNS (1), /* mulsi_const */
304 COSTS_N_INSNS (1), /* mulsi_const9 */
305 COSTS_N_INSNS (1), /* muldi */
306 COSTS_N_INSNS (1), /* divsi */
307 COSTS_N_INSNS (1), /* divdi */
308 COSTS_N_INSNS (1), /* fp */
309 COSTS_N_INSNS (1), /* dmul */
310 COSTS_N_INSNS (1), /* sdiv */
311 COSTS_N_INSNS (1), /* ddiv */
314 /* Instruction size costs on 64bit processors. */
316 struct processor_costs size64_cost = {
317 COSTS_N_INSNS (1), /* mulsi */
318 COSTS_N_INSNS (1), /* mulsi_const */
319 COSTS_N_INSNS (1), /* mulsi_const9 */
320 COSTS_N_INSNS (1), /* muldi */
321 COSTS_N_INSNS (1), /* divsi */
322 COSTS_N_INSNS (1), /* divdi */
323 COSTS_N_INSNS (1), /* fp */
324 COSTS_N_INSNS (1), /* dmul */
325 COSTS_N_INSNS (1), /* sdiv */
326 COSTS_N_INSNS (1), /* ddiv */
329 /* Instruction costs on RIOS1 processors. */
331 struct processor_costs rios1_cost = {
332 COSTS_N_INSNS (5), /* mulsi */
333 COSTS_N_INSNS (4), /* mulsi_const */
334 COSTS_N_INSNS (3), /* mulsi_const9 */
335 COSTS_N_INSNS (5), /* muldi */
336 COSTS_N_INSNS (19), /* divsi */
337 COSTS_N_INSNS (19), /* divdi */
338 COSTS_N_INSNS (2), /* fp */
339 COSTS_N_INSNS (2), /* dmul */
340 COSTS_N_INSNS (19), /* sdiv */
341 COSTS_N_INSNS (19), /* ddiv */
344 /* Instruction costs on RIOS2 processors. */
346 struct processor_costs rios2_cost = {
347 COSTS_N_INSNS (2), /* mulsi */
348 COSTS_N_INSNS (2), /* mulsi_const */
349 COSTS_N_INSNS (2), /* mulsi_const9 */
350 COSTS_N_INSNS (2), /* muldi */
351 COSTS_N_INSNS (13), /* divsi */
352 COSTS_N_INSNS (13), /* divdi */
353 COSTS_N_INSNS (2), /* fp */
354 COSTS_N_INSNS (2), /* dmul */
355 COSTS_N_INSNS (17), /* sdiv */
356 COSTS_N_INSNS (17), /* ddiv */
359 /* Instruction costs on RS64A processors. */
361 struct processor_costs rs64a_cost = {
362 COSTS_N_INSNS (20), /* mulsi */
363 COSTS_N_INSNS (12), /* mulsi_const */
364 COSTS_N_INSNS (8), /* mulsi_const9 */
365 COSTS_N_INSNS (34), /* muldi */
366 COSTS_N_INSNS (65), /* divsi */
367 COSTS_N_INSNS (67), /* divdi */
368 COSTS_N_INSNS (4), /* fp */
369 COSTS_N_INSNS (4), /* dmul */
370 COSTS_N_INSNS (31), /* sdiv */
371 COSTS_N_INSNS (31), /* ddiv */
374 /* Instruction costs on MPCCORE processors. */
376 struct processor_costs mpccore_cost = {
377 COSTS_N_INSNS (2), /* mulsi */
378 COSTS_N_INSNS (2), /* mulsi_const */
379 COSTS_N_INSNS (2), /* mulsi_const9 */
380 COSTS_N_INSNS (2), /* muldi */
381 COSTS_N_INSNS (6), /* divsi */
382 COSTS_N_INSNS (6), /* divdi */
383 COSTS_N_INSNS (4), /* fp */
384 COSTS_N_INSNS (5), /* dmul */
385 COSTS_N_INSNS (10), /* sdiv */
386 COSTS_N_INSNS (17), /* ddiv */
389 /* Instruction costs on PPC403 processors. */
391 struct processor_costs ppc403_cost = {
392 COSTS_N_INSNS (4), /* mulsi */
393 COSTS_N_INSNS (4), /* mulsi_const */
394 COSTS_N_INSNS (4), /* mulsi_const9 */
395 COSTS_N_INSNS (4), /* muldi */
396 COSTS_N_INSNS (33), /* divsi */
397 COSTS_N_INSNS (33), /* divdi */
398 COSTS_N_INSNS (11), /* fp */
399 COSTS_N_INSNS (11), /* dmul */
400 COSTS_N_INSNS (11), /* sdiv */
401 COSTS_N_INSNS (11), /* ddiv */
404 /* Instruction costs on PPC405 processors. */
406 struct processor_costs ppc405_cost = {
407 COSTS_N_INSNS (5), /* mulsi */
408 COSTS_N_INSNS (4), /* mulsi_const */
409 COSTS_N_INSNS (3), /* mulsi_const9 */
410 COSTS_N_INSNS (5), /* muldi */
411 COSTS_N_INSNS (35), /* divsi */
412 COSTS_N_INSNS (35), /* divdi */
413 COSTS_N_INSNS (11), /* fp */
414 COSTS_N_INSNS (11), /* dmul */
415 COSTS_N_INSNS (11), /* sdiv */
416 COSTS_N_INSNS (11), /* ddiv */
419 /* Instruction costs on PPC440 processors. */
421 struct processor_costs ppc440_cost = {
422 COSTS_N_INSNS (3), /* mulsi */
423 COSTS_N_INSNS (2), /* mulsi_const */
424 COSTS_N_INSNS (2), /* mulsi_const9 */
425 COSTS_N_INSNS (3), /* muldi */
426 COSTS_N_INSNS (34), /* divsi */
427 COSTS_N_INSNS (34), /* divdi */
428 COSTS_N_INSNS (5), /* fp */
429 COSTS_N_INSNS (5), /* dmul */
430 COSTS_N_INSNS (19), /* sdiv */
431 COSTS_N_INSNS (33), /* ddiv */
434 /* Instruction costs on PPC601 processors. */
436 struct processor_costs ppc601_cost = {
437 COSTS_N_INSNS (5), /* mulsi */
438 COSTS_N_INSNS (5), /* mulsi_const */
439 COSTS_N_INSNS (5), /* mulsi_const9 */
440 COSTS_N_INSNS (5), /* muldi */
441 COSTS_N_INSNS (36), /* divsi */
442 COSTS_N_INSNS (36), /* divdi */
443 COSTS_N_INSNS (4), /* fp */
444 COSTS_N_INSNS (5), /* dmul */
445 COSTS_N_INSNS (17), /* sdiv */
446 COSTS_N_INSNS (31), /* ddiv */
449 /* Instruction costs on PPC603 processors. */
451 struct processor_costs ppc603_cost = {
452 COSTS_N_INSNS (5), /* mulsi */
453 COSTS_N_INSNS (3), /* mulsi_const */
454 COSTS_N_INSNS (2), /* mulsi_const9 */
455 COSTS_N_INSNS (5), /* muldi */
456 COSTS_N_INSNS (37), /* divsi */
457 COSTS_N_INSNS (37), /* divdi */
458 COSTS_N_INSNS (3), /* fp */
459 COSTS_N_INSNS (4), /* dmul */
460 COSTS_N_INSNS (18), /* sdiv */
461 COSTS_N_INSNS (33), /* ddiv */
464 /* Instruction costs on PPC604 processors. */
466 struct processor_costs ppc604_cost = {
467 COSTS_N_INSNS (4), /* mulsi */
468 COSTS_N_INSNS (4), /* mulsi_const */
469 COSTS_N_INSNS (4), /* mulsi_const9 */
470 COSTS_N_INSNS (4), /* muldi */
471 COSTS_N_INSNS (20), /* divsi */
472 COSTS_N_INSNS (20), /* divdi */
473 COSTS_N_INSNS (3), /* fp */
474 COSTS_N_INSNS (3), /* dmul */
475 COSTS_N_INSNS (18), /* sdiv */
476 COSTS_N_INSNS (32), /* ddiv */
479 /* Instruction costs on PPC604e processors. */
481 struct processor_costs ppc604e_cost = {
482 COSTS_N_INSNS (2), /* mulsi */
483 COSTS_N_INSNS (2), /* mulsi_const */
484 COSTS_N_INSNS (2), /* mulsi_const9 */
485 COSTS_N_INSNS (2), /* muldi */
486 COSTS_N_INSNS (20), /* divsi */
487 COSTS_N_INSNS (20), /* divdi */
488 COSTS_N_INSNS (3), /* fp */
489 COSTS_N_INSNS (3), /* dmul */
490 COSTS_N_INSNS (18), /* sdiv */
491 COSTS_N_INSNS (32), /* ddiv */
494 /* Instruction costs on PPC620 processors. */
496 struct processor_costs ppc620_cost = {
497 COSTS_N_INSNS (5), /* mulsi */
498 COSTS_N_INSNS (4), /* mulsi_const */
499 COSTS_N_INSNS (3), /* mulsi_const9 */
500 COSTS_N_INSNS (7), /* muldi */
501 COSTS_N_INSNS (21), /* divsi */
502 COSTS_N_INSNS (37), /* divdi */
503 COSTS_N_INSNS (3), /* fp */
504 COSTS_N_INSNS (3), /* dmul */
505 COSTS_N_INSNS (18), /* sdiv */
506 COSTS_N_INSNS (32), /* ddiv */
509 /* Instruction costs on PPC630 processors. */
511 struct processor_costs ppc630_cost = {
512 COSTS_N_INSNS (5), /* mulsi */
513 COSTS_N_INSNS (4), /* mulsi_const */
514 COSTS_N_INSNS (3), /* mulsi_const9 */
515 COSTS_N_INSNS (7), /* muldi */
516 COSTS_N_INSNS (21), /* divsi */
517 COSTS_N_INSNS (37), /* divdi */
518 COSTS_N_INSNS (3), /* fp */
519 COSTS_N_INSNS (3), /* dmul */
520 COSTS_N_INSNS (17), /* sdiv */
521 COSTS_N_INSNS (21), /* ddiv */
524 /* Instruction costs on Cell processor. */
525 /* COSTS_N_INSNS (1) ~ one add. */
527 struct processor_costs ppccell_cost = {
528 COSTS_N_INSNS (9/2)+2, /* mulsi */
529 COSTS_N_INSNS (6/2), /* mulsi_const */
530 COSTS_N_INSNS (6/2), /* mulsi_const9 */
531 COSTS_N_INSNS (15/2)+2, /* muldi */
532 COSTS_N_INSNS (38/2), /* divsi */
533 COSTS_N_INSNS (70/2), /* divdi */
534 COSTS_N_INSNS (10/2), /* fp */
535 COSTS_N_INSNS (10/2), /* dmul */
536 COSTS_N_INSNS (74/2), /* sdiv */
537 COSTS_N_INSNS (74/2), /* ddiv */
540 /* Instruction costs on PPC750 and PPC7400 processors. */
542 struct processor_costs ppc750_cost = {
543 COSTS_N_INSNS (5), /* mulsi */
544 COSTS_N_INSNS (3), /* mulsi_const */
545 COSTS_N_INSNS (2), /* mulsi_const9 */
546 COSTS_N_INSNS (5), /* muldi */
547 COSTS_N_INSNS (17), /* divsi */
548 COSTS_N_INSNS (17), /* divdi */
549 COSTS_N_INSNS (3), /* fp */
550 COSTS_N_INSNS (3), /* dmul */
551 COSTS_N_INSNS (17), /* sdiv */
552 COSTS_N_INSNS (31), /* ddiv */
555 /* Instruction costs on PPC7450 processors. */
557 struct processor_costs ppc7450_cost = {
558 COSTS_N_INSNS (4), /* mulsi */
559 COSTS_N_INSNS (3), /* mulsi_const */
560 COSTS_N_INSNS (3), /* mulsi_const9 */
561 COSTS_N_INSNS (4), /* muldi */
562 COSTS_N_INSNS (23), /* divsi */
563 COSTS_N_INSNS (23), /* divdi */
564 COSTS_N_INSNS (5), /* fp */
565 COSTS_N_INSNS (5), /* dmul */
566 COSTS_N_INSNS (21), /* sdiv */
567 COSTS_N_INSNS (35), /* ddiv */
570 /* Instruction costs on PPC8540 processors. */
572 struct processor_costs ppc8540_cost = {
573 COSTS_N_INSNS (4), /* mulsi */
574 COSTS_N_INSNS (4), /* mulsi_const */
575 COSTS_N_INSNS (4), /* mulsi_const9 */
576 COSTS_N_INSNS (4), /* muldi */
577 COSTS_N_INSNS (19), /* divsi */
578 COSTS_N_INSNS (19), /* divdi */
579 COSTS_N_INSNS (4), /* fp */
580 COSTS_N_INSNS (4), /* dmul */
581 COSTS_N_INSNS (29), /* sdiv */
582 COSTS_N_INSNS (29), /* ddiv */
585 /* Instruction costs on POWER4 and POWER5 processors. */
587 struct processor_costs power4_cost = {
588 COSTS_N_INSNS (3), /* mulsi */
589 COSTS_N_INSNS (2), /* mulsi_const */
590 COSTS_N_INSNS (2), /* mulsi_const9 */
591 COSTS_N_INSNS (4), /* muldi */
592 COSTS_N_INSNS (18), /* divsi */
593 COSTS_N_INSNS (34), /* divdi */
594 COSTS_N_INSNS (3), /* fp */
595 COSTS_N_INSNS (3), /* dmul */
596 COSTS_N_INSNS (17), /* sdiv */
597 COSTS_N_INSNS (17), /* ddiv */
600 /* Instruction costs on POWER6 processors. */
602 struct processor_costs power6_cost = {
603 COSTS_N_INSNS (8), /* mulsi */
604 COSTS_N_INSNS (8), /* mulsi_const */
605 COSTS_N_INSNS (8), /* mulsi_const9 */
606 COSTS_N_INSNS (8), /* muldi */
607 COSTS_N_INSNS (22), /* divsi */
608 COSTS_N_INSNS (28), /* divdi */
609 COSTS_N_INSNS (3), /* fp */
610 COSTS_N_INSNS (3), /* dmul */
611 COSTS_N_INSNS (13), /* sdiv */
612 COSTS_N_INSNS (16), /* ddiv */
616 static bool rs6000_function_ok_for_sibcall (tree, tree);
617 static const char *rs6000_invalid_within_doloop (rtx);
618 static rtx rs6000_generate_compare (enum rtx_code);
619 static void rs6000_maybe_dead (rtx);
620 static void rs6000_emit_stack_tie (void);
621 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
622 static rtx spe_synthesize_frame_save (rtx);
623 static bool spe_func_has_64bit_regs_p (void);
624 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
626 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
627 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int);
628 static unsigned rs6000_hash_constant (rtx);
629 static unsigned toc_hash_function (const void *);
630 static int toc_hash_eq (const void *, const void *);
631 static int constant_pool_expr_1 (rtx, int *, int *);
632 static bool constant_pool_expr_p (rtx);
633 static bool legitimate_small_data_p (enum machine_mode, rtx);
634 static bool legitimate_indexed_address_p (rtx, int);
635 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
636 static struct machine_function * rs6000_init_machine_status (void);
637 static bool rs6000_assemble_integer (rtx, unsigned int, int);
638 static bool no_global_regs_above (int);
639 #ifdef HAVE_GAS_HIDDEN
640 static void rs6000_assemble_visibility (tree, int);
642 static int rs6000_ra_ever_killed (void);
643 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
644 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
645 static bool rs6000_ms_bitfield_layout_p (tree);
646 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
647 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
648 static const char *rs6000_mangle_fundamental_type (tree);
649 extern const struct attribute_spec rs6000_attribute_table[];
650 static void rs6000_set_default_type_attributes (tree);
651 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
652 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
653 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
655 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
656 static bool rs6000_return_in_memory (tree, tree);
657 static void rs6000_file_start (void);
659 static int rs6000_elf_reloc_rw_mask (void);
660 static void rs6000_elf_asm_out_constructor (rtx, int);
661 static void rs6000_elf_asm_out_destructor (rtx, int);
662 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
663 static void rs6000_elf_asm_init_sections (void);
664 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
665 unsigned HOST_WIDE_INT);
666 static void rs6000_elf_encode_section_info (tree, rtx, int)
669 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, rtx);
671 static void rs6000_xcoff_asm_output_anchor (rtx);
672 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
673 static void rs6000_xcoff_asm_init_sections (void);
674 static int rs6000_xcoff_reloc_rw_mask (void);
675 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
676 static section *rs6000_xcoff_select_section (tree, int,
677 unsigned HOST_WIDE_INT);
678 static void rs6000_xcoff_unique_section (tree, int);
679 static section *rs6000_xcoff_select_rtx_section
680 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
681 static const char * rs6000_xcoff_strip_name_encoding (const char *);
682 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
683 static void rs6000_xcoff_file_start (void);
684 static void rs6000_xcoff_file_end (void);
686 static int rs6000_variable_issue (FILE *, int, rtx, int);
687 static bool rs6000_rtx_costs (rtx, int, int, int *);
688 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
689 static void rs6000_sched_init (FILE *, int, int);
690 static bool is_microcoded_insn (rtx);
691 static bool is_nonpipeline_insn (rtx);
692 static bool is_cracked_insn (rtx);
693 static bool is_branch_slot_insn (rtx);
694 static bool is_load_insn (rtx);
695 static rtx get_store_dest (rtx pat);
696 static bool is_store_insn (rtx);
697 static bool set_to_load_agen (rtx,rtx);
698 static bool adjacent_mem_locations (rtx,rtx);
699 static int rs6000_adjust_priority (rtx, int);
700 static int rs6000_issue_rate (void);
701 static bool rs6000_is_costly_dependence (dep_t, int, int);
702 static rtx get_next_active_insn (rtx, rtx);
703 static bool insn_terminates_group_p (rtx , enum group_termination);
704 static bool insn_must_be_first_in_group (rtx);
705 static bool insn_must_be_last_in_group (rtx);
706 static bool is_costly_group (rtx *, rtx);
707 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
708 static int redefine_groups (FILE *, int, rtx, rtx);
709 static int pad_groups (FILE *, int, rtx, rtx);
710 static void rs6000_sched_finish (FILE *, int);
711 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
712 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
713 static int rs6000_use_sched_lookahead (void);
714 static int rs6000_use_sched_lookahead_guard (rtx);
715 static tree rs6000_builtin_mask_for_load (void);
716 static tree rs6000_builtin_mul_widen_even (tree);
717 static tree rs6000_builtin_mul_widen_odd (tree);
718 static tree rs6000_builtin_conversion (enum tree_code, tree);
720 static void def_builtin (int, const char *, tree, int);
721 static void rs6000_init_builtins (void);
722 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
723 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
724 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
725 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
726 static void altivec_init_builtins (void);
727 static void rs6000_common_init_builtins (void);
728 static void rs6000_init_libfuncs (void);
730 static void enable_mask_for_builtins (struct builtin_description *, int,
731 enum rs6000_builtins,
732 enum rs6000_builtins);
733 static tree build_opaque_vector_type (tree, int);
734 static void spe_init_builtins (void);
735 static rtx spe_expand_builtin (tree, rtx, bool *);
736 static rtx spe_expand_stv_builtin (enum insn_code, tree);
737 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
738 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
739 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
740 static rs6000_stack_t *rs6000_stack_info (void);
741 static void debug_stack_info (rs6000_stack_t *);
743 static rtx altivec_expand_builtin (tree, rtx, bool *);
744 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
745 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
746 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
747 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
748 static rtx altivec_expand_predicate_builtin (enum insn_code,
749 const char *, tree, rtx);
750 static rtx altivec_expand_lv_builtin (enum insn_code, tree, rtx);
751 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
752 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
753 static rtx altivec_expand_vec_set_builtin (tree);
754 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
755 static int get_element_number (tree, tree);
756 static bool rs6000_handle_option (size_t, const char *, int);
757 static void rs6000_parse_tls_size_option (void);
758 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
759 static int first_altivec_reg_to_save (void);
760 static unsigned int compute_vrsave_mask (void);
761 static void compute_save_world_info (rs6000_stack_t *info_ptr);
762 static void is_altivec_return_reg (rtx, void *);
763 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
764 int easy_vector_constant (rtx, enum machine_mode);
765 static bool rs6000_is_opaque_type (tree);
766 static rtx rs6000_dwarf_register_span (rtx);
767 static void rs6000_init_dwarf_reg_sizes_extra (tree);
768 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
769 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
770 static rtx rs6000_tls_get_addr (void);
771 static rtx rs6000_got_sym (void);
772 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
773 static const char *rs6000_get_some_local_dynamic_name (void);
774 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
775 static rtx rs6000_complex_function_value (enum machine_mode);
776 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
777 enum machine_mode, tree);
778 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
780 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
781 tree, HOST_WIDE_INT);
782 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
785 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
788 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, tree, int, bool);
789 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
790 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
791 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
792 enum machine_mode, tree,
794 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
796 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
798 static const char *invalid_arg_for_unprototyped_fn (tree, tree, tree);
800 static void macho_branch_islands (void);
801 static int no_previous_def (tree function_name);
802 static tree get_prev_label (tree function_name);
803 static void rs6000_darwin_file_start (void);
806 static tree rs6000_build_builtin_va_list (void);
807 static tree rs6000_gimplify_va_arg (tree, tree, tree *, tree *);
808 static bool rs6000_must_pass_in_stack (enum machine_mode, tree);
809 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
810 static bool rs6000_vector_mode_supported_p (enum machine_mode);
811 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
813 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
815 static int get_vsel_insn (enum machine_mode);
816 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
817 static tree rs6000_stack_protect_fail (void);
819 const int INSN_NOT_AVAILABLE = -1;
820 static enum machine_mode rs6000_eh_return_filter_mode (void);
822 /* Hash table stuff for keeping track of TOC entries. */
824 struct toc_hash_struct GTY(())
826 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
827 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
829 enum machine_mode key_mode;
833 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
835 /* Default register names. */
836 char rs6000_reg_names[][8] =
838 "0", "1", "2", "3", "4", "5", "6", "7",
839 "8", "9", "10", "11", "12", "13", "14", "15",
840 "16", "17", "18", "19", "20", "21", "22", "23",
841 "24", "25", "26", "27", "28", "29", "30", "31",
842 "0", "1", "2", "3", "4", "5", "6", "7",
843 "8", "9", "10", "11", "12", "13", "14", "15",
844 "16", "17", "18", "19", "20", "21", "22", "23",
845 "24", "25", "26", "27", "28", "29", "30", "31",
846 "mq", "lr", "ctr","ap",
847 "0", "1", "2", "3", "4", "5", "6", "7",
849 /* AltiVec registers. */
850 "0", "1", "2", "3", "4", "5", "6", "7",
851 "8", "9", "10", "11", "12", "13", "14", "15",
852 "16", "17", "18", "19", "20", "21", "22", "23",
853 "24", "25", "26", "27", "28", "29", "30", "31",
856 "spe_acc", "spefscr",
857 /* Soft frame pointer. */
861 #ifdef TARGET_REGNAMES
862 static const char alt_reg_names[][8] =
864 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
865 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
866 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
867 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
868 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
869 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
870 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
871 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
872 "mq", "lr", "ctr", "ap",
873 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
875 /* AltiVec registers. */
876 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
877 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
878 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
879 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
882 "spe_acc", "spefscr",
883 /* Soft frame pointer. */
888 #ifndef MASK_STRICT_ALIGN
889 #define MASK_STRICT_ALIGN 0
891 #ifndef TARGET_PROFILE_KERNEL
892 #define TARGET_PROFILE_KERNEL 0
895 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
896 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
898 /* Initialize the GCC target structure. */
899 #undef TARGET_ATTRIBUTE_TABLE
900 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
901 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
902 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
904 #undef TARGET_ASM_ALIGNED_DI_OP
905 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
907 /* Default unaligned ops are only provided for ELF. Find the ops needed
908 for non-ELF systems. */
909 #ifndef OBJECT_FORMAT_ELF
911 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
913 #undef TARGET_ASM_UNALIGNED_HI_OP
914 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
915 #undef TARGET_ASM_UNALIGNED_SI_OP
916 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
917 #undef TARGET_ASM_UNALIGNED_DI_OP
918 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
921 #undef TARGET_ASM_UNALIGNED_HI_OP
922 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
923 #undef TARGET_ASM_UNALIGNED_SI_OP
924 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
925 #undef TARGET_ASM_UNALIGNED_DI_OP
926 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
927 #undef TARGET_ASM_ALIGNED_DI_OP
928 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
932 /* This hook deals with fixups for relocatable code and DI-mode objects
934 #undef TARGET_ASM_INTEGER
935 #define TARGET_ASM_INTEGER rs6000_assemble_integer
937 #ifdef HAVE_GAS_HIDDEN
938 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
939 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
942 #undef TARGET_HAVE_TLS
943 #define TARGET_HAVE_TLS HAVE_AS_TLS
945 #undef TARGET_CANNOT_FORCE_CONST_MEM
946 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
948 #undef TARGET_ASM_FUNCTION_PROLOGUE
949 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
950 #undef TARGET_ASM_FUNCTION_EPILOGUE
951 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
953 #undef TARGET_SCHED_VARIABLE_ISSUE
954 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
956 #undef TARGET_SCHED_ISSUE_RATE
957 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
958 #undef TARGET_SCHED_ADJUST_COST
959 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
960 #undef TARGET_SCHED_ADJUST_PRIORITY
961 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
962 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
963 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
964 #undef TARGET_SCHED_INIT
965 #define TARGET_SCHED_INIT rs6000_sched_init
966 #undef TARGET_SCHED_FINISH
967 #define TARGET_SCHED_FINISH rs6000_sched_finish
968 #undef TARGET_SCHED_REORDER
969 #define TARGET_SCHED_REORDER rs6000_sched_reorder
970 #undef TARGET_SCHED_REORDER2
971 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
973 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
974 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
976 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
977 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
979 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
980 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
981 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
982 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
983 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
984 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
985 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
986 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
988 #undef TARGET_INIT_BUILTINS
989 #define TARGET_INIT_BUILTINS rs6000_init_builtins
991 #undef TARGET_EXPAND_BUILTIN
992 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
994 #undef TARGET_MANGLE_FUNDAMENTAL_TYPE
995 #define TARGET_MANGLE_FUNDAMENTAL_TYPE rs6000_mangle_fundamental_type
997 #undef TARGET_INIT_LIBFUNCS
998 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1001 #undef TARGET_BINDS_LOCAL_P
1002 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1005 #undef TARGET_MS_BITFIELD_LAYOUT_P
1006 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1008 #undef TARGET_ASM_OUTPUT_MI_THUNK
1009 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1011 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1012 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
1014 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1015 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1017 #undef TARGET_INVALID_WITHIN_DOLOOP
1018 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1020 #undef TARGET_RTX_COSTS
1021 #define TARGET_RTX_COSTS rs6000_rtx_costs
1022 #undef TARGET_ADDRESS_COST
1023 #define TARGET_ADDRESS_COST hook_int_rtx_0
1025 #undef TARGET_VECTOR_OPAQUE_P
1026 #define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
1028 #undef TARGET_DWARF_REGISTER_SPAN
1029 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1031 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1032 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1034 /* On rs6000, function arguments are promoted, as are function return
1036 #undef TARGET_PROMOTE_FUNCTION_ARGS
1037 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
1038 #undef TARGET_PROMOTE_FUNCTION_RETURN
1039 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
1041 #undef TARGET_RETURN_IN_MEMORY
1042 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1044 #undef TARGET_SETUP_INCOMING_VARARGS
1045 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1047 /* Always strict argument naming on rs6000. */
1048 #undef TARGET_STRICT_ARGUMENT_NAMING
1049 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1050 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1051 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1052 #undef TARGET_SPLIT_COMPLEX_ARG
1053 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_tree_true
1054 #undef TARGET_MUST_PASS_IN_STACK
1055 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1056 #undef TARGET_PASS_BY_REFERENCE
1057 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1058 #undef TARGET_ARG_PARTIAL_BYTES
1059 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1061 #undef TARGET_BUILD_BUILTIN_VA_LIST
1062 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1064 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1065 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1067 #undef TARGET_EH_RETURN_FILTER_MODE
1068 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1070 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1071 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1073 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1074 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1076 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1077 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1079 #undef TARGET_HANDLE_OPTION
1080 #define TARGET_HANDLE_OPTION rs6000_handle_option
1082 #undef TARGET_DEFAULT_TARGET_FLAGS
1083 #define TARGET_DEFAULT_TARGET_FLAGS \
1086 #undef TARGET_STACK_PROTECT_FAIL
1087 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1089 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1090 The PowerPC architecture requires only weak consistency among
1091 processors--that is, memory accesses between processors need not be
1092 sequentially consistent and memory accesses among processors can occur
1093 in any order. The ability to order memory accesses weakly provides
1094 opportunities for more efficient use of the system bus. Unless a
1095 dependency exists, the 604e allows read operations to precede store
1097 #undef TARGET_RELAXED_ORDERING
1098 #define TARGET_RELAXED_ORDERING true
1101 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1102 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1105 /* Use a 32-bit anchor range. This leads to sequences like:
1107 addis tmp,anchor,high
1110 where tmp itself acts as an anchor, and can be shared between
1111 accesses to the same 64k page. */
1112 #undef TARGET_MIN_ANCHOR_OFFSET
1113 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1114 #undef TARGET_MAX_ANCHOR_OFFSET
1115 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1116 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1117 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1119 struct gcc_target targetm = TARGET_INITIALIZER;
1122 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1125 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1127 /* The GPRs can hold any mode, but values bigger than one register
1128 cannot go past R31. */
1129 if (INT_REGNO_P (regno))
1130 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1132 /* The float registers can only hold floating modes and DImode.
1133 This excludes the 32-bit decimal float mode for now. */
1134 if (FP_REGNO_P (regno))
1136 (SCALAR_FLOAT_MODE_P (mode)
1137 && (mode != TDmode || (regno % 2) == 0)
1139 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1140 || (GET_MODE_CLASS (mode) == MODE_INT
1141 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD);
1143 /* The CR register can only hold CC modes. */
1144 if (CR_REGNO_P (regno))
1145 return GET_MODE_CLASS (mode) == MODE_CC;
1147 if (XER_REGNO_P (regno))
1148 return mode == PSImode;
1150 /* AltiVec only in AldyVec registers. */
1151 if (ALTIVEC_REGNO_P (regno))
1152 return ALTIVEC_VECTOR_MODE (mode);
1154 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1155 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1158 /* We cannot put TImode anywhere except general register and it must be
1159 able to fit within the register set. */
1161 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1164 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1166 rs6000_init_hard_regno_mode_ok (void)
1170 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1171 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1172 if (rs6000_hard_regno_mode_ok (r, m))
1173 rs6000_hard_regno_mode_ok_p[m][r] = true;
1177 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
1180 darwin_rs6000_override_options (void)
1182 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
1184 rs6000_altivec_abi = 1;
1185 TARGET_ALTIVEC_VRSAVE = 1;
1186 if (DEFAULT_ABI == ABI_DARWIN)
1188 if (MACHO_DYNAMIC_NO_PIC_P)
1191 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
1194 else if (flag_pic == 1)
1199 if (TARGET_64BIT && ! TARGET_POWERPC64)
1201 target_flags |= MASK_POWERPC64;
1202 warning (0, "-m64 requires PowerPC64 architecture, enabling");
1206 rs6000_default_long_calls = 1;
1207 target_flags |= MASK_SOFT_FLOAT;
1210 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
1212 if (!flag_mkernel && !flag_apple_kext
1214 && ! (target_flags_explicit & MASK_ALTIVEC))
1215 target_flags |= MASK_ALTIVEC;
1217 /* Unless the user (not the configurer) has explicitly overridden
1218 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
1219 G4 unless targetting the kernel. */
1222 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
1223 && ! (target_flags_explicit & MASK_ALTIVEC)
1224 && ! rs6000_select[1].string)
1226 target_flags |= MASK_ALTIVEC;
1231 /* If not otherwise specified by a target, make 'long double' equivalent to
1234 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1235 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1238 /* Override command line options. Mostly we process the processor
1239 type and sometimes adjust other TARGET_ options. */
1242 rs6000_override_options (const char *default_cpu)
1245 struct rs6000_cpu_select *ptr;
1248 /* Simplifications for entries below. */
1251 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1252 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1255 /* This table occasionally claims that a processor does not support
1256 a particular feature even though it does, but the feature is slower
1257 than the alternative. Thus, it shouldn't be relied on as a
1258 complete description of the processor's support.
1260 Please keep this list in order, and don't forget to update the
1261 documentation in invoke.texi when adding a new processor or
1265 const char *const name; /* Canonical processor name. */
1266 const enum processor_type processor; /* Processor type enum value. */
1267 const int target_enable; /* Target flags to enable. */
1268 } const processor_target_table[]
1269 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1270 {"403", PROCESSOR_PPC403,
1271 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1272 {"405", PROCESSOR_PPC405,
1273 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1274 {"405fp", PROCESSOR_PPC405,
1275 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1276 {"440", PROCESSOR_PPC440,
1277 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1278 {"440fp", PROCESSOR_PPC440,
1279 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1280 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1281 {"601", PROCESSOR_PPC601,
1282 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1283 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1284 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1285 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1286 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1287 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1288 {"620", PROCESSOR_PPC620,
1289 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1290 {"630", PROCESSOR_PPC630,
1291 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1292 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1293 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1294 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1295 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1296 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1297 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1298 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1299 {"8540", PROCESSOR_PPC8540,
1300 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_STRICT_ALIGN},
1301 /* 8548 has a dummy entry for now. */
1302 {"8548", PROCESSOR_PPC8540,
1303 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_STRICT_ALIGN},
1304 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1305 {"970", PROCESSOR_POWER4,
1306 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1307 {"cell", PROCESSOR_CELL,
1308 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1309 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1310 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1311 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1312 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1313 {"G5", PROCESSOR_POWER4,
1314 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1315 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1316 {"power2", PROCESSOR_POWER,
1317 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1318 {"power3", PROCESSOR_PPC630,
1319 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1320 {"power4", PROCESSOR_POWER4,
1321 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1322 {"power5", PROCESSOR_POWER5,
1323 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1324 | MASK_MFCRF | MASK_POPCNTB},
1325 {"power5+", PROCESSOR_POWER5,
1326 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1327 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1328 {"power6", PROCESSOR_POWER6,
1329 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1330 | MASK_FPRND | MASK_CMPB | MASK_DFP },
1331 {"power6x", PROCESSOR_POWER6,
1332 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1333 | MASK_FPRND | MASK_CMPB | MASK_MFPGPR | MASK_DFP },
1334 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1335 {"powerpc64", PROCESSOR_POWERPC64,
1336 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1337 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1338 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1339 {"rios2", PROCESSOR_RIOS2,
1340 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1341 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1342 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1343 {"rs64", PROCESSOR_RS64A,
1344 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1347 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1349 /* Some OSs don't support saving the high part of 64-bit registers on
1350 context switch. Other OSs don't support saving Altivec registers.
1351 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1352 settings; if the user wants either, the user must explicitly specify
1353 them and we won't interfere with the user's specification. */
1356 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1357 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1358 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1359 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1360 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP)
1363 rs6000_init_hard_regno_mode_ok ();
1365 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1366 #ifdef OS_MISSING_POWERPC64
1367 if (OS_MISSING_POWERPC64)
1368 set_masks &= ~MASK_POWERPC64;
1370 #ifdef OS_MISSING_ALTIVEC
1371 if (OS_MISSING_ALTIVEC)
1372 set_masks &= ~MASK_ALTIVEC;
1375 /* Don't override by the processor default if given explicitly. */
1376 set_masks &= ~target_flags_explicit;
1378 /* Identify the processor type. */
1379 rs6000_select[0].string = default_cpu;
1380 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1382 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1384 ptr = &rs6000_select[i];
1385 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1387 for (j = 0; j < ptt_size; j++)
1388 if (! strcmp (ptr->string, processor_target_table[j].name))
1390 if (ptr->set_tune_p)
1391 rs6000_cpu = processor_target_table[j].processor;
1393 if (ptr->set_arch_p)
1395 target_flags &= ~set_masks;
1396 target_flags |= (processor_target_table[j].target_enable
1403 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1410 /* If we are optimizing big endian systems for space, use the load/store
1411 multiple and string instructions. */
1412 if (BYTES_BIG_ENDIAN && optimize_size)
1413 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1415 /* Don't allow -mmultiple or -mstring on little endian systems
1416 unless the cpu is a 750, because the hardware doesn't support the
1417 instructions used in little endian mode, and causes an alignment
1418 trap. The 750 does not cause an alignment trap (except when the
1419 target is unaligned). */
1421 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1423 if (TARGET_MULTIPLE)
1425 target_flags &= ~MASK_MULTIPLE;
1426 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1427 warning (0, "-mmultiple is not supported on little endian systems");
1432 target_flags &= ~MASK_STRING;
1433 if ((target_flags_explicit & MASK_STRING) != 0)
1434 warning (0, "-mstring is not supported on little endian systems");
1438 /* Set debug flags */
1439 if (rs6000_debug_name)
1441 if (! strcmp (rs6000_debug_name, "all"))
1442 rs6000_debug_stack = rs6000_debug_arg = 1;
1443 else if (! strcmp (rs6000_debug_name, "stack"))
1444 rs6000_debug_stack = 1;
1445 else if (! strcmp (rs6000_debug_name, "arg"))
1446 rs6000_debug_arg = 1;
1448 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1451 if (rs6000_traceback_name)
1453 if (! strncmp (rs6000_traceback_name, "full", 4))
1454 rs6000_traceback = traceback_full;
1455 else if (! strncmp (rs6000_traceback_name, "part", 4))
1456 rs6000_traceback = traceback_part;
1457 else if (! strncmp (rs6000_traceback_name, "no", 2))
1458 rs6000_traceback = traceback_none;
1460 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1461 rs6000_traceback_name);
1464 if (!rs6000_explicit_options.long_double)
1465 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1467 #ifndef POWERPC_LINUX
1468 if (!rs6000_explicit_options.ieee)
1469 rs6000_ieeequad = 1;
1472 /* Set Altivec ABI as default for powerpc64 linux. */
1473 if (TARGET_ELF && TARGET_64BIT)
1475 rs6000_altivec_abi = 1;
1476 TARGET_ALTIVEC_VRSAVE = 1;
1479 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1480 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1482 rs6000_darwin64_abi = 1;
1484 darwin_one_byte_bool = 1;
1486 /* Default to natural alignment, for better performance. */
1487 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1490 /* Place FP constants in the constant pool instead of TOC
1491 if section anchors enabled. */
1492 if (flag_section_anchors)
1493 TARGET_NO_FP_IN_TOC = 1;
1495 /* Handle -mtls-size option. */
1496 rs6000_parse_tls_size_option ();
1498 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1499 SUBTARGET_OVERRIDE_OPTIONS;
1501 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1502 SUBSUBTARGET_OVERRIDE_OPTIONS;
1504 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1505 SUB3TARGET_OVERRIDE_OPTIONS;
1510 /* The e500 does not have string instructions, and we set
1511 MASK_STRING above when optimizing for size. */
1512 if ((target_flags & MASK_STRING) != 0)
1513 target_flags = target_flags & ~MASK_STRING;
1515 else if (rs6000_select[1].string != NULL)
1517 /* For the powerpc-eabispe configuration, we set all these by
1518 default, so let's unset them if we manually set another
1519 CPU that is not the E500. */
1520 if (!rs6000_explicit_options.abi)
1522 if (!rs6000_explicit_options.spe)
1524 if (!rs6000_explicit_options.float_gprs)
1525 rs6000_float_gprs = 0;
1526 if (!rs6000_explicit_options.isel)
1530 /* Detect invalid option combinations with E500. */
1533 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1534 && rs6000_cpu != PROCESSOR_POWER5
1535 && rs6000_cpu != PROCESSOR_POWER6
1536 && rs6000_cpu != PROCESSOR_CELL);
1537 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1538 || rs6000_cpu == PROCESSOR_POWER5);
1539 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
1540 || rs6000_cpu == PROCESSOR_POWER5
1541 || rs6000_cpu == PROCESSOR_POWER6);
1543 rs6000_sched_restricted_insns_priority
1544 = (rs6000_sched_groups ? 1 : 0);
1546 /* Handle -msched-costly-dep option. */
1547 rs6000_sched_costly_dep
1548 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1550 if (rs6000_sched_costly_dep_str)
1552 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1553 rs6000_sched_costly_dep = no_dep_costly;
1554 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1555 rs6000_sched_costly_dep = all_deps_costly;
1556 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1557 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1558 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1559 rs6000_sched_costly_dep = store_to_load_dep_costly;
1561 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1564 /* Handle -minsert-sched-nops option. */
1565 rs6000_sched_insert_nops
1566 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1568 if (rs6000_sched_insert_nops_str)
1570 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1571 rs6000_sched_insert_nops = sched_finish_none;
1572 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1573 rs6000_sched_insert_nops = sched_finish_pad_groups;
1574 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1575 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1577 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1580 #ifdef TARGET_REGNAMES
1581 /* If the user desires alternate register names, copy in the
1582 alternate names now. */
1583 if (TARGET_REGNAMES)
1584 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1587 /* Set aix_struct_return last, after the ABI is determined.
1588 If -maix-struct-return or -msvr4-struct-return was explicitly
1589 used, don't override with the ABI default. */
1590 if (!rs6000_explicit_options.aix_struct_ret)
1591 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
1593 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
1594 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1597 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1599 /* We can only guarantee the availability of DI pseudo-ops when
1600 assembling for 64-bit targets. */
1603 targetm.asm_out.aligned_op.di = NULL;
1604 targetm.asm_out.unaligned_op.di = NULL;
1607 /* Set branch target alignment, if not optimizing for size. */
1610 /* Cell wants to be aligned 8byte for dual issue. */
1611 if (rs6000_cpu == PROCESSOR_CELL)
1613 if (align_functions <= 0)
1614 align_functions = 8;
1615 if (align_jumps <= 0)
1617 if (align_loops <= 0)
1620 if (rs6000_align_branch_targets)
1622 if (align_functions <= 0)
1623 align_functions = 16;
1624 if (align_jumps <= 0)
1626 if (align_loops <= 0)
1629 if (align_jumps_max_skip <= 0)
1630 align_jumps_max_skip = 15;
1631 if (align_loops_max_skip <= 0)
1632 align_loops_max_skip = 15;
1635 /* Arrange to save and restore machine status around nested functions. */
1636 init_machine_status = rs6000_init_machine_status;
1638 /* We should always be splitting complex arguments, but we can't break
1639 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1640 if (DEFAULT_ABI != ABI_AIX)
1641 targetm.calls.split_complex_arg = NULL;
1643 /* Initialize rs6000_cost with the appropriate target costs. */
1645 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1649 case PROCESSOR_RIOS1:
1650 rs6000_cost = &rios1_cost;
1653 case PROCESSOR_RIOS2:
1654 rs6000_cost = &rios2_cost;
1657 case PROCESSOR_RS64A:
1658 rs6000_cost = &rs64a_cost;
1661 case PROCESSOR_MPCCORE:
1662 rs6000_cost = &mpccore_cost;
1665 case PROCESSOR_PPC403:
1666 rs6000_cost = &ppc403_cost;
1669 case PROCESSOR_PPC405:
1670 rs6000_cost = &ppc405_cost;
1673 case PROCESSOR_PPC440:
1674 rs6000_cost = &ppc440_cost;
1677 case PROCESSOR_PPC601:
1678 rs6000_cost = &ppc601_cost;
1681 case PROCESSOR_PPC603:
1682 rs6000_cost = &ppc603_cost;
1685 case PROCESSOR_PPC604:
1686 rs6000_cost = &ppc604_cost;
1689 case PROCESSOR_PPC604e:
1690 rs6000_cost = &ppc604e_cost;
1693 case PROCESSOR_PPC620:
1694 rs6000_cost = &ppc620_cost;
1697 case PROCESSOR_PPC630:
1698 rs6000_cost = &ppc630_cost;
1701 case PROCESSOR_CELL:
1702 rs6000_cost = &ppccell_cost;
1705 case PROCESSOR_PPC750:
1706 case PROCESSOR_PPC7400:
1707 rs6000_cost = &ppc750_cost;
1710 case PROCESSOR_PPC7450:
1711 rs6000_cost = &ppc7450_cost;
1714 case PROCESSOR_PPC8540:
1715 rs6000_cost = &ppc8540_cost;
1718 case PROCESSOR_POWER4:
1719 case PROCESSOR_POWER5:
1720 rs6000_cost = &power4_cost;
1723 case PROCESSOR_POWER6:
1724 rs6000_cost = &power6_cost;
1732 /* Implement targetm.vectorize.builtin_mask_for_load. */
1734 rs6000_builtin_mask_for_load (void)
1737 return altivec_builtin_mask_for_load;
1742 /* Implement targetm.vectorize.builtin_conversion. */
1744 rs6000_builtin_conversion (enum tree_code code, tree type)
1746 if (!TARGET_ALTIVEC)
1752 switch (TYPE_MODE (type))
1755 return TYPE_UNSIGNED (type) ?
1756 rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFUX] :
1757 rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFSX];
1766 /* Implement targetm.vectorize.builtin_mul_widen_even. */
1768 rs6000_builtin_mul_widen_even (tree type)
1770 if (!TARGET_ALTIVEC)
1773 switch (TYPE_MODE (type))
1776 return TYPE_UNSIGNED (type) ?
1777 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH] :
1778 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
1781 return TYPE_UNSIGNED (type) ?
1782 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB] :
1783 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
1789 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
1791 rs6000_builtin_mul_widen_odd (tree type)
1793 if (!TARGET_ALTIVEC)
1796 switch (TYPE_MODE (type))
1799 return TYPE_UNSIGNED (type) ?
1800 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH] :
1801 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
1804 return TYPE_UNSIGNED (type) ?
1805 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB] :
1806 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
1812 /* Handle generic options of the form -mfoo=yes/no.
1813 NAME is the option name.
1814 VALUE is the option value.
1815 FLAG is the pointer to the flag where to store a 1 or 0, depending on
1816 whether the option value is 'yes' or 'no' respectively. */
1818 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
1822 else if (!strcmp (value, "yes"))
1824 else if (!strcmp (value, "no"))
1827 error ("unknown -m%s= option specified: '%s'", name, value);
1830 /* Validate and record the size specified with the -mtls-size option. */
1833 rs6000_parse_tls_size_option (void)
1835 if (rs6000_tls_size_string == 0)
1837 else if (strcmp (rs6000_tls_size_string, "16") == 0)
1838 rs6000_tls_size = 16;
1839 else if (strcmp (rs6000_tls_size_string, "32") == 0)
1840 rs6000_tls_size = 32;
1841 else if (strcmp (rs6000_tls_size_string, "64") == 0)
1842 rs6000_tls_size = 64;
1844 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
1848 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
1850 if (DEFAULT_ABI == ABI_DARWIN)
1851 /* The Darwin libraries never set errno, so we might as well
1852 avoid calling them when that's the only reason we would. */
1853 flag_errno_math = 0;
1855 /* Double growth factor to counter reduced min jump length. */
1856 set_param_value ("max-grow-copy-bb-insns", 16);
1858 /* Enable section anchors by default.
1859 Skip section anchors for Objective C and Objective C++
1860 until front-ends fixed. */
1861 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
1862 flag_section_anchors = 1;
1865 /* Implement TARGET_HANDLE_OPTION. */
1868 rs6000_handle_option (size_t code, const char *arg, int value)
1873 target_flags &= ~(MASK_POWER | MASK_POWER2
1874 | MASK_MULTIPLE | MASK_STRING);
1875 target_flags_explicit |= (MASK_POWER | MASK_POWER2
1876 | MASK_MULTIPLE | MASK_STRING);
1878 case OPT_mno_powerpc:
1879 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
1880 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1881 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
1882 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1885 target_flags &= ~MASK_MINIMAL_TOC;
1886 TARGET_NO_FP_IN_TOC = 0;
1887 TARGET_NO_SUM_IN_TOC = 0;
1888 target_flags_explicit |= MASK_MINIMAL_TOC;
1889 #ifdef TARGET_USES_SYSV4_OPT
1890 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
1891 just the same as -mminimal-toc. */
1892 target_flags |= MASK_MINIMAL_TOC;
1893 target_flags_explicit |= MASK_MINIMAL_TOC;
1897 #ifdef TARGET_USES_SYSV4_OPT
1899 /* Make -mtoc behave like -mminimal-toc. */
1900 target_flags |= MASK_MINIMAL_TOC;
1901 target_flags_explicit |= MASK_MINIMAL_TOC;
1905 #ifdef TARGET_USES_AIX64_OPT
1910 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
1911 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
1912 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
1915 #ifdef TARGET_USES_AIX64_OPT
1920 target_flags &= ~MASK_POWERPC64;
1921 target_flags_explicit |= MASK_POWERPC64;
1924 case OPT_minsert_sched_nops_:
1925 rs6000_sched_insert_nops_str = arg;
1928 case OPT_mminimal_toc:
1931 TARGET_NO_FP_IN_TOC = 0;
1932 TARGET_NO_SUM_IN_TOC = 0;
1939 target_flags |= (MASK_MULTIPLE | MASK_STRING);
1940 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
1947 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1948 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1952 case OPT_mpowerpc_gpopt:
1953 case OPT_mpowerpc_gfxopt:
1956 target_flags |= MASK_POWERPC;
1957 target_flags_explicit |= MASK_POWERPC;
1961 case OPT_maix_struct_return:
1962 case OPT_msvr4_struct_return:
1963 rs6000_explicit_options.aix_struct_ret = true;
1967 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
1971 rs6000_explicit_options.isel = true;
1972 rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
1976 rs6000_explicit_options.spe = true;
1977 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
1981 rs6000_debug_name = arg;
1984 #ifdef TARGET_USES_SYSV4_OPT
1986 rs6000_abi_name = arg;
1990 rs6000_sdata_name = arg;
1993 case OPT_mtls_size_:
1994 rs6000_tls_size_string = arg;
1997 case OPT_mrelocatable:
2000 target_flags |= MASK_MINIMAL_TOC;
2001 target_flags_explicit |= MASK_MINIMAL_TOC;
2002 TARGET_NO_FP_IN_TOC = 1;
2006 case OPT_mrelocatable_lib:
2009 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2010 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2011 TARGET_NO_FP_IN_TOC = 1;
2015 target_flags &= ~MASK_RELOCATABLE;
2016 target_flags_explicit |= MASK_RELOCATABLE;
2022 if (!strcmp (arg, "altivec"))
2024 rs6000_explicit_options.abi = true;
2025 rs6000_altivec_abi = 1;
2028 else if (! strcmp (arg, "no-altivec"))
2030 /* ??? Don't set rs6000_explicit_options.abi here, to allow
2031 the default for rs6000_spe_abi to be chosen later. */
2032 rs6000_altivec_abi = 0;
2034 else if (! strcmp (arg, "spe"))
2036 rs6000_explicit_options.abi = true;
2038 rs6000_altivec_abi = 0;
2039 if (!TARGET_SPE_ABI)
2040 error ("not configured for ABI: '%s'", arg);
2042 else if (! strcmp (arg, "no-spe"))
2044 rs6000_explicit_options.abi = true;
2048 /* These are here for testing during development only, do not
2049 document in the manual please. */
2050 else if (! strcmp (arg, "d64"))
2052 rs6000_darwin64_abi = 1;
2053 warning (0, "Using darwin64 ABI");
2055 else if (! strcmp (arg, "d32"))
2057 rs6000_darwin64_abi = 0;
2058 warning (0, "Using old darwin ABI");
2061 else if (! strcmp (arg, "ibmlongdouble"))
2063 rs6000_explicit_options.ieee = true;
2064 rs6000_ieeequad = 0;
2065 warning (0, "Using IBM extended precision long double");
2067 else if (! strcmp (arg, "ieeelongdouble"))
2069 rs6000_explicit_options.ieee = true;
2070 rs6000_ieeequad = 1;
2071 warning (0, "Using IEEE extended precision long double");
2076 error ("unknown ABI specified: '%s'", arg);
2082 rs6000_select[1].string = arg;
2086 rs6000_select[2].string = arg;
2089 case OPT_mtraceback_:
2090 rs6000_traceback_name = arg;
2093 case OPT_mfloat_gprs_:
2094 rs6000_explicit_options.float_gprs = true;
2095 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
2096 rs6000_float_gprs = 1;
2097 else if (! strcmp (arg, "double"))
2098 rs6000_float_gprs = 2;
2099 else if (! strcmp (arg, "no"))
2100 rs6000_float_gprs = 0;
2103 error ("invalid option for -mfloat-gprs: '%s'", arg);
2108 case OPT_mlong_double_:
2109 rs6000_explicit_options.long_double = true;
2110 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2111 if (value != 64 && value != 128)
2113 error ("Unknown switch -mlong-double-%s", arg);
2114 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2118 rs6000_long_double_type_size = value;
2121 case OPT_msched_costly_dep_:
2122 rs6000_sched_costly_dep_str = arg;
2126 rs6000_explicit_options.alignment = true;
2127 if (! strcmp (arg, "power"))
2129 /* On 64-bit Darwin, power alignment is ABI-incompatible with
2130 some C library functions, so warn about it. The flag may be
2131 useful for performance studies from time to time though, so
2132 don't disable it entirely. */
2133 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2134 warning (0, "-malign-power is not supported for 64-bit Darwin;"
2135 " it is incompatible with the installed C and C++ libraries");
2136 rs6000_alignment_flags = MASK_ALIGN_POWER;
2138 else if (! strcmp (arg, "natural"))
2139 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2142 error ("unknown -malign-XXXXX option specified: '%s'", arg);
2150 /* Do anything needed at the start of the asm file. */
2153 rs6000_file_start (void)
2157 const char *start = buffer;
2158 struct rs6000_cpu_select *ptr;
2159 const char *default_cpu = TARGET_CPU_DEFAULT;
2160 FILE *file = asm_out_file;
2162 default_file_start ();
2164 #ifdef TARGET_BI_ARCH
2165 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
2169 if (flag_verbose_asm)
2171 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
2172 rs6000_select[0].string = default_cpu;
2174 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2176 ptr = &rs6000_select[i];
2177 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2179 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
2184 if (PPC405_ERRATUM77)
2186 fprintf (file, "%s PPC405CR_ERRATUM77", start);
2190 #ifdef USING_ELFOS_H
2191 switch (rs6000_sdata)
2193 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
2194 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
2195 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
2196 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
2199 if (rs6000_sdata && g_switch_value)
2201 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
2211 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
2213 switch_to_section (toc_section);
2214 switch_to_section (text_section);
2219 /* Return nonzero if this function is known to have a null epilogue. */
2222 direct_return (void)
2224 if (reload_completed)
2226 rs6000_stack_t *info = rs6000_stack_info ();
2228 if (info->first_gp_reg_save == 32
2229 && info->first_fp_reg_save == 64
2230 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
2231 && ! info->lr_save_p
2232 && ! info->cr_save_p
2233 && info->vrsave_mask == 0
2241 /* Return the number of instructions it takes to form a constant in an
2242 integer register. */
2245 num_insns_constant_wide (HOST_WIDE_INT value)
2247 /* signed constant loadable with {cal|addi} */
2248 if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000)
2251 /* constant loadable with {cau|addis} */
2252 else if ((value & 0xffff) == 0
2253 && (value >> 31 == -1 || value >> 31 == 0))
2256 #if HOST_BITS_PER_WIDE_INT == 64
2257 else if (TARGET_POWERPC64)
2259 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
2260 HOST_WIDE_INT high = value >> 31;
2262 if (high == 0 || high == -1)
2268 return num_insns_constant_wide (high) + 1;
2270 return (num_insns_constant_wide (high)
2271 + num_insns_constant_wide (low) + 1);
2280 num_insns_constant (rtx op, enum machine_mode mode)
2282 HOST_WIDE_INT low, high;
2284 switch (GET_CODE (op))
2287 #if HOST_BITS_PER_WIDE_INT == 64
2288 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
2289 && mask64_operand (op, mode))
2293 return num_insns_constant_wide (INTVAL (op));
2301 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2302 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
2303 return num_insns_constant_wide ((HOST_WIDE_INT) l);
2306 if (mode == VOIDmode || mode == DImode)
2308 high = CONST_DOUBLE_HIGH (op);
2309 low = CONST_DOUBLE_LOW (op);
2316 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2317 if (DECIMAL_FLOAT_MODE_P (mode))
2318 REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
2320 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
2321 high = l[WORDS_BIG_ENDIAN == 0];
2322 low = l[WORDS_BIG_ENDIAN != 0];
2326 return (num_insns_constant_wide (low)
2327 + num_insns_constant_wide (high));
2330 if ((high == 0 && low >= 0)
2331 || (high == -1 && low < 0))
2332 return num_insns_constant_wide (low);
2334 else if (mask64_operand (op, mode))
2338 return num_insns_constant_wide (high) + 1;
2341 return (num_insns_constant_wide (high)
2342 + num_insns_constant_wide (low) + 1);
2350 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
2351 If the mode of OP is MODE_VECTOR_INT, this simply returns the
2352 corresponding element of the vector, but for V4SFmode and V2SFmode,
2353 the corresponding "float" is interpreted as an SImode integer. */
2355 static HOST_WIDE_INT
2356 const_vector_elt_as_int (rtx op, unsigned int elt)
2358 rtx tmp = CONST_VECTOR_ELT (op, elt);
2359 if (GET_MODE (op) == V4SFmode
2360 || GET_MODE (op) == V2SFmode)
2361 tmp = gen_lowpart (SImode, tmp);
2362 return INTVAL (tmp);
2365 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
2366 or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used
2367 depends on STEP and COPIES, one of which will be 1. If COPIES > 1,
2368 all items are set to the same value and contain COPIES replicas of the
2369 vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's
2370 operand and the others are set to the value of the operand's msb. */
2373 vspltis_constant (rtx op, unsigned step, unsigned copies)
2375 enum machine_mode mode = GET_MODE (op);
2376 enum machine_mode inner = GET_MODE_INNER (mode);
2379 unsigned nunits = GET_MODE_NUNITS (mode);
2380 unsigned bitsize = GET_MODE_BITSIZE (inner);
2381 unsigned mask = GET_MODE_MASK (inner);
2383 HOST_WIDE_INT val = const_vector_elt_as_int (op, nunits - 1);
2384 HOST_WIDE_INT splat_val = val;
2385 HOST_WIDE_INT msb_val = val > 0 ? 0 : -1;
2387 /* Construct the value to be splatted, if possible. If not, return 0. */
2388 for (i = 2; i <= copies; i *= 2)
2390 HOST_WIDE_INT small_val;
2392 small_val = splat_val >> bitsize;
2394 if (splat_val != ((small_val << bitsize) | (small_val & mask)))
2396 splat_val = small_val;
2399 /* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */
2400 if (EASY_VECTOR_15 (splat_val))
2403 /* Also check if we can splat, and then add the result to itself. Do so if
2404 the value is positive, of if the splat instruction is using OP's mode;
2405 for splat_val < 0, the splat and the add should use the same mode. */
2406 else if (EASY_VECTOR_15_ADD_SELF (splat_val)
2407 && (splat_val >= 0 || (step == 1 && copies == 1)))
2413 /* Check if VAL is present in every STEP-th element, and the
2414 other elements are filled with its most significant bit. */
2415 for (i = 0; i < nunits - 1; ++i)
2417 HOST_WIDE_INT desired_val;
2418 if (((i + 1) & (step - 1)) == 0)
2421 desired_val = msb_val;
2423 if (desired_val != const_vector_elt_as_int (op, i))
2431 /* Return true if OP is of the given MODE and can be synthesized
2432 with a vspltisb, vspltish or vspltisw. */
2435 easy_altivec_constant (rtx op, enum machine_mode mode)
2437 unsigned step, copies;
2439 if (mode == VOIDmode)
2440 mode = GET_MODE (op);
2441 else if (mode != GET_MODE (op))
2444 /* Start with a vspltisw. */
2445 step = GET_MODE_NUNITS (mode) / 4;
2448 if (vspltis_constant (op, step, copies))
2451 /* Then try with a vspltish. */
2457 if (vspltis_constant (op, step, copies))
2460 /* And finally a vspltisb. */
2466 if (vspltis_constant (op, step, copies))
2472 /* Generate a VEC_DUPLICATE representing a vspltis[bhw] instruction whose
2473 result is OP. Abort if it is not possible. */
2476 gen_easy_altivec_constant (rtx op)
2478 enum machine_mode mode = GET_MODE (op);
2479 int nunits = GET_MODE_NUNITS (mode);
2480 rtx last = CONST_VECTOR_ELT (op, nunits - 1);
2481 unsigned step = nunits / 4;
2482 unsigned copies = 1;
2484 /* Start with a vspltisw. */
2485 if (vspltis_constant (op, step, copies))
2486 return gen_rtx_VEC_DUPLICATE (V4SImode, gen_lowpart (SImode, last));
2488 /* Then try with a vspltish. */
2494 if (vspltis_constant (op, step, copies))
2495 return gen_rtx_VEC_DUPLICATE (V8HImode, gen_lowpart (HImode, last));
2497 /* And finally a vspltisb. */
2503 if (vspltis_constant (op, step, copies))
2504 return gen_rtx_VEC_DUPLICATE (V16QImode, gen_lowpart (QImode, last));
2510 output_vec_const_move (rtx *operands)
2513 enum machine_mode mode;
2518 mode = GET_MODE (dest);
2523 if (zero_constant (vec, mode))
2524 return "vxor %0,%0,%0";
2526 splat_vec = gen_easy_altivec_constant (vec);
2527 gcc_assert (GET_CODE (splat_vec) == VEC_DUPLICATE);
2528 operands[1] = XEXP (splat_vec, 0);
2529 if (!EASY_VECTOR_15 (INTVAL (operands[1])))
2532 switch (GET_MODE (splat_vec))
2535 return "vspltisw %0,%1";
2538 return "vspltish %0,%1";
2541 return "vspltisb %0,%1";
2548 gcc_assert (TARGET_SPE);
2550 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2551 pattern of V1DI, V4HI, and V2SF.
2553 FIXME: We should probably return # and add post reload
2554 splitters for these, but this way is so easy ;-). */
2555 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2556 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
2557 operands[1] = CONST_VECTOR_ELT (vec, 0);
2558 operands[2] = CONST_VECTOR_ELT (vec, 1);
2560 return "li %0,%1\n\tevmergelo %0,%0,%0";
2562 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
2565 /* Initialize vector TARGET to VALS. */
2568 rs6000_expand_vector_init (rtx target, rtx vals)
2570 enum machine_mode mode = GET_MODE (target);
2571 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2572 int n_elts = GET_MODE_NUNITS (mode);
2573 int n_var = 0, one_var = -1;
2574 bool all_same = true, all_const_zero = true;
2578 for (i = 0; i < n_elts; ++i)
2580 x = XVECEXP (vals, 0, i);
2581 if (!CONSTANT_P (x))
2582 ++n_var, one_var = i;
2583 else if (x != CONST0_RTX (inner_mode))
2584 all_const_zero = false;
2586 if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0)))
2592 if (mode != V4SFmode && all_const_zero)
2594 /* Zero register. */
2595 emit_insn (gen_rtx_SET (VOIDmode, target,
2596 gen_rtx_XOR (mode, target, target)));
2599 else if (mode != V4SFmode && easy_vector_constant (vals, mode))
2601 /* Splat immediate. */
2602 emit_insn (gen_rtx_SET (VOIDmode, target, vals));
2606 ; /* Splat vector element. */
2609 /* Load from constant pool. */
2610 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
2615 /* Store value to stack temp. Load vector element. Splat. */
2618 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2619 emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
2620 XVECEXP (vals, 0, 0));
2621 x = gen_rtx_UNSPEC (VOIDmode,
2622 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2623 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2625 gen_rtx_SET (VOIDmode,
2628 x = gen_rtx_VEC_SELECT (inner_mode, target,
2629 gen_rtx_PARALLEL (VOIDmode,
2630 gen_rtvec (1, const0_rtx)));
2631 emit_insn (gen_rtx_SET (VOIDmode, target,
2632 gen_rtx_VEC_DUPLICATE (mode, x)));
2636 /* One field is non-constant. Load constant then overwrite
2640 rtx copy = copy_rtx (vals);
2642 /* Load constant part of vector, substitute neighboring value for
2644 XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts);
2645 rs6000_expand_vector_init (target, copy);
2647 /* Insert variable. */
2648 rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), one_var);
2652 /* Construct the vector in memory one field at a time
2653 and load the whole vector. */
2654 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2655 for (i = 0; i < n_elts; i++)
2656 emit_move_insn (adjust_address_nv (mem, inner_mode,
2657 i * GET_MODE_SIZE (inner_mode)),
2658 XVECEXP (vals, 0, i));
2659 emit_move_insn (target, mem);
2662 /* Set field ELT of TARGET to VAL. */
2665 rs6000_expand_vector_set (rtx target, rtx val, int elt)
2667 enum machine_mode mode = GET_MODE (target);
2668 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2669 rtx reg = gen_reg_rtx (mode);
2671 int width = GET_MODE_SIZE (inner_mode);
2674 /* Load single variable value. */
2675 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2676 emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val);
2677 x = gen_rtx_UNSPEC (VOIDmode,
2678 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2679 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2681 gen_rtx_SET (VOIDmode,
2685 /* Linear sequence. */
2686 mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
2687 for (i = 0; i < 16; ++i)
2688 XVECEXP (mask, 0, i) = GEN_INT (i);
2690 /* Set permute mask to insert element into target. */
2691 for (i = 0; i < width; ++i)
2692 XVECEXP (mask, 0, elt*width + i)
2693 = GEN_INT (i + 0x10);
2694 x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
2695 x = gen_rtx_UNSPEC (mode,
2696 gen_rtvec (3, target, reg,
2697 force_reg (V16QImode, x)),
2699 emit_insn (gen_rtx_SET (VOIDmode, target, x));
2702 /* Extract field ELT from VEC into TARGET. */
2705 rs6000_expand_vector_extract (rtx target, rtx vec, int elt)
2707 enum machine_mode mode = GET_MODE (vec);
2708 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2711 /* Allocate mode-sized buffer. */
2712 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2714 /* Add offset to field within buffer matching vector element. */
2715 mem = adjust_address_nv (mem, mode, elt * GET_MODE_SIZE (inner_mode));
2717 /* Store single field into mode-sized buffer. */
2718 x = gen_rtx_UNSPEC (VOIDmode,
2719 gen_rtvec (1, const0_rtx), UNSPEC_STVE);
2720 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2722 gen_rtx_SET (VOIDmode,
2725 emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0));
2728 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
2729 implement ANDing by the mask IN. */
2731 build_mask64_2_operands (rtx in, rtx *out)
2733 #if HOST_BITS_PER_WIDE_INT >= 64
2734 unsigned HOST_WIDE_INT c, lsb, m1, m2;
2737 gcc_assert (GET_CODE (in) == CONST_INT);
2742 /* Assume c initially something like 0x00fff000000fffff. The idea
2743 is to rotate the word so that the middle ^^^^^^ group of zeros
2744 is at the MS end and can be cleared with an rldicl mask. We then
2745 rotate back and clear off the MS ^^ group of zeros with a
2747 c = ~c; /* c == 0xff000ffffff00000 */
2748 lsb = c & -c; /* lsb == 0x0000000000100000 */
2749 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
2750 c = ~c; /* c == 0x00fff000000fffff */
2751 c &= -lsb; /* c == 0x00fff00000000000 */
2752 lsb = c & -c; /* lsb == 0x0000100000000000 */
2753 c = ~c; /* c == 0xff000fffffffffff */
2754 c &= -lsb; /* c == 0xff00000000000000 */
2756 while ((lsb >>= 1) != 0)
2757 shift++; /* shift == 44 on exit from loop */
2758 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
2759 m1 = ~m1; /* m1 == 0x000000ffffffffff */
2760 m2 = ~c; /* m2 == 0x00ffffffffffffff */
2764 /* Assume c initially something like 0xff000f0000000000. The idea
2765 is to rotate the word so that the ^^^ middle group of zeros
2766 is at the LS end and can be cleared with an rldicr mask. We then
2767 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
2769 lsb = c & -c; /* lsb == 0x0000010000000000 */
2770 m2 = -lsb; /* m2 == 0xffffff0000000000 */
2771 c = ~c; /* c == 0x00fff0ffffffffff */
2772 c &= -lsb; /* c == 0x00fff00000000000 */
2773 lsb = c & -c; /* lsb == 0x0000100000000000 */
2774 c = ~c; /* c == 0xff000fffffffffff */
2775 c &= -lsb; /* c == 0xff00000000000000 */
2777 while ((lsb >>= 1) != 0)
2778 shift++; /* shift == 44 on exit from loop */
2779 m1 = ~c; /* m1 == 0x00ffffffffffffff */
2780 m1 >>= shift; /* m1 == 0x0000000000000fff */
2781 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
2784 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
2785 masks will be all 1's. We are guaranteed more than one transition. */
2786 out[0] = GEN_INT (64 - shift);
2787 out[1] = GEN_INT (m1);
2788 out[2] = GEN_INT (shift);
2789 out[3] = GEN_INT (m2);
2797 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
2800 invalid_e500_subreg (rtx op, enum machine_mode mode)
2802 if (TARGET_E500_DOUBLE)
2804 /* Reject (subreg:SI (reg:DF)); likewise with subreg:DI or
2805 subreg:TI and reg:TF. */
2806 if (GET_CODE (op) == SUBREG
2807 && (mode == SImode || mode == DImode || mode == TImode)
2808 && REG_P (SUBREG_REG (op))
2809 && (GET_MODE (SUBREG_REG (op)) == DFmode
2810 || GET_MODE (SUBREG_REG (op)) == TFmode))
2813 /* Reject (subreg:DF (reg:DI)); likewise with subreg:TF and
2815 if (GET_CODE (op) == SUBREG
2816 && (mode == DFmode || mode == TFmode)
2817 && REG_P (SUBREG_REG (op))
2818 && (GET_MODE (SUBREG_REG (op)) == DImode
2819 || GET_MODE (SUBREG_REG (op)) == TImode))
2824 && GET_CODE (op) == SUBREG
2826 && REG_P (SUBREG_REG (op))
2827 && SPE_VECTOR_MODE (GET_MODE (SUBREG_REG (op))))
2833 /* AIX increases natural record alignment to doubleword if the first
2834 field is an FP double while the FP fields remain word aligned. */
2837 rs6000_special_round_type_align (tree type, unsigned int computed,
2838 unsigned int specified)
2840 unsigned int align = MAX (computed, specified);
2841 tree field = TYPE_FIELDS (type);
2843 /* Skip all non field decls */
2844 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2845 field = TREE_CHAIN (field);
2847 if (field != NULL && field != type)
2849 type = TREE_TYPE (field);
2850 while (TREE_CODE (type) == ARRAY_TYPE)
2851 type = TREE_TYPE (type);
2853 if (type != error_mark_node && TYPE_MODE (type) == DFmode)
2854 align = MAX (align, 64);
2860 /* Darwin increases record alignment to the natural alignment of
2864 darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
2865 unsigned int specified)
2867 unsigned int align = MAX (computed, specified);
2869 if (TYPE_PACKED (type))
2872 /* Find the first field, looking down into aggregates. */
2874 tree field = TYPE_FIELDS (type);
2875 /* Skip all non field decls */
2876 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2877 field = TREE_CHAIN (field);
2880 type = TREE_TYPE (field);
2881 while (TREE_CODE (type) == ARRAY_TYPE)
2882 type = TREE_TYPE (type);
2883 } while (AGGREGATE_TYPE_P (type));
2885 if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
2886 align = MAX (align, TYPE_ALIGN (type));
2891 /* Return 1 for an operand in small memory on V.4/eabi. */
2894 small_data_operand (rtx op ATTRIBUTE_UNUSED,
2895 enum machine_mode mode ATTRIBUTE_UNUSED)
2900 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
2903 if (DEFAULT_ABI != ABI_V4)
2906 if (GET_CODE (op) == SYMBOL_REF)
2909 else if (GET_CODE (op) != CONST
2910 || GET_CODE (XEXP (op, 0)) != PLUS
2911 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
2912 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
2917 rtx sum = XEXP (op, 0);
2918 HOST_WIDE_INT summand;
2920 /* We have to be careful here, because it is the referenced address
2921 that must be 32k from _SDA_BASE_, not just the symbol. */
2922 summand = INTVAL (XEXP (sum, 1));
2923 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
2926 sym_ref = XEXP (sum, 0);
2929 return SYMBOL_REF_SMALL_P (sym_ref);
2935 /* Return true if either operand is a general purpose register. */
2938 gpr_or_gpr_p (rtx op0, rtx op1)
2940 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
2941 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
2945 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
2948 constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
2950 switch (GET_CODE (op))
2953 if (RS6000_SYMBOL_REF_TLS_P (op))
2955 else if (CONSTANT_POOL_ADDRESS_P (op))
2957 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
2965 else if (! strcmp (XSTR (op, 0), toc_label_name))
2974 return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
2975 && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
2977 return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
2986 constant_pool_expr_p (rtx op)
2990 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
2994 toc_relative_expr_p (rtx op)
2998 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
3002 legitimate_constant_pool_address_p (rtx x)
3005 && GET_CODE (x) == PLUS
3006 && GET_CODE (XEXP (x, 0)) == REG
3007 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
3008 && constant_pool_expr_p (XEXP (x, 1)));
3012 legitimate_small_data_p (enum machine_mode mode, rtx x)
3014 return (DEFAULT_ABI == ABI_V4
3015 && !flag_pic && !TARGET_TOC
3016 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
3017 && small_data_operand (x, mode));
3020 /* SPE offset addressing is limited to 5-bits worth of double words. */
3021 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
3024 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
3026 unsigned HOST_WIDE_INT offset, extra;
3028 if (GET_CODE (x) != PLUS)
3030 if (GET_CODE (XEXP (x, 0)) != REG)
3032 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3034 if (legitimate_constant_pool_address_p (x))
3036 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3039 offset = INTVAL (XEXP (x, 1));
3047 /* AltiVec vector modes. Only reg+reg addressing is valid and
3048 constant offset zero should not occur due to canonicalization.
3049 Allow any offset when not strict before reload. */
3056 /* SPE vector modes. */
3057 return SPE_CONST_OFFSET_OK (offset);
3061 if (TARGET_E500_DOUBLE)
3062 return SPE_CONST_OFFSET_OK (offset);
3065 /* On e500v2, we may have:
3067 (subreg:DF (mem:DI (plus (reg) (const_int))) 0).
3069 Which gets addressed with evldd instructions. */
3070 if (TARGET_E500_DOUBLE)
3071 return SPE_CONST_OFFSET_OK (offset);
3073 if (mode == DFmode || mode == DDmode || !TARGET_POWERPC64)
3075 else if (offset & 3)
3080 if (TARGET_E500_DOUBLE)
3081 return (SPE_CONST_OFFSET_OK (offset)
3082 && SPE_CONST_OFFSET_OK (offset + 8));
3086 if (mode == TFmode || mode == TDmode || !TARGET_POWERPC64)
3088 else if (offset & 3)
3099 return (offset < 0x10000) && (offset + extra < 0x10000);
3103 legitimate_indexed_address_p (rtx x, int strict)
3107 if (GET_CODE (x) != PLUS)
3113 /* Recognize the rtl generated by reload which we know will later be
3114 replaced with proper base and index regs. */
3116 && reload_in_progress
3117 && (REG_P (op0) || GET_CODE (op0) == PLUS)
3121 return (REG_P (op0) && REG_P (op1)
3122 && ((INT_REG_OK_FOR_BASE_P (op0, strict)
3123 && INT_REG_OK_FOR_INDEX_P (op1, strict))
3124 || (INT_REG_OK_FOR_BASE_P (op1, strict)
3125 && INT_REG_OK_FOR_INDEX_P (op0, strict))));
3129 legitimate_indirect_address_p (rtx x, int strict)
3131 return GET_CODE (x) == REG && INT_REG_OK_FOR_BASE_P (x, strict);
3135 macho_lo_sum_memory_operand (rtx x, enum machine_mode mode)
3137 if (!TARGET_MACHO || !flag_pic
3138 || mode != SImode || GET_CODE (x) != MEM)
3142 if (GET_CODE (x) != LO_SUM)
3144 if (GET_CODE (XEXP (x, 0)) != REG)
3146 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0))
3150 return CONSTANT_P (x);
3154 legitimate_lo_sum_address_p (enum machine_mode mode, rtx x, int strict)
3156 if (GET_CODE (x) != LO_SUM)
3158 if (GET_CODE (XEXP (x, 0)) != REG)
3160 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3162 /* Restrict addressing for DI because of our SUBREG hackery. */
3163 if (TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3168 if (TARGET_ELF || TARGET_MACHO)
3170 if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
3174 if (GET_MODE_NUNITS (mode) != 1)
3176 if (GET_MODE_BITSIZE (mode) > 64
3177 || (GET_MODE_BITSIZE (mode) > 32 && !TARGET_POWERPC64
3178 && !(TARGET_HARD_FLOAT && TARGET_FPRS && mode == DFmode)))
3181 return CONSTANT_P (x);
3188 /* Try machine-dependent ways of modifying an illegitimate address
3189 to be legitimate. If we find one, return the new, valid address.
3190 This is used from only one place: `memory_address' in explow.c.
3192 OLDX is the address as it was before break_out_memory_refs was
3193 called. In some cases it is useful to look at this to decide what
3196 MODE is passed so that this function can use GO_IF_LEGITIMATE_ADDRESS.
3198 It is always safe for this function to do nothing. It exists to
3199 recognize opportunities to optimize the output.
3201 On RS/6000, first check for the sum of a register with a constant
3202 integer that is out of range. If so, generate code to add the
3203 constant with the low-order 16 bits masked to the register and force
3204 this result into another register (this can be done with `cau').
3205 Then generate an address of REG+(CONST&0xffff), allowing for the
3206 possibility of bit 16 being a one.
3208 Then check for the sum of a register and something not constant, try to
3209 load the other things into a register and return the sum. */
3212 rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
3213 enum machine_mode mode)
3215 if (GET_CODE (x) == SYMBOL_REF)
3217 enum tls_model model = SYMBOL_REF_TLS_MODEL (x);
3219 return rs6000_legitimize_tls_address (x, model);
3222 if (GET_CODE (x) == PLUS
3223 && GET_CODE (XEXP (x, 0)) == REG
3224 && GET_CODE (XEXP (x, 1)) == CONST_INT
3225 && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) >= 0x10000)
3227 HOST_WIDE_INT high_int, low_int;
3229 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
3230 high_int = INTVAL (XEXP (x, 1)) - low_int;
3231 sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0),
3232 GEN_INT (high_int)), 0);
3233 return gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));
3235 else if (GET_CODE (x) == PLUS
3236 && GET_CODE (XEXP (x, 0)) == REG
3237 && GET_CODE (XEXP (x, 1)) != CONST_INT
3238 && GET_MODE_NUNITS (mode) == 1
3239 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3241 || (((mode != DImode && mode != DFmode && mode != DDmode)
3242 || TARGET_E500_DOUBLE)
3243 && mode != TFmode && mode != TDmode))
3244 && (TARGET_POWERPC64 || mode != DImode)
3247 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
3248 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
3250 else if (ALTIVEC_VECTOR_MODE (mode))
3254 /* Make sure both operands are registers. */
3255 if (GET_CODE (x) == PLUS)
3256 return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)),
3257 force_reg (Pmode, XEXP (x, 1)));
3259 reg = force_reg (Pmode, x);
3262 else if (SPE_VECTOR_MODE (mode)
3263 || (TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3264 || mode == DDmode || mode == TDmode
3265 || mode == DImode)))
3269 /* We accept [reg + reg] and [reg + OFFSET]. */
3271 if (GET_CODE (x) == PLUS)
3273 rtx op1 = XEXP (x, 0);
3274 rtx op2 = XEXP (x, 1);
3276 op1 = force_reg (Pmode, op1);
3278 if (GET_CODE (op2) != REG
3279 && (GET_CODE (op2) != CONST_INT
3280 || !SPE_CONST_OFFSET_OK (INTVAL (op2))))
3281 op2 = force_reg (Pmode, op2);
3283 return gen_rtx_PLUS (Pmode, op1, op2);
3286 return force_reg (Pmode, x);
3292 && GET_CODE (x) != CONST_INT
3293 && GET_CODE (x) != CONST_DOUBLE
3295 && GET_MODE_NUNITS (mode) == 1
3296 && (GET_MODE_BITSIZE (mode) <= 32
3297 || ((TARGET_HARD_FLOAT && TARGET_FPRS) && mode == DFmode)))
3299 rtx reg = gen_reg_rtx (Pmode);
3300 emit_insn (gen_elf_high (reg, x));
3301 return gen_rtx_LO_SUM (Pmode, reg, x);
3303 else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
3306 && ! MACHO_DYNAMIC_NO_PIC_P
3308 && GET_CODE (x) != CONST_INT
3309 && GET_CODE (x) != CONST_DOUBLE
3311 && ((TARGET_HARD_FLOAT && TARGET_FPRS) || mode != DFmode)
3315 rtx reg = gen_reg_rtx (Pmode);
3316 emit_insn (gen_macho_high (reg, x));
3317 return gen_rtx_LO_SUM (Pmode, reg, x);
3320 && constant_pool_expr_p (x)
3321 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
3323 return create_TOC_reference (x);
3329 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
3330 We need to emit DTP-relative relocations. */
3333 rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
3338 fputs ("\t.long\t", file);
3341 fputs (DOUBLE_INT_ASM_OP, file);
3346 output_addr_const (file, x);
3347 fputs ("@dtprel+0x8000", file);
3350 /* Construct the SYMBOL_REF for the tls_get_addr function. */
3352 static GTY(()) rtx rs6000_tls_symbol;
3354 rs6000_tls_get_addr (void)
3356 if (!rs6000_tls_symbol)
3357 rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr");
3359 return rs6000_tls_symbol;
3362 /* Construct the SYMBOL_REF for TLS GOT references. */
3364 static GTY(()) rtx rs6000_got_symbol;
3366 rs6000_got_sym (void)
3368 if (!rs6000_got_symbol)
3370 rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
3371 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL;
3372 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL;
3375 return rs6000_got_symbol;
3378 /* ADDR contains a thread-local SYMBOL_REF. Generate code to compute
3379 this (thread-local) address. */
3382 rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
3386 dest = gen_reg_rtx (Pmode);
3387 if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 16)
3393 tlsreg = gen_rtx_REG (Pmode, 13);
3394 insn = gen_tls_tprel_64 (dest, tlsreg, addr);
3398 tlsreg = gen_rtx_REG (Pmode, 2);
3399 insn = gen_tls_tprel_32 (dest, tlsreg, addr);
3403 else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32)
3407 tmp = gen_reg_rtx (Pmode);
3410 tlsreg = gen_rtx_REG (Pmode, 13);
3411 insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr);
3415 tlsreg = gen_rtx_REG (Pmode, 2);
3416 insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr);
3420 insn = gen_tls_tprel_lo_64 (dest, tmp, addr);
3422 insn = gen_tls_tprel_lo_32 (dest, tmp, addr);
3427 rtx r3, got, tga, tmp1, tmp2, eqv;
3429 /* We currently use relocations like @got@tlsgd for tls, which
3430 means the linker will handle allocation of tls entries, placing
3431 them in the .got section. So use a pointer to the .got section,
3432 not one to secondary TOC sections used by 64-bit -mminimal-toc,
3433 or to secondary GOT sections used by 32-bit -fPIC. */
3435 got = gen_rtx_REG (Pmode, 2);
3439 got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
3442 rtx gsym = rs6000_got_sym ();
3443 got = gen_reg_rtx (Pmode);
3445 rs6000_emit_move (got, gsym, Pmode);
3451 tmp1 = gen_reg_rtx (Pmode);
3452 tmp2 = gen_reg_rtx (Pmode);
3453 tmp3 = gen_reg_rtx (Pmode);
3454 mem = gen_const_mem (Pmode, tmp1);
3456 first = emit_insn (gen_load_toc_v4_PIC_1b (gsym));
3457 emit_move_insn (tmp1,
3458 gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM));
3459 emit_move_insn (tmp2, mem);
3460 emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
3461 last = emit_move_insn (got, tmp3);
3462 set_unique_reg_note (last, REG_EQUAL, gsym);
3463 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
3465 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
3471 if (model == TLS_MODEL_GLOBAL_DYNAMIC)
3473 r3 = gen_rtx_REG (Pmode, 3);
3475 insn = gen_tls_gd_64 (r3, got, addr);
3477 insn = gen_tls_gd_32 (r3, got, addr);
3480 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3481 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3482 insn = emit_call_insn (insn);
3483 CONST_OR_PURE_CALL_P (insn) = 1;
3484 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3485 insn = get_insns ();
3487 emit_libcall_block (insn, dest, r3, addr);
3489 else if (model == TLS_MODEL_LOCAL_DYNAMIC)
3491 r3 = gen_rtx_REG (Pmode, 3);
3493 insn = gen_tls_ld_64 (r3, got);
3495 insn = gen_tls_ld_32 (r3, got);
3498 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3499 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3500 insn = emit_call_insn (insn);
3501 CONST_OR_PURE_CALL_P (insn) = 1;
3502 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3503 insn = get_insns ();
3505 tmp1 = gen_reg_rtx (Pmode);
3506 eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
3508 emit_libcall_block (insn, tmp1, r3, eqv);
3509 if (rs6000_tls_size == 16)
3512 insn = gen_tls_dtprel_64 (dest, tmp1, addr);
3514 insn = gen_tls_dtprel_32 (dest, tmp1, addr);
3516 else if (rs6000_tls_size == 32)
3518 tmp2 = gen_reg_rtx (Pmode);
3520 insn = gen_tls_dtprel_ha_64 (tmp2, tmp1, addr);
3522 insn = gen_tls_dtprel_ha_32 (tmp2, tmp1, addr);
3525 insn = gen_tls_dtprel_lo_64 (dest, tmp2, addr);
3527 insn = gen_tls_dtprel_lo_32 (dest, tmp2, addr);
3531 tmp2 = gen_reg_rtx (Pmode);
3533 insn = gen_tls_got_dtprel_64 (tmp2, got, addr);
3535 insn = gen_tls_got_dtprel_32 (tmp2, got, addr);
3537 insn = gen_rtx_SET (Pmode, dest,
3538 gen_rtx_PLUS (Pmode, tmp2, tmp1));
3544 /* IE, or 64-bit offset LE. */
3545 tmp2 = gen_reg_rtx (Pmode);
3547 insn = gen_tls_got_tprel_64 (tmp2, got, addr);
3549 insn = gen_tls_got_tprel_32 (tmp2, got, addr);
3552 insn = gen_tls_tls_64 (dest, tmp2, addr);
3554 insn = gen_tls_tls_32 (dest, tmp2, addr);
3562 /* Return 1 if X contains a thread-local symbol. */
3565 rs6000_tls_referenced_p (rtx x)
3567 if (! TARGET_HAVE_TLS)
3570 return for_each_rtx (&x, &rs6000_tls_symbol_ref_1, 0);
3573 /* Return 1 if *X is a thread-local symbol. This is the same as
3574 rs6000_tls_symbol_ref except for the type of the unused argument. */
3577 rs6000_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
3579 return RS6000_SYMBOL_REF_TLS_P (*x);
3582 /* The convention appears to be to define this wherever it is used.
3583 With legitimize_reload_address now defined here, REG_MODE_OK_FOR_BASE_P
3584 is now used here. */
3585 #ifndef REG_MODE_OK_FOR_BASE_P
3586 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
3589 /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS. Returns a value to
3590 replace the input X, or the original X if no replacement is called for.
3591 The output parameter *WIN is 1 if the calling macro should goto WIN,
3594 For RS/6000, we wish to handle large displacements off a base
3595 register by splitting the addend across an addiu/addis and the mem insn.
3596 This cuts number of extra insns needed from 3 to 1.
3598 On Darwin, we use this to generate code for floating point constants.
3599 A movsf_low is generated so we wind up with 2 instructions rather than 3.
3600 The Darwin code is inside #if TARGET_MACHO because only then is
3601 machopic_function_base_name() defined. */
3603 rs6000_legitimize_reload_address (rtx x, enum machine_mode mode,
3604 int opnum, int type,
3605 int ind_levels ATTRIBUTE_UNUSED, int *win)
3607 /* We must recognize output that we have already generated ourselves. */
3608 if (GET_CODE (x) == PLUS
3609 && GET_CODE (XEXP (x, 0)) == PLUS
3610 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3611 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3612 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3614 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3615 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3616 opnum, (enum reload_type)type);
3622 if (DEFAULT_ABI == ABI_DARWIN && flag_pic
3623 && GET_CODE (x) == LO_SUM
3624 && GET_CODE (XEXP (x, 0)) == PLUS
3625 && XEXP (XEXP (x, 0), 0) == pic_offset_table_rtx
3626 && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH
3627 && GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 0)) == CONST
3628 && XEXP (XEXP (XEXP (x, 0), 1), 0) == XEXP (x, 1)
3629 && GET_CODE (XEXP (XEXP (x, 1), 0)) == MINUS
3630 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 0)) == SYMBOL_REF
3631 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 1)) == SYMBOL_REF)
3633 /* Result of previous invocation of this function on Darwin
3634 floating point constant. */
3635 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3636 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3637 opnum, (enum reload_type)type);
3643 /* Force ld/std non-word aligned offset into base register by wrapping
3645 if (GET_CODE (x) == PLUS
3646 && GET_CODE (XEXP (x, 0)) == REG
3647 && REGNO (XEXP (x, 0)) < 32
3648 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3649 && GET_CODE (XEXP (x, 1)) == CONST_INT
3650 && (INTVAL (XEXP (x, 1)) & 3) != 0
3651 && !ALTIVEC_VECTOR_MODE (mode)
3652 && GET_MODE_SIZE (mode) >= UNITS_PER_WORD
3653 && TARGET_POWERPC64)
3655 x = gen_rtx_PLUS (GET_MODE (x), x, GEN_INT (0));
3656 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3657 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3658 opnum, (enum reload_type) type);
3663 if (GET_CODE (x) == PLUS
3664 && GET_CODE (XEXP (x, 0)) == REG
3665 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
3666 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3667 && GET_CODE (XEXP (x, 1)) == CONST_INT
3668 && !SPE_VECTOR_MODE (mode)
3669 && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3671 && !ALTIVEC_VECTOR_MODE (mode))
3673 HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
3674 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
3676 = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;
3678 /* Check for 32-bit overflow. */
3679 if (high + low != val)
3685 /* Reload the high part into a base reg; leave the low part
3686 in the mem directly. */
3688 x = gen_rtx_PLUS (GET_MODE (x),
3689 gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
3693 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3694 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3695 opnum, (enum reload_type)type);
3700 if (GET_CODE (x) == SYMBOL_REF
3701 && !ALTIVEC_VECTOR_MODE (mode)
3702 && !SPE_VECTOR_MODE (mode)
3704 && DEFAULT_ABI == ABI_DARWIN
3705 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
3707 && DEFAULT_ABI == ABI_V4
3710 /* Don't do this for TFmode or TDmode, since the result isn't offsettable.
3711 The same goes for DImode without 64-bit gprs and DFmode
3715 && (mode != DImode || TARGET_POWERPC64)
3716 && (mode != DFmode || TARGET_POWERPC64
3717 || (TARGET_FPRS && TARGET_HARD_FLOAT)))
3722 rtx offset = gen_rtx_CONST (Pmode,
3723 gen_rtx_MINUS (Pmode, x,
3724 machopic_function_base_sym ()));
3725 x = gen_rtx_LO_SUM (GET_MODE (x),
3726 gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
3727 gen_rtx_HIGH (Pmode, offset)), offset);
3731 x = gen_rtx_LO_SUM (GET_MODE (x),
3732 gen_rtx_HIGH (Pmode, x), x);
3734 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3735 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3736 opnum, (enum reload_type)type);
3741 /* Reload an offset address wrapped by an AND that represents the
3742 masking of the lower bits. Strip the outer AND and let reload
3743 convert the offset address into an indirect address. */
3745 && ALTIVEC_VECTOR_MODE (mode)
3746 && GET_CODE (x) == AND
3747 && GET_CODE (XEXP (x, 0)) == PLUS
3748 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3749 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3750 && GET_CODE (XEXP (x, 1)) == CONST_INT
3751 && INTVAL (XEXP (x, 1)) == -16)
3759 && constant_pool_expr_p (x)
3760 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
3762 x = create_TOC_reference (x);
3770 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
3771 that is a valid memory address for an instruction.
3772 The MODE argument is the machine mode for the MEM expression
3773 that wants to use this address.
3775 On the RS/6000, there are four valid address: a SYMBOL_REF that
3776 refers to a constant pool entry of an address (or the sum of it
3777 plus a constant), a short (16-bit signed) constant plus a register,
3778 the sum of two registers, or a register indirect, possibly with an
3779 auto-increment. For DFmode and DImode with a constant plus register,
3780 we must ensure that both words are addressable or PowerPC64 with offset
3783 For modes spanning multiple registers (DFmode in 32-bit GPRs,
3784 32-bit DImode, TImode, TFmode, TDmode), indexed addressing cannot be used
3785 because adjacent memory cells are accessed by adding word-sized offsets
3786 during assembly output. */
3788 rs6000_legitimate_address (enum machine_mode mode, rtx x, int reg_ok_strict)
3790 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */
3792 && ALTIVEC_VECTOR_MODE (mode)
3793 && GET_CODE (x) == AND
3794 && GET_CODE (XEXP (x, 1)) == CONST_INT
3795 && INTVAL (XEXP (x, 1)) == -16)
3798 if (RS6000_SYMBOL_REF_TLS_P (x))
3800 if (legitimate_indirect_address_p (x, reg_ok_strict))
3802 if ((GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
3803 && !ALTIVEC_VECTOR_MODE (mode)
3804 && !SPE_VECTOR_MODE (mode)
3807 /* Restrict addressing for DI because of our SUBREG hackery. */
3808 && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3811 && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict))
3813 if (legitimate_small_data_p (mode, x))
3815 if (legitimate_constant_pool_address_p (x))
3817 /* If not REG_OK_STRICT (before reload) let pass any stack offset. */
3819 && GET_CODE (x) == PLUS
3820 && GET_CODE (XEXP (x, 0)) == REG
3821 && (XEXP (x, 0) == virtual_stack_vars_rtx
3822 || XEXP (x, 0) == arg_pointer_rtx)
3823 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3825 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict))
3830 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3832 || ((mode != DFmode || TARGET_E500_DOUBLE) && mode != TFmode))
3833 && (TARGET_POWERPC64 || mode != DImode)
3834 && legitimate_indexed_address_p (x, reg_ok_strict))
3836 if (legitimate_lo_sum_address_p (mode, x, reg_ok_strict))
3841 /* Go to LABEL if ADDR (a legitimate address expression)
3842 has an effect that depends on the machine mode it is used for.
3844 On the RS/6000 this is true of all integral offsets (since AltiVec
3845 modes don't allow them) or is a pre-increment or decrement.
3847 ??? Except that due to conceptual problems in offsettable_address_p
3848 we can't really report the problems of integral offsets. So leave
3849 this assuming that the adjustable offset must be valid for the
3850 sub-words of a TFmode operand, which is what we had before. */
3853 rs6000_mode_dependent_address (rtx addr)
3855 switch (GET_CODE (addr))
3858 if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
3860 unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
3861 return val + 12 + 0x8000 >= 0x10000;
3868 /* Auto-increment cases are now treated generically in recog.c. */
3877 /* More elaborate version of recog's offsettable_memref_p predicate
3878 that works around the ??? note of rs6000_mode_dependent_address.
3879 In particular it accepts
3881 (mem:DI (plus:SI (reg/f:SI 31 31) (const_int 32760 [0x7ff8])))
3883 in 32-bit mode, that the recog predicate rejects. */
3886 rs6000_offsettable_memref_p (rtx op)
3891 /* First mimic offsettable_memref_p. */
3892 if (offsettable_address_p (1, GET_MODE (op), XEXP (op, 0)))
3895 /* offsettable_address_p invokes rs6000_mode_dependent_address, but
3896 the latter predicate knows nothing about the mode of the memory
3897 reference and, therefore, assumes that it is the largest supported
3898 mode (TFmode). As a consequence, legitimate offsettable memory
3899 references are rejected. rs6000_legitimate_offset_address_p contains
3900 the correct logic for the PLUS case of rs6000_mode_dependent_address. */
3901 return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0), 1);
3904 /* Return number of consecutive hard regs needed starting at reg REGNO
3905 to hold something of mode MODE.
3906 This is ordinarily the length in words of a value of mode MODE
3907 but can be less for certain modes in special long registers.
3909 For the SPE, GPRs are 64 bits but only 32 bits are visible in
3910 scalar instructions. The upper 32 bits are only available to the
3913 POWER and PowerPC GPRs hold 32 bits worth;
3914 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
3917 rs6000_hard_regno_nregs (int regno, enum machine_mode mode)
3919 if (FP_REGNO_P (regno))
3920 return (GET_MODE_SIZE (mode) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD;
3922 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
3923 return (GET_MODE_SIZE (mode) + UNITS_PER_SPE_WORD - 1) / UNITS_PER_SPE_WORD;
3925 if (ALTIVEC_REGNO_P (regno))
3927 (GET_MODE_SIZE (mode) + UNITS_PER_ALTIVEC_WORD - 1) / UNITS_PER_ALTIVEC_WORD;
3929 /* The value returned for SCmode in the E500 double case is 2 for
3930 ABI compatibility; storing an SCmode value in a single register
3931 would require function_arg and rs6000_spe_function_arg to handle
3932 SCmode so as to pass the value correctly in a pair of
3934 if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode)
3935 return (GET_MODE_SIZE (mode) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD;
3937 return (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
3940 /* Change register usage conditional on target flags. */
3942 rs6000_conditional_register_usage (void)
3946 /* Set MQ register fixed (already call_used) if not POWER
3947 architecture (RIOS1, RIOS2, RSC, and PPC601) so that it will not
3952 /* 64-bit AIX and Linux reserve GPR13 for thread-private data. */
3954 fixed_regs[13] = call_used_regs[13]
3955 = call_really_used_regs[13] = 1;
3957 /* Conditionally disable FPRs. */
3958 if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
3959 for (i = 32; i < 64; i++)
3960 fixed_regs[i] = call_used_regs[i]
3961 = call_really_used_regs[i] = 1;
3963 /* The TOC register is not killed across calls in a way that is
3964 visible to the compiler. */
3965 if (DEFAULT_ABI == ABI_AIX)
3966 call_really_used_regs[2] = 0;
3968 if (DEFAULT_ABI == ABI_V4
3969 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3971 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3973 if (DEFAULT_ABI == ABI_V4
3974 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3976 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3977 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3978 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3980 if (DEFAULT_ABI == ABI_DARWIN
3981 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
3982 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3983 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3984 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3986 if (TARGET_TOC && TARGET_MINIMAL_TOC)
3987 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3988 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3991 global_regs[VSCR_REGNO] = 1;
3995 global_regs[SPEFSCR_REGNO] = 1;
3996 fixed_regs[FIXED_SCRATCH]
3997 = call_used_regs[FIXED_SCRATCH]
3998 = call_really_used_regs[FIXED_SCRATCH] = 1;
4001 if (! TARGET_ALTIVEC)
4003 for (i = FIRST_ALTIVEC_REGNO; i <= LAST_ALTIVEC_REGNO; ++i)
4004 fixed_regs[i] = call_used_regs[i] = call_really_used_regs[i] = 1;
4005 call_really_used_regs[VRSAVE_REGNO] = 1;
4008 if (TARGET_ALTIVEC_ABI)
4009 for (i = FIRST_ALTIVEC_REGNO; i < FIRST_ALTIVEC_REGNO + 20; ++i)
4010 call_used_regs[i] = call_really_used_regs[i] = 1;
4013 /* Try to output insns to set TARGET equal to the constant C if it can
4014 be done in less than N insns. Do all computations in MODE.
4015 Returns the place where the output has been placed if it can be
4016 done and the insns have been emitted. If it would take more than N
4017 insns, zero is returned and no insns and emitted. */
4020 rs6000_emit_set_const (rtx dest, enum machine_mode mode,
4021 rtx source, int n ATTRIBUTE_UNUSED)
4023 rtx result, insn, set;
4024 HOST_WIDE_INT c0, c1;