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, 2008, 2009, 2010
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 3, 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 COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
54 #include "sched-int.h"
56 #include "tree-flow.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 GTY(()) machine_function
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;
129 /* Temporary stack slot to use for SDmode copies. This slot is
130 64-bits wide and is allocated early enough so that the offset
131 does not overflow the 16-bit load/store offset field. */
132 rtx sdmode_stack_slot;
135 /* Target cpu type */
137 enum processor_type rs6000_cpu;
138 struct rs6000_cpu_select rs6000_select[3] =
140 /* switch name, tune arch */
141 { (const char *)0, "--with-cpu=", 1, 1 },
142 { (const char *)0, "-mcpu=", 1, 1 },
143 { (const char *)0, "-mtune=", 1, 0 },
146 /* Always emit branch hint bits. */
147 static GTY(()) bool rs6000_always_hint;
149 /* Schedule instructions for group formation. */
150 static GTY(()) bool rs6000_sched_groups;
152 /* Align branch targets. */
153 static GTY(()) bool rs6000_align_branch_targets;
155 /* Support for -msched-costly-dep option. */
156 const char *rs6000_sched_costly_dep_str;
157 enum rs6000_dependence_cost rs6000_sched_costly_dep;
159 /* Support for -minsert-sched-nops option. */
160 const char *rs6000_sched_insert_nops_str;
161 enum rs6000_nop_insertion rs6000_sched_insert_nops;
163 /* Support targetm.vectorize.builtin_mask_for_load. */
164 static GTY(()) tree altivec_builtin_mask_for_load;
166 /* Size of long double. */
167 int rs6000_long_double_type_size;
169 /* IEEE quad extended precision long double. */
172 /* Nonzero to use AltiVec ABI. */
173 int rs6000_altivec_abi;
175 /* Nonzero if we want SPE SIMD instructions. */
178 /* Nonzero if we want SPE ABI extensions. */
181 /* Nonzero if floating point operations are done in the GPRs. */
182 int rs6000_float_gprs = 0;
184 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
185 int rs6000_darwin64_abi;
187 /* Set to nonzero once AIX common-mode calls have been defined. */
188 static GTY(()) int common_mode_defined;
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 */
222 int rs6000_debug_reg; /* debug register classes */
223 int rs6000_debug_addr; /* debug memory addressing */
224 int rs6000_debug_cost; /* debug rtx_costs */
226 /* Specify the machine mode that pointers have. After generation of rtl, the
227 compiler makes no further distinction between pointers and any other objects
228 of this machine mode. The type is unsigned since not all things that
229 include rs6000.h also include machmode.h. */
230 unsigned rs6000_pmode;
232 /* Width in bits of a pointer. */
233 unsigned rs6000_pointer_size;
236 /* Value is TRUE if register/mode pair is acceptable. */
237 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
239 /* Maximum number of registers needed for a given register class and mode. */
240 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
242 /* How many registers are needed for a given register and mode. */
243 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
245 /* Map register number to register class. */
246 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
248 /* Reload functions based on the type and the vector unit. */
249 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
251 /* Built in types. */
252 tree rs6000_builtin_types[RS6000_BTI_MAX];
253 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
255 const char *rs6000_traceback_name;
257 traceback_default = 0,
263 /* Flag to say the TOC is initialized */
265 char toc_label_name[10];
267 /* Cached value of rs6000_variable_issue. This is cached in
268 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
269 static short cached_can_issue_more;
271 static GTY(()) section *read_only_data_section;
272 static GTY(()) section *private_data_section;
273 static GTY(()) section *read_only_private_data_section;
274 static GTY(()) section *sdata2_section;
275 static GTY(()) section *toc_section;
277 /* Control alignment for fields within structures. */
278 /* String from -malign-XXXXX. */
279 int rs6000_alignment_flags;
281 /* True for any options that were explicitly set. */
283 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
284 bool alignment; /* True if -malign- was used. */
285 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
286 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
287 bool spe; /* True if -mspe= was used. */
288 bool float_gprs; /* True if -mfloat-gprs= was used. */
289 bool long_double; /* True if -mlong-double- was used. */
290 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
291 bool vrsave; /* True if -mvrsave was used. */
292 } rs6000_explicit_options;
294 struct builtin_description
296 /* mask is not const because we're going to alter it below. This
297 nonsense will go away when we rewrite the -march infrastructure
298 to give us more target flag bits. */
300 const enum insn_code icode;
301 const char *const name;
302 const enum rs6000_builtins code;
305 /* Describe the vector unit used for modes. */
306 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
307 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
309 /* Register classes for various constraints that are based on the target
311 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
313 /* Describe the alignment of a vector. */
314 int rs6000_vector_align[NUM_MACHINE_MODES];
316 /* Map selected modes to types for builtins. */
317 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
319 /* Target cpu costs. */
321 struct processor_costs {
322 const int mulsi; /* cost of SImode multiplication. */
323 const int mulsi_const; /* cost of SImode multiplication by constant. */
324 const int mulsi_const9; /* cost of SImode mult by short constant. */
325 const int muldi; /* cost of DImode multiplication. */
326 const int divsi; /* cost of SImode division. */
327 const int divdi; /* cost of DImode division. */
328 const int fp; /* cost of simple SFmode and DFmode insns. */
329 const int dmul; /* cost of DFmode multiplication (and fmadd). */
330 const int sdiv; /* cost of SFmode division (fdivs). */
331 const int ddiv; /* cost of DFmode division (fdiv). */
332 const int cache_line_size; /* cache line size in bytes. */
333 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
334 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
335 const int simultaneous_prefetches; /* number of parallel prefetch
339 const struct processor_costs *rs6000_cost;
341 /* Processor costs (relative to an add) */
343 /* Instruction size costs on 32bit processors. */
345 struct processor_costs size32_cost = {
346 COSTS_N_INSNS (1), /* mulsi */
347 COSTS_N_INSNS (1), /* mulsi_const */
348 COSTS_N_INSNS (1), /* mulsi_const9 */
349 COSTS_N_INSNS (1), /* muldi */
350 COSTS_N_INSNS (1), /* divsi */
351 COSTS_N_INSNS (1), /* divdi */
352 COSTS_N_INSNS (1), /* fp */
353 COSTS_N_INSNS (1), /* dmul */
354 COSTS_N_INSNS (1), /* sdiv */
355 COSTS_N_INSNS (1), /* ddiv */
362 /* Instruction size costs on 64bit processors. */
364 struct processor_costs size64_cost = {
365 COSTS_N_INSNS (1), /* mulsi */
366 COSTS_N_INSNS (1), /* mulsi_const */
367 COSTS_N_INSNS (1), /* mulsi_const9 */
368 COSTS_N_INSNS (1), /* muldi */
369 COSTS_N_INSNS (1), /* divsi */
370 COSTS_N_INSNS (1), /* divdi */
371 COSTS_N_INSNS (1), /* fp */
372 COSTS_N_INSNS (1), /* dmul */
373 COSTS_N_INSNS (1), /* sdiv */
374 COSTS_N_INSNS (1), /* ddiv */
381 /* Instruction costs on RIOS1 processors. */
383 struct processor_costs rios1_cost = {
384 COSTS_N_INSNS (5), /* mulsi */
385 COSTS_N_INSNS (4), /* mulsi_const */
386 COSTS_N_INSNS (3), /* mulsi_const9 */
387 COSTS_N_INSNS (5), /* muldi */
388 COSTS_N_INSNS (19), /* divsi */
389 COSTS_N_INSNS (19), /* divdi */
390 COSTS_N_INSNS (2), /* fp */
391 COSTS_N_INSNS (2), /* dmul */
392 COSTS_N_INSNS (19), /* sdiv */
393 COSTS_N_INSNS (19), /* ddiv */
394 128, /* cache line size */
400 /* Instruction costs on RIOS2 processors. */
402 struct processor_costs rios2_cost = {
403 COSTS_N_INSNS (2), /* mulsi */
404 COSTS_N_INSNS (2), /* mulsi_const */
405 COSTS_N_INSNS (2), /* mulsi_const9 */
406 COSTS_N_INSNS (2), /* muldi */
407 COSTS_N_INSNS (13), /* divsi */
408 COSTS_N_INSNS (13), /* divdi */
409 COSTS_N_INSNS (2), /* fp */
410 COSTS_N_INSNS (2), /* dmul */
411 COSTS_N_INSNS (17), /* sdiv */
412 COSTS_N_INSNS (17), /* ddiv */
413 256, /* cache line size */
419 /* Instruction costs on RS64A processors. */
421 struct processor_costs rs64a_cost = {
422 COSTS_N_INSNS (20), /* mulsi */
423 COSTS_N_INSNS (12), /* mulsi_const */
424 COSTS_N_INSNS (8), /* mulsi_const9 */
425 COSTS_N_INSNS (34), /* muldi */
426 COSTS_N_INSNS (65), /* divsi */
427 COSTS_N_INSNS (67), /* divdi */
428 COSTS_N_INSNS (4), /* fp */
429 COSTS_N_INSNS (4), /* dmul */
430 COSTS_N_INSNS (31), /* sdiv */
431 COSTS_N_INSNS (31), /* ddiv */
432 128, /* cache line size */
438 /* Instruction costs on MPCCORE processors. */
440 struct processor_costs mpccore_cost = {
441 COSTS_N_INSNS (2), /* mulsi */
442 COSTS_N_INSNS (2), /* mulsi_const */
443 COSTS_N_INSNS (2), /* mulsi_const9 */
444 COSTS_N_INSNS (2), /* muldi */
445 COSTS_N_INSNS (6), /* divsi */
446 COSTS_N_INSNS (6), /* divdi */
447 COSTS_N_INSNS (4), /* fp */
448 COSTS_N_INSNS (5), /* dmul */
449 COSTS_N_INSNS (10), /* sdiv */
450 COSTS_N_INSNS (17), /* ddiv */
451 32, /* cache line size */
457 /* Instruction costs on PPC403 processors. */
459 struct processor_costs ppc403_cost = {
460 COSTS_N_INSNS (4), /* mulsi */
461 COSTS_N_INSNS (4), /* mulsi_const */
462 COSTS_N_INSNS (4), /* mulsi_const9 */
463 COSTS_N_INSNS (4), /* muldi */
464 COSTS_N_INSNS (33), /* divsi */
465 COSTS_N_INSNS (33), /* divdi */
466 COSTS_N_INSNS (11), /* fp */
467 COSTS_N_INSNS (11), /* dmul */
468 COSTS_N_INSNS (11), /* sdiv */
469 COSTS_N_INSNS (11), /* ddiv */
470 32, /* cache line size */
476 /* Instruction costs on PPC405 processors. */
478 struct processor_costs ppc405_cost = {
479 COSTS_N_INSNS (5), /* mulsi */
480 COSTS_N_INSNS (4), /* mulsi_const */
481 COSTS_N_INSNS (3), /* mulsi_const9 */
482 COSTS_N_INSNS (5), /* muldi */
483 COSTS_N_INSNS (35), /* divsi */
484 COSTS_N_INSNS (35), /* divdi */
485 COSTS_N_INSNS (11), /* fp */
486 COSTS_N_INSNS (11), /* dmul */
487 COSTS_N_INSNS (11), /* sdiv */
488 COSTS_N_INSNS (11), /* ddiv */
489 32, /* cache line size */
495 /* Instruction costs on PPC440 processors. */
497 struct processor_costs ppc440_cost = {
498 COSTS_N_INSNS (3), /* mulsi */
499 COSTS_N_INSNS (2), /* mulsi_const */
500 COSTS_N_INSNS (2), /* mulsi_const9 */
501 COSTS_N_INSNS (3), /* muldi */
502 COSTS_N_INSNS (34), /* divsi */
503 COSTS_N_INSNS (34), /* divdi */
504 COSTS_N_INSNS (5), /* fp */
505 COSTS_N_INSNS (5), /* dmul */
506 COSTS_N_INSNS (19), /* sdiv */
507 COSTS_N_INSNS (33), /* ddiv */
508 32, /* cache line size */
514 /* Instruction costs on PPC476 processors. */
516 struct processor_costs ppc476_cost = {
517 COSTS_N_INSNS (4), /* mulsi */
518 COSTS_N_INSNS (4), /* mulsi_const */
519 COSTS_N_INSNS (4), /* mulsi_const9 */
520 COSTS_N_INSNS (4), /* muldi */
521 COSTS_N_INSNS (11), /* divsi */
522 COSTS_N_INSNS (11), /* divdi */
523 COSTS_N_INSNS (6), /* fp */
524 COSTS_N_INSNS (6), /* dmul */
525 COSTS_N_INSNS (19), /* sdiv */
526 COSTS_N_INSNS (33), /* ddiv */
527 32, /* l1 cache line size */
533 /* Instruction costs on PPC601 processors. */
535 struct processor_costs ppc601_cost = {
536 COSTS_N_INSNS (5), /* mulsi */
537 COSTS_N_INSNS (5), /* mulsi_const */
538 COSTS_N_INSNS (5), /* mulsi_const9 */
539 COSTS_N_INSNS (5), /* muldi */
540 COSTS_N_INSNS (36), /* divsi */
541 COSTS_N_INSNS (36), /* divdi */
542 COSTS_N_INSNS (4), /* fp */
543 COSTS_N_INSNS (5), /* dmul */
544 COSTS_N_INSNS (17), /* sdiv */
545 COSTS_N_INSNS (31), /* ddiv */
546 32, /* cache line size */
552 /* Instruction costs on PPC603 processors. */
554 struct processor_costs ppc603_cost = {
555 COSTS_N_INSNS (5), /* mulsi */
556 COSTS_N_INSNS (3), /* mulsi_const */
557 COSTS_N_INSNS (2), /* mulsi_const9 */
558 COSTS_N_INSNS (5), /* muldi */
559 COSTS_N_INSNS (37), /* divsi */
560 COSTS_N_INSNS (37), /* divdi */
561 COSTS_N_INSNS (3), /* fp */
562 COSTS_N_INSNS (4), /* dmul */
563 COSTS_N_INSNS (18), /* sdiv */
564 COSTS_N_INSNS (33), /* ddiv */
565 32, /* cache line size */
571 /* Instruction costs on PPC604 processors. */
573 struct processor_costs ppc604_cost = {
574 COSTS_N_INSNS (4), /* mulsi */
575 COSTS_N_INSNS (4), /* mulsi_const */
576 COSTS_N_INSNS (4), /* mulsi_const9 */
577 COSTS_N_INSNS (4), /* muldi */
578 COSTS_N_INSNS (20), /* divsi */
579 COSTS_N_INSNS (20), /* divdi */
580 COSTS_N_INSNS (3), /* fp */
581 COSTS_N_INSNS (3), /* dmul */
582 COSTS_N_INSNS (18), /* sdiv */
583 COSTS_N_INSNS (32), /* ddiv */
584 32, /* cache line size */
590 /* Instruction costs on PPC604e processors. */
592 struct processor_costs ppc604e_cost = {
593 COSTS_N_INSNS (2), /* mulsi */
594 COSTS_N_INSNS (2), /* mulsi_const */
595 COSTS_N_INSNS (2), /* mulsi_const9 */
596 COSTS_N_INSNS (2), /* muldi */
597 COSTS_N_INSNS (20), /* divsi */
598 COSTS_N_INSNS (20), /* divdi */
599 COSTS_N_INSNS (3), /* fp */
600 COSTS_N_INSNS (3), /* dmul */
601 COSTS_N_INSNS (18), /* sdiv */
602 COSTS_N_INSNS (32), /* ddiv */
603 32, /* cache line size */
609 /* Instruction costs on PPC620 processors. */
611 struct processor_costs ppc620_cost = {
612 COSTS_N_INSNS (5), /* mulsi */
613 COSTS_N_INSNS (4), /* mulsi_const */
614 COSTS_N_INSNS (3), /* mulsi_const9 */
615 COSTS_N_INSNS (7), /* muldi */
616 COSTS_N_INSNS (21), /* divsi */
617 COSTS_N_INSNS (37), /* divdi */
618 COSTS_N_INSNS (3), /* fp */
619 COSTS_N_INSNS (3), /* dmul */
620 COSTS_N_INSNS (18), /* sdiv */
621 COSTS_N_INSNS (32), /* ddiv */
622 128, /* cache line size */
628 /* Instruction costs on PPC630 processors. */
630 struct processor_costs ppc630_cost = {
631 COSTS_N_INSNS (5), /* mulsi */
632 COSTS_N_INSNS (4), /* mulsi_const */
633 COSTS_N_INSNS (3), /* mulsi_const9 */
634 COSTS_N_INSNS (7), /* muldi */
635 COSTS_N_INSNS (21), /* divsi */
636 COSTS_N_INSNS (37), /* divdi */
637 COSTS_N_INSNS (3), /* fp */
638 COSTS_N_INSNS (3), /* dmul */
639 COSTS_N_INSNS (17), /* sdiv */
640 COSTS_N_INSNS (21), /* ddiv */
641 128, /* cache line size */
647 /* Instruction costs on Cell processor. */
648 /* COSTS_N_INSNS (1) ~ one add. */
650 struct processor_costs ppccell_cost = {
651 COSTS_N_INSNS (9/2)+2, /* mulsi */
652 COSTS_N_INSNS (6/2), /* mulsi_const */
653 COSTS_N_INSNS (6/2), /* mulsi_const9 */
654 COSTS_N_INSNS (15/2)+2, /* muldi */
655 COSTS_N_INSNS (38/2), /* divsi */
656 COSTS_N_INSNS (70/2), /* divdi */
657 COSTS_N_INSNS (10/2), /* fp */
658 COSTS_N_INSNS (10/2), /* dmul */
659 COSTS_N_INSNS (74/2), /* sdiv */
660 COSTS_N_INSNS (74/2), /* ddiv */
661 128, /* cache line size */
667 /* Instruction costs on PPC750 and PPC7400 processors. */
669 struct processor_costs ppc750_cost = {
670 COSTS_N_INSNS (5), /* mulsi */
671 COSTS_N_INSNS (3), /* mulsi_const */
672 COSTS_N_INSNS (2), /* mulsi_const9 */
673 COSTS_N_INSNS (5), /* muldi */
674 COSTS_N_INSNS (17), /* divsi */
675 COSTS_N_INSNS (17), /* divdi */
676 COSTS_N_INSNS (3), /* fp */
677 COSTS_N_INSNS (3), /* dmul */
678 COSTS_N_INSNS (17), /* sdiv */
679 COSTS_N_INSNS (31), /* ddiv */
680 32, /* cache line size */
686 /* Instruction costs on PPC7450 processors. */
688 struct processor_costs ppc7450_cost = {
689 COSTS_N_INSNS (4), /* mulsi */
690 COSTS_N_INSNS (3), /* mulsi_const */
691 COSTS_N_INSNS (3), /* mulsi_const9 */
692 COSTS_N_INSNS (4), /* muldi */
693 COSTS_N_INSNS (23), /* divsi */
694 COSTS_N_INSNS (23), /* divdi */
695 COSTS_N_INSNS (5), /* fp */
696 COSTS_N_INSNS (5), /* dmul */
697 COSTS_N_INSNS (21), /* sdiv */
698 COSTS_N_INSNS (35), /* ddiv */
699 32, /* cache line size */
705 /* Instruction costs on PPC8540 processors. */
707 struct processor_costs ppc8540_cost = {
708 COSTS_N_INSNS (4), /* mulsi */
709 COSTS_N_INSNS (4), /* mulsi_const */
710 COSTS_N_INSNS (4), /* mulsi_const9 */
711 COSTS_N_INSNS (4), /* muldi */
712 COSTS_N_INSNS (19), /* divsi */
713 COSTS_N_INSNS (19), /* divdi */
714 COSTS_N_INSNS (4), /* fp */
715 COSTS_N_INSNS (4), /* dmul */
716 COSTS_N_INSNS (29), /* sdiv */
717 COSTS_N_INSNS (29), /* ddiv */
718 32, /* cache line size */
721 1, /* prefetch streams /*/
724 /* Instruction costs on E300C2 and E300C3 cores. */
726 struct processor_costs ppce300c2c3_cost = {
727 COSTS_N_INSNS (4), /* mulsi */
728 COSTS_N_INSNS (4), /* mulsi_const */
729 COSTS_N_INSNS (4), /* mulsi_const9 */
730 COSTS_N_INSNS (4), /* muldi */
731 COSTS_N_INSNS (19), /* divsi */
732 COSTS_N_INSNS (19), /* divdi */
733 COSTS_N_INSNS (3), /* fp */
734 COSTS_N_INSNS (4), /* dmul */
735 COSTS_N_INSNS (18), /* sdiv */
736 COSTS_N_INSNS (33), /* ddiv */
740 1, /* prefetch streams /*/
743 /* Instruction costs on PPCE500MC processors. */
745 struct processor_costs ppce500mc_cost = {
746 COSTS_N_INSNS (4), /* mulsi */
747 COSTS_N_INSNS (4), /* mulsi_const */
748 COSTS_N_INSNS (4), /* mulsi_const9 */
749 COSTS_N_INSNS (4), /* muldi */
750 COSTS_N_INSNS (14), /* divsi */
751 COSTS_N_INSNS (14), /* divdi */
752 COSTS_N_INSNS (8), /* fp */
753 COSTS_N_INSNS (10), /* dmul */
754 COSTS_N_INSNS (36), /* sdiv */
755 COSTS_N_INSNS (66), /* ddiv */
756 64, /* cache line size */
759 1, /* prefetch streams /*/
762 /* Instruction costs on PPCE500MC64 processors. */
764 struct processor_costs ppce500mc64_cost = {
765 COSTS_N_INSNS (4), /* mulsi */
766 COSTS_N_INSNS (4), /* mulsi_const */
767 COSTS_N_INSNS (4), /* mulsi_const9 */
768 COSTS_N_INSNS (4), /* muldi */
769 COSTS_N_INSNS (14), /* divsi */
770 COSTS_N_INSNS (14), /* divdi */
771 COSTS_N_INSNS (4), /* fp */
772 COSTS_N_INSNS (10), /* dmul */
773 COSTS_N_INSNS (36), /* sdiv */
774 COSTS_N_INSNS (66), /* ddiv */
775 64, /* cache line size */
778 1, /* prefetch streams /*/
781 /* Instruction costs on POWER4 and POWER5 processors. */
783 struct processor_costs power4_cost = {
784 COSTS_N_INSNS (3), /* mulsi */
785 COSTS_N_INSNS (2), /* mulsi_const */
786 COSTS_N_INSNS (2), /* mulsi_const9 */
787 COSTS_N_INSNS (4), /* muldi */
788 COSTS_N_INSNS (18), /* divsi */
789 COSTS_N_INSNS (34), /* divdi */
790 COSTS_N_INSNS (3), /* fp */
791 COSTS_N_INSNS (3), /* dmul */
792 COSTS_N_INSNS (17), /* sdiv */
793 COSTS_N_INSNS (17), /* ddiv */
794 128, /* cache line size */
797 8, /* prefetch streams /*/
800 /* Instruction costs on POWER6 processors. */
802 struct processor_costs power6_cost = {
803 COSTS_N_INSNS (8), /* mulsi */
804 COSTS_N_INSNS (8), /* mulsi_const */
805 COSTS_N_INSNS (8), /* mulsi_const9 */
806 COSTS_N_INSNS (8), /* muldi */
807 COSTS_N_INSNS (22), /* divsi */
808 COSTS_N_INSNS (28), /* divdi */
809 COSTS_N_INSNS (3), /* fp */
810 COSTS_N_INSNS (3), /* dmul */
811 COSTS_N_INSNS (13), /* sdiv */
812 COSTS_N_INSNS (16), /* ddiv */
813 128, /* cache line size */
816 16, /* prefetch streams */
819 /* Instruction costs on POWER7 processors. */
821 struct processor_costs power7_cost = {
822 COSTS_N_INSNS (2), /* mulsi */
823 COSTS_N_INSNS (2), /* mulsi_const */
824 COSTS_N_INSNS (2), /* mulsi_const9 */
825 COSTS_N_INSNS (2), /* muldi */
826 COSTS_N_INSNS (18), /* divsi */
827 COSTS_N_INSNS (34), /* divdi */
828 COSTS_N_INSNS (3), /* fp */
829 COSTS_N_INSNS (3), /* dmul */
830 COSTS_N_INSNS (13), /* sdiv */
831 COSTS_N_INSNS (16), /* ddiv */
832 128, /* cache line size */
835 12, /* prefetch streams */
838 /* Instruction costs on POWER A2 processors. */
840 struct processor_costs ppca2_cost = {
841 COSTS_N_INSNS (16), /* mulsi */
842 COSTS_N_INSNS (16), /* mulsi_const */
843 COSTS_N_INSNS (16), /* mulsi_const9 */
844 COSTS_N_INSNS (16), /* muldi */
845 COSTS_N_INSNS (22), /* divsi */
846 COSTS_N_INSNS (28), /* divdi */
847 COSTS_N_INSNS (3), /* fp */
848 COSTS_N_INSNS (3), /* dmul */
849 COSTS_N_INSNS (59), /* sdiv */
850 COSTS_N_INSNS (72), /* ddiv */
854 16, /* prefetch streams */
858 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
859 #undef RS6000_BUILTIN
860 #undef RS6000_BUILTIN_EQUATE
861 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
862 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
864 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
866 #include "rs6000-builtin.def"
869 #undef RS6000_BUILTIN
870 #undef RS6000_BUILTIN_EQUATE
873 static bool rs6000_function_ok_for_sibcall (tree, tree);
874 static const char *rs6000_invalid_within_doloop (const_rtx);
875 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
876 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
877 static rtx rs6000_generate_compare (rtx, enum machine_mode);
878 static void rs6000_emit_stack_tie (void);
879 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
880 static bool spe_func_has_64bit_regs_p (void);
881 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
883 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
884 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int, int);
885 static unsigned rs6000_hash_constant (rtx);
886 static unsigned toc_hash_function (const void *);
887 static int toc_hash_eq (const void *, const void *);
888 static bool reg_offset_addressing_ok_p (enum machine_mode);
889 static bool virtual_stack_registers_memory_p (rtx);
890 static bool constant_pool_expr_p (rtx);
891 static bool legitimate_small_data_p (enum machine_mode, rtx);
892 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
893 static struct machine_function * rs6000_init_machine_status (void);
894 static bool rs6000_assemble_integer (rtx, unsigned int, int);
895 static bool no_global_regs_above (int, bool);
896 #ifdef HAVE_GAS_HIDDEN
897 static void rs6000_assemble_visibility (tree, int);
899 static int rs6000_ra_ever_killed (void);
900 static bool rs6000_attribute_takes_identifier_p (const_tree);
901 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
902 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
903 static bool rs6000_ms_bitfield_layout_p (const_tree);
904 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
905 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
906 static const char *rs6000_mangle_type (const_tree);
907 static void rs6000_set_default_type_attributes (tree);
908 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
909 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
910 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
911 enum machine_mode, bool, bool, bool);
912 static bool rs6000_reg_live_or_pic_offset_p (int);
913 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
914 static int rs6000_savres_strategy (rs6000_stack_t *, bool, int, int);
915 static void rs6000_restore_saved_cr (rtx, int);
916 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
917 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
918 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
920 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
921 static bool rs6000_return_in_memory (const_tree, const_tree);
922 static rtx rs6000_function_value (const_tree, const_tree, bool);
923 static void rs6000_file_start (void);
925 static int rs6000_elf_reloc_rw_mask (void);
926 static void rs6000_elf_asm_out_constructor (rtx, int);
927 static void rs6000_elf_asm_out_destructor (rtx, int);
928 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
929 static void rs6000_elf_asm_init_sections (void);
930 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
931 unsigned HOST_WIDE_INT);
932 static void rs6000_elf_encode_section_info (tree, rtx, int)
935 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
936 static void rs6000_alloc_sdmode_stack_slot (void);
937 static void rs6000_instantiate_decls (void);
939 static void rs6000_xcoff_asm_output_anchor (rtx);
940 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
941 static void rs6000_xcoff_asm_init_sections (void);
942 static int rs6000_xcoff_reloc_rw_mask (void);
943 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
944 static section *rs6000_xcoff_select_section (tree, int,
945 unsigned HOST_WIDE_INT);
946 static void rs6000_xcoff_unique_section (tree, int);
947 static section *rs6000_xcoff_select_rtx_section
948 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
949 static const char * rs6000_xcoff_strip_name_encoding (const char *);
950 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
951 static void rs6000_xcoff_file_start (void);
952 static void rs6000_xcoff_file_end (void);
954 static int rs6000_variable_issue (FILE *, int, rtx, int);
955 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
956 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
957 static int rs6000_debug_address_cost (rtx, bool);
958 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
959 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
960 static void rs6000_sched_init (FILE *, int, int);
961 static bool is_microcoded_insn (rtx);
962 static bool is_nonpipeline_insn (rtx);
963 static bool is_cracked_insn (rtx);
964 static bool is_branch_slot_insn (rtx);
965 static bool is_load_insn (rtx);
966 static rtx get_store_dest (rtx pat);
967 static bool is_store_insn (rtx);
968 static bool set_to_load_agen (rtx,rtx);
969 static bool adjacent_mem_locations (rtx,rtx);
970 static int rs6000_adjust_priority (rtx, int);
971 static int rs6000_issue_rate (void);
972 static bool rs6000_is_costly_dependence (dep_t, int, int);
973 static rtx get_next_active_insn (rtx, rtx);
974 static bool insn_terminates_group_p (rtx , enum group_termination);
975 static bool insn_must_be_first_in_group (rtx);
976 static bool insn_must_be_last_in_group (rtx);
977 static bool is_costly_group (rtx *, rtx);
978 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
979 static int redefine_groups (FILE *, int, rtx, rtx);
980 static int pad_groups (FILE *, int, rtx, rtx);
981 static void rs6000_sched_finish (FILE *, int);
982 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
983 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
984 static int rs6000_use_sched_lookahead (void);
985 static int rs6000_use_sched_lookahead_guard (rtx);
986 static void * rs6000_alloc_sched_context (void);
987 static void rs6000_init_sched_context (void *, bool);
988 static void rs6000_set_sched_context (void *);
989 static void rs6000_free_sched_context (void *);
990 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
991 static tree rs6000_builtin_mask_for_load (void);
992 static tree rs6000_builtin_mul_widen_even (tree);
993 static tree rs6000_builtin_mul_widen_odd (tree);
994 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
995 static tree rs6000_builtin_vec_perm (tree, tree *);
996 static bool rs6000_builtin_support_vector_misalignment (enum
1001 static void def_builtin (int, const char *, tree, int);
1002 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1003 static void rs6000_init_builtins (void);
1004 static tree rs6000_builtin_decl (unsigned, bool);
1006 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1007 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1008 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1009 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1010 static void altivec_init_builtins (void);
1011 static unsigned builtin_hash_function (const void *);
1012 static int builtin_hash_eq (const void *, const void *);
1013 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1014 enum machine_mode, enum machine_mode,
1015 enum rs6000_builtins, const char *name);
1016 static void rs6000_common_init_builtins (void);
1017 static void rs6000_init_libfuncs (void);
1019 static void paired_init_builtins (void);
1020 static rtx paired_expand_builtin (tree, rtx, bool *);
1021 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1022 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1023 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1025 static void enable_mask_for_builtins (struct builtin_description *, int,
1026 enum rs6000_builtins,
1027 enum rs6000_builtins);
1028 static void spe_init_builtins (void);
1029 static rtx spe_expand_builtin (tree, rtx, bool *);
1030 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1031 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1032 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1033 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1034 static rs6000_stack_t *rs6000_stack_info (void);
1035 static void debug_stack_info (rs6000_stack_t *);
1037 static rtx altivec_expand_builtin (tree, rtx, bool *);
1038 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1039 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1040 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1041 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1042 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1043 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1044 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1045 static rtx altivec_expand_vec_set_builtin (tree);
1046 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1047 static int get_element_number (tree, tree);
1048 static bool rs6000_handle_option (size_t, const char *, int);
1049 static void rs6000_parse_tls_size_option (void);
1050 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1051 static int first_altivec_reg_to_save (void);
1052 static unsigned int compute_vrsave_mask (void);
1053 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1054 static void is_altivec_return_reg (rtx, void *);
1055 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1056 int easy_vector_constant (rtx, enum machine_mode);
1057 static rtx rs6000_dwarf_register_span (rtx);
1058 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1059 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1060 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1061 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1062 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1063 static rtx rs6000_delegitimize_address (rtx);
1064 static rtx rs6000_tls_get_addr (void);
1065 static rtx rs6000_got_sym (void);
1066 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1067 static const char *rs6000_get_some_local_dynamic_name (void);
1068 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1069 static rtx rs6000_complex_function_value (enum machine_mode);
1070 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
1071 enum machine_mode, tree);
1072 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1074 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1075 tree, HOST_WIDE_INT);
1076 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1079 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1080 const_tree, HOST_WIDE_INT,
1082 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
1083 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
1084 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1085 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1086 enum machine_mode, tree,
1088 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1090 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1092 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1094 static void macho_branch_islands (void);
1095 static int no_previous_def (tree function_name);
1096 static tree get_prev_label (tree function_name);
1097 static void rs6000_darwin_file_start (void);
1100 static tree rs6000_build_builtin_va_list (void);
1101 static void rs6000_va_start (tree, rtx);
1102 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1103 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1104 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1105 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1106 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1107 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1109 static tree rs6000_stack_protect_fail (void);
1111 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1114 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1117 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1119 = rs6000_legitimize_reload_address;
1121 static bool rs6000_mode_dependent_address (rtx);
1122 static bool rs6000_debug_mode_dependent_address (rtx);
1123 bool (*rs6000_mode_dependent_address_ptr) (rtx)
1124 = rs6000_mode_dependent_address;
1126 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1127 enum machine_mode, rtx);
1128 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1131 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1132 enum machine_mode, rtx)
1133 = rs6000_secondary_reload_class;
1135 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1136 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1138 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1139 = rs6000_preferred_reload_class;
1141 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1144 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1148 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1150 = rs6000_secondary_memory_needed;
1152 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1155 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1159 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1162 = rs6000_cannot_change_mode_class;
1164 static enum reg_class rs6000_secondary_reload (bool, rtx, enum reg_class,
1166 struct secondary_reload_info *);
1168 static const enum reg_class *rs6000_ira_cover_classes (void);
1170 const int INSN_NOT_AVAILABLE = -1;
1171 static enum machine_mode rs6000_eh_return_filter_mode (void);
1172 static bool rs6000_can_eliminate (const int, const int);
1173 static void rs6000_trampoline_init (rtx, tree, rtx);
1175 /* Hash table stuff for keeping track of TOC entries. */
1177 struct GTY(()) toc_hash_struct
1179 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1180 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1182 enum machine_mode key_mode;
1186 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1188 /* Hash table to keep track of the argument types for builtin functions. */
1190 struct GTY(()) builtin_hash_struct
1193 enum machine_mode mode[4]; /* return value + 3 arguments. */
1194 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1197 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1199 /* Default register names. */
1200 char rs6000_reg_names[][8] =
1202 "0", "1", "2", "3", "4", "5", "6", "7",
1203 "8", "9", "10", "11", "12", "13", "14", "15",
1204 "16", "17", "18", "19", "20", "21", "22", "23",
1205 "24", "25", "26", "27", "28", "29", "30", "31",
1206 "0", "1", "2", "3", "4", "5", "6", "7",
1207 "8", "9", "10", "11", "12", "13", "14", "15",
1208 "16", "17", "18", "19", "20", "21", "22", "23",
1209 "24", "25", "26", "27", "28", "29", "30", "31",
1210 "mq", "lr", "ctr","ap",
1211 "0", "1", "2", "3", "4", "5", "6", "7",
1213 /* AltiVec registers. */
1214 "0", "1", "2", "3", "4", "5", "6", "7",
1215 "8", "9", "10", "11", "12", "13", "14", "15",
1216 "16", "17", "18", "19", "20", "21", "22", "23",
1217 "24", "25", "26", "27", "28", "29", "30", "31",
1219 /* SPE registers. */
1220 "spe_acc", "spefscr",
1221 /* Soft frame pointer. */
1225 #ifdef TARGET_REGNAMES
1226 static const char alt_reg_names[][8] =
1228 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1229 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1230 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1231 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1232 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1233 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1234 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1235 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1236 "mq", "lr", "ctr", "ap",
1237 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1239 /* AltiVec registers. */
1240 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1241 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1242 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1243 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1245 /* SPE registers. */
1246 "spe_acc", "spefscr",
1247 /* Soft frame pointer. */
1252 /* Table of valid machine attributes. */
1254 static const struct attribute_spec rs6000_attribute_table[] =
1256 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1257 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute },
1258 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1259 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1260 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1261 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1262 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1263 SUBTARGET_ATTRIBUTE_TABLE,
1265 { NULL, 0, 0, false, false, false, NULL }
1268 #ifndef MASK_STRICT_ALIGN
1269 #define MASK_STRICT_ALIGN 0
1271 #ifndef TARGET_PROFILE_KERNEL
1272 #define TARGET_PROFILE_KERNEL 0
1275 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1276 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1278 /* Initialize the GCC target structure. */
1279 #undef TARGET_ATTRIBUTE_TABLE
1280 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1281 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1282 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1283 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1284 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1286 #undef TARGET_ASM_ALIGNED_DI_OP
1287 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1289 /* Default unaligned ops are only provided for ELF. Find the ops needed
1290 for non-ELF systems. */
1291 #ifndef OBJECT_FORMAT_ELF
1293 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1295 #undef TARGET_ASM_UNALIGNED_HI_OP
1296 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1297 #undef TARGET_ASM_UNALIGNED_SI_OP
1298 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1299 #undef TARGET_ASM_UNALIGNED_DI_OP
1300 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1303 #undef TARGET_ASM_UNALIGNED_HI_OP
1304 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1305 #undef TARGET_ASM_UNALIGNED_SI_OP
1306 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1307 #undef TARGET_ASM_UNALIGNED_DI_OP
1308 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1309 #undef TARGET_ASM_ALIGNED_DI_OP
1310 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1314 /* This hook deals with fixups for relocatable code and DI-mode objects
1316 #undef TARGET_ASM_INTEGER
1317 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1319 #ifdef HAVE_GAS_HIDDEN
1320 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1321 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1324 #undef TARGET_HAVE_TLS
1325 #define TARGET_HAVE_TLS HAVE_AS_TLS
1327 #undef TARGET_CANNOT_FORCE_CONST_MEM
1328 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1330 #undef TARGET_DELEGITIMIZE_ADDRESS
1331 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1333 #undef TARGET_ASM_FUNCTION_PROLOGUE
1334 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1335 #undef TARGET_ASM_FUNCTION_EPILOGUE
1336 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1338 #undef TARGET_LEGITIMIZE_ADDRESS
1339 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1341 #undef TARGET_SCHED_VARIABLE_ISSUE
1342 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1344 #undef TARGET_SCHED_ISSUE_RATE
1345 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1346 #undef TARGET_SCHED_ADJUST_COST
1347 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1348 #undef TARGET_SCHED_ADJUST_PRIORITY
1349 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1350 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1351 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1352 #undef TARGET_SCHED_INIT
1353 #define TARGET_SCHED_INIT rs6000_sched_init
1354 #undef TARGET_SCHED_FINISH
1355 #define TARGET_SCHED_FINISH rs6000_sched_finish
1356 #undef TARGET_SCHED_REORDER
1357 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1358 #undef TARGET_SCHED_REORDER2
1359 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1361 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1362 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1364 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1365 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1367 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1368 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1369 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1370 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1371 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1372 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1373 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1374 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1376 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1377 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1378 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1379 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1380 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1381 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1382 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1383 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1384 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1385 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1386 #undef TARGET_SUPPORT_VECTOR_MISALIGNMENT
1387 #define TARGET_SUPPORT_VECTOR_MISALIGNMENT \
1388 rs6000_builtin_support_vector_misalignment
1389 #undef TARGET_VECTOR_ALIGNMENT_REACHABLE
1390 #define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1392 #undef TARGET_INIT_BUILTINS
1393 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1394 #undef TARGET_BUILTIN_DECL
1395 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1397 #undef TARGET_EXPAND_BUILTIN
1398 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1400 #undef TARGET_MANGLE_TYPE
1401 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1403 #undef TARGET_INIT_LIBFUNCS
1404 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1407 #undef TARGET_BINDS_LOCAL_P
1408 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1411 #undef TARGET_MS_BITFIELD_LAYOUT_P
1412 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1414 #undef TARGET_ASM_OUTPUT_MI_THUNK
1415 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1417 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1418 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1420 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1421 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1423 #undef TARGET_INVALID_WITHIN_DOLOOP
1424 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1426 #undef TARGET_RTX_COSTS
1427 #define TARGET_RTX_COSTS rs6000_rtx_costs
1428 #undef TARGET_ADDRESS_COST
1429 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1431 #undef TARGET_DWARF_REGISTER_SPAN
1432 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1434 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1435 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1437 /* On rs6000, function arguments are promoted, as are function return
1439 #undef TARGET_PROMOTE_FUNCTION_MODE
1440 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1442 #undef TARGET_RETURN_IN_MEMORY
1443 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1445 #undef TARGET_SETUP_INCOMING_VARARGS
1446 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1448 /* Always strict argument naming on rs6000. */
1449 #undef TARGET_STRICT_ARGUMENT_NAMING
1450 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1451 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1452 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1453 #undef TARGET_SPLIT_COMPLEX_ARG
1454 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1455 #undef TARGET_MUST_PASS_IN_STACK
1456 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1457 #undef TARGET_PASS_BY_REFERENCE
1458 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1459 #undef TARGET_ARG_PARTIAL_BYTES
1460 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1462 #undef TARGET_BUILD_BUILTIN_VA_LIST
1463 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1465 #undef TARGET_EXPAND_BUILTIN_VA_START
1466 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1468 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1469 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1471 #undef TARGET_EH_RETURN_FILTER_MODE
1472 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1474 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1475 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1477 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1478 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1480 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1481 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1483 #undef TARGET_HANDLE_OPTION
1484 #define TARGET_HANDLE_OPTION rs6000_handle_option
1486 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1487 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1488 rs6000_builtin_vectorized_function
1490 #undef TARGET_DEFAULT_TARGET_FLAGS
1491 #define TARGET_DEFAULT_TARGET_FLAGS \
1494 #undef TARGET_STACK_PROTECT_FAIL
1495 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1497 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1498 The PowerPC architecture requires only weak consistency among
1499 processors--that is, memory accesses between processors need not be
1500 sequentially consistent and memory accesses among processors can occur
1501 in any order. The ability to order memory accesses weakly provides
1502 opportunities for more efficient use of the system bus. Unless a
1503 dependency exists, the 604e allows read operations to precede store
1505 #undef TARGET_RELAXED_ORDERING
1506 #define TARGET_RELAXED_ORDERING true
1509 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1510 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1513 /* Use a 32-bit anchor range. This leads to sequences like:
1515 addis tmp,anchor,high
1518 where tmp itself acts as an anchor, and can be shared between
1519 accesses to the same 64k page. */
1520 #undef TARGET_MIN_ANCHOR_OFFSET
1521 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1522 #undef TARGET_MAX_ANCHOR_OFFSET
1523 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1524 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1525 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1527 #undef TARGET_BUILTIN_RECIPROCAL
1528 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1530 #undef TARGET_EXPAND_TO_RTL_HOOK
1531 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1533 #undef TARGET_INSTANTIATE_DECLS
1534 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1536 #undef TARGET_SECONDARY_RELOAD
1537 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1539 #undef TARGET_IRA_COVER_CLASSES
1540 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1542 #undef TARGET_LEGITIMATE_ADDRESS_P
1543 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1545 #undef TARGET_CAN_ELIMINATE
1546 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1548 #undef TARGET_TRAMPOLINE_INIT
1549 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1551 #undef TARGET_FUNCTION_VALUE
1552 #define TARGET_FUNCTION_VALUE rs6000_function_value
1554 struct gcc_target targetm = TARGET_INITIALIZER;
1556 /* Return number of consecutive hard regs needed starting at reg REGNO
1557 to hold something of mode MODE.
1558 This is ordinarily the length in words of a value of mode MODE
1559 but can be less for certain modes in special long registers.
1561 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1562 scalar instructions. The upper 32 bits are only available to the
1565 POWER and PowerPC GPRs hold 32 bits worth;
1566 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1569 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1571 unsigned HOST_WIDE_INT reg_size;
1573 if (FP_REGNO_P (regno))
1574 reg_size = (VECTOR_MEM_VSX_P (mode)
1575 ? UNITS_PER_VSX_WORD
1576 : UNITS_PER_FP_WORD);
1578 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1579 reg_size = UNITS_PER_SPE_WORD;
1581 else if (ALTIVEC_REGNO_P (regno))
1582 reg_size = UNITS_PER_ALTIVEC_WORD;
1584 /* The value returned for SCmode in the E500 double case is 2 for
1585 ABI compatibility; storing an SCmode value in a single register
1586 would require function_arg and rs6000_spe_function_arg to handle
1587 SCmode so as to pass the value correctly in a pair of
1589 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1590 && !DECIMAL_FLOAT_MODE_P (mode))
1591 reg_size = UNITS_PER_FP_WORD;
1594 reg_size = UNITS_PER_WORD;
1596 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1599 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1602 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1604 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1606 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1607 implementations. Don't allow an item to be split between a FP register
1608 and an Altivec register. */
1609 if (VECTOR_MEM_VSX_P (mode))
1611 if (FP_REGNO_P (regno))
1612 return FP_REGNO_P (last_regno);
1614 if (ALTIVEC_REGNO_P (regno))
1615 return ALTIVEC_REGNO_P (last_regno);
1618 /* The GPRs can hold any mode, but values bigger than one register
1619 cannot go past R31. */
1620 if (INT_REGNO_P (regno))
1621 return INT_REGNO_P (last_regno);
1623 /* The float registers (except for VSX vector modes) can only hold floating
1624 modes and DImode. This excludes the 32-bit decimal float mode for
1626 if (FP_REGNO_P (regno))
1628 if (SCALAR_FLOAT_MODE_P (mode)
1629 && (mode != TDmode || (regno % 2) == 0)
1630 && FP_REGNO_P (last_regno))
1633 if (GET_MODE_CLASS (mode) == MODE_INT
1634 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1637 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1638 && PAIRED_VECTOR_MODE (mode))
1644 /* The CR register can only hold CC modes. */
1645 if (CR_REGNO_P (regno))
1646 return GET_MODE_CLASS (mode) == MODE_CC;
1648 if (XER_REGNO_P (regno))
1649 return mode == PSImode;
1651 /* AltiVec only in AldyVec registers. */
1652 if (ALTIVEC_REGNO_P (regno))
1653 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1655 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1656 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1659 /* We cannot put TImode anywhere except general register and it must be able
1660 to fit within the register set. In the future, allow TImode in the
1661 Altivec or VSX registers. */
1663 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1666 /* Print interesting facts about registers. */
1668 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1672 for (r = first_regno; r <= last_regno; ++r)
1674 const char *comma = "";
1677 if (first_regno == last_regno)
1678 fprintf (stderr, "%s:\t", reg_name);
1680 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1683 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1684 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1688 fprintf (stderr, ",\n\t");
1693 if (rs6000_hard_regno_nregs[m][r] > 1)
1694 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1695 rs6000_hard_regno_nregs[m][r]);
1697 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1702 if (call_used_regs[r])
1706 fprintf (stderr, ",\n\t");
1711 len += fprintf (stderr, "%s%s", comma, "call-used");
1719 fprintf (stderr, ",\n\t");
1724 len += fprintf (stderr, "%s%s", comma, "fixed");
1730 fprintf (stderr, ",\n\t");
1734 fprintf (stderr, "%sregno = %d\n", comma, r);
1738 /* Print various interesting information with -mdebug=reg. */
1740 rs6000_debug_reg_global (void)
1742 const char *nl = (const char *)0;
1744 char costly_num[20];
1746 const char *costly_str;
1747 const char *nop_str;
1749 /* Map enum rs6000_vector to string. */
1750 static const char *rs6000_debug_vector_unit[] = {
1759 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
1760 LAST_VIRTUAL_REGISTER);
1761 rs6000_debug_reg_print (0, 31, "gr");
1762 rs6000_debug_reg_print (32, 63, "fp");
1763 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
1766 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
1767 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
1768 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
1769 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
1770 rs6000_debug_reg_print (XER_REGNO, XER_REGNO, "xer");
1771 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
1772 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
1773 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
1774 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
1778 "d reg_class = %s\n"
1779 "f reg_class = %s\n"
1780 "v reg_class = %s\n"
1781 "wa reg_class = %s\n"
1782 "wd reg_class = %s\n"
1783 "wf reg_class = %s\n"
1784 "ws reg_class = %s\n\n",
1785 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
1786 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
1787 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
1788 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
1789 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
1790 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
1791 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
1793 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1794 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
1797 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
1799 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
1800 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
1806 switch (rs6000_sched_costly_dep)
1808 case max_dep_latency:
1809 costly_str = "max_dep_latency";
1813 costly_str = "no_dep_costly";
1816 case all_deps_costly:
1817 costly_str = "all_deps_costly";
1820 case true_store_to_load_dep_costly:
1821 costly_str = "true_store_to_load_dep_costly";
1824 case store_to_load_dep_costly:
1825 costly_str = "store_to_load_dep_costly";
1829 costly_str = costly_num;
1830 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
1834 switch (rs6000_sched_insert_nops)
1836 case sched_finish_regroup_exact:
1837 nop_str = "sched_finish_regroup_exact";
1840 case sched_finish_pad_groups:
1841 nop_str = "sched_finish_pad_groups";
1844 case sched_finish_none:
1845 nop_str = "sched_finish_none";
1850 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
1855 "always_hint = %s\n"
1856 "align_branch_targets = %s\n"
1857 "sched_restricted_insns_priority = %d\n"
1858 "sched_costly_dep = %s\n"
1859 "sched_insert_nops = %s\n\n",
1860 rs6000_always_hint ? "true" : "false",
1861 rs6000_align_branch_targets ? "true" : "false",
1862 (int)rs6000_sched_restricted_insns_priority,
1863 costly_str, nop_str);
1866 /* Initialize the various global tables that are based on register size. */
1868 rs6000_init_hard_regno_mode_ok (void)
1874 /* Precalculate REGNO_REG_CLASS. */
1875 rs6000_regno_regclass[0] = GENERAL_REGS;
1876 for (r = 1; r < 32; ++r)
1877 rs6000_regno_regclass[r] = BASE_REGS;
1879 for (r = 32; r < 64; ++r)
1880 rs6000_regno_regclass[r] = FLOAT_REGS;
1882 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
1883 rs6000_regno_regclass[r] = NO_REGS;
1885 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
1886 rs6000_regno_regclass[r] = ALTIVEC_REGS;
1888 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
1889 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
1890 rs6000_regno_regclass[r] = CR_REGS;
1892 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
1893 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
1894 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
1895 rs6000_regno_regclass[XER_REGNO] = XER_REGS;
1896 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
1897 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
1898 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
1899 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
1900 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
1901 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
1903 /* Precalculate vector information, this must be set up before the
1904 rs6000_hard_regno_nregs_internal below. */
1905 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1907 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
1908 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
1909 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
1912 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
1913 rs6000_constraints[c] = NO_REGS;
1915 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
1916 believes it can use native alignment or still uses 128-bit alignment. */
1917 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
1928 /* V2DF mode, VSX only. */
1931 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
1932 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
1933 rs6000_vector_align[V2DFmode] = align64;
1936 /* V4SF mode, either VSX or Altivec. */
1939 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
1940 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
1941 rs6000_vector_align[V4SFmode] = align32;
1943 else if (TARGET_ALTIVEC)
1945 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
1946 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
1947 rs6000_vector_align[V4SFmode] = align32;
1950 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
1954 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
1955 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
1956 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
1957 rs6000_vector_align[V4SImode] = align32;
1958 rs6000_vector_align[V8HImode] = align32;
1959 rs6000_vector_align[V16QImode] = align32;
1963 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
1964 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
1965 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
1969 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
1970 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
1971 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
1975 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
1976 Altivec doesn't have 64-bit support. */
1979 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
1980 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
1981 rs6000_vector_align[V2DImode] = align64;
1984 /* DFmode, see if we want to use the VSX unit. */
1985 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
1987 rs6000_vector_unit[DFmode] = VECTOR_VSX;
1988 rs6000_vector_mem[DFmode]
1989 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
1990 rs6000_vector_align[DFmode] = align64;
1993 /* TODO add SPE and paired floating point vector support. */
1995 /* Register class constaints for the constraints that depend on compile
1997 if (TARGET_HARD_FLOAT && TARGET_FPRS)
1998 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2000 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2001 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2005 /* At present, we just use VSX_REGS, but we have different constraints
2006 based on the use, in case we want to fine tune the default register
2007 class used. wa = any VSX register, wf = register class to use for
2008 V4SF, wd = register class to use for V2DF, and ws = register classs to
2009 use for DF scalars. */
2010 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2011 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2012 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2013 if (TARGET_VSX_SCALAR_DOUBLE)
2014 rs6000_constraints[RS6000_CONSTRAINT_ws] = VSX_REGS;
2018 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2020 /* Set up the reload helper functions. */
2021 if (TARGET_VSX || TARGET_ALTIVEC)
2025 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2026 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2027 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2028 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2029 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2030 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2031 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2032 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2033 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2034 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2035 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2036 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2040 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2041 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2042 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2043 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2044 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2045 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2046 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2047 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2048 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2049 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2050 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2051 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2055 /* Precalculate HARD_REGNO_NREGS. */
2056 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2057 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2058 rs6000_hard_regno_nregs[m][r]
2059 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2061 /* Precalculate HARD_REGNO_MODE_OK. */
2062 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2063 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2064 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2065 rs6000_hard_regno_mode_ok_p[m][r] = true;
2067 /* Precalculate CLASS_MAX_NREGS sizes. */
2068 for (c = 0; c < LIM_REG_CLASSES; ++c)
2072 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2073 reg_size = UNITS_PER_VSX_WORD;
2075 else if (c == ALTIVEC_REGS)
2076 reg_size = UNITS_PER_ALTIVEC_WORD;
2078 else if (c == FLOAT_REGS)
2079 reg_size = UNITS_PER_FP_WORD;
2082 reg_size = UNITS_PER_WORD;
2084 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2085 rs6000_class_max_nregs[m][c]
2086 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2089 if (TARGET_E500_DOUBLE)
2090 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2092 if (TARGET_DEBUG_REG)
2093 rs6000_debug_reg_global ();
2097 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2100 darwin_rs6000_override_options (void)
2102 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2104 rs6000_altivec_abi = 1;
2105 TARGET_ALTIVEC_VRSAVE = 1;
2106 if (DEFAULT_ABI == ABI_DARWIN)
2108 if (MACHO_DYNAMIC_NO_PIC_P)
2111 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
2114 else if (flag_pic == 1)
2119 if (TARGET_64BIT && ! TARGET_POWERPC64)
2121 target_flags |= MASK_POWERPC64;
2122 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2126 rs6000_default_long_calls = 1;
2127 target_flags |= MASK_SOFT_FLOAT;
2130 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2132 if (!flag_mkernel && !flag_apple_kext
2134 && ! (target_flags_explicit & MASK_ALTIVEC))
2135 target_flags |= MASK_ALTIVEC;
2137 /* Unless the user (not the configurer) has explicitly overridden
2138 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2139 G4 unless targetting the kernel. */
2142 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2143 && ! (target_flags_explicit & MASK_ALTIVEC)
2144 && ! rs6000_select[1].string)
2146 target_flags |= MASK_ALTIVEC;
2151 /* If not otherwise specified by a target, make 'long double' equivalent to
2154 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2155 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2158 /* Override command line options. Mostly we process the processor
2159 type and sometimes adjust other TARGET_ options. */
2162 rs6000_override_options (const char *default_cpu)
2165 struct rs6000_cpu_select *ptr;
2168 /* Simplifications for entries below. */
2171 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
2172 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
2175 /* This table occasionally claims that a processor does not support
2176 a particular feature even though it does, but the feature is slower
2177 than the alternative. Thus, it shouldn't be relied on as a
2178 complete description of the processor's support.
2180 Please keep this list in order, and don't forget to update the
2181 documentation in invoke.texi when adding a new processor or
2185 const char *const name; /* Canonical processor name. */
2186 const enum processor_type processor; /* Processor type enum value. */
2187 const int target_enable; /* Target flags to enable. */
2188 } const processor_target_table[]
2189 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2190 {"403", PROCESSOR_PPC403,
2191 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
2192 {"405", PROCESSOR_PPC405,
2193 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2194 {"405fp", PROCESSOR_PPC405,
2195 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2196 {"440", PROCESSOR_PPC440,
2197 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2198 {"440fp", PROCESSOR_PPC440,
2199 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2200 {"464", PROCESSOR_PPC440,
2201 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2202 {"464fp", PROCESSOR_PPC440,
2203 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2204 {"476", PROCESSOR_PPC476,
2205 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
2206 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2207 {"476fp", PROCESSOR_PPC476,
2208 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
2209 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2210 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
2211 {"601", PROCESSOR_PPC601,
2212 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
2213 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2214 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2215 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2216 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2217 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2218 {"620", PROCESSOR_PPC620,
2219 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2220 {"630", PROCESSOR_PPC630,
2221 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2222 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2223 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
2224 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2225 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2226 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2227 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2228 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2229 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2231 /* 8548 has a dummy entry for now. */
2232 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2234 {"a2", PROCESSOR_PPCA2,
2235 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
2236 | MASK_CMPB | MASK_NO_UPDATE },
2237 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2238 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
2239 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
2241 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
2242 | MASK_PPC_GFXOPT | MASK_ISEL},
2243 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2244 {"970", PROCESSOR_POWER4,
2245 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2246 {"cell", PROCESSOR_CELL,
2247 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2248 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
2249 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2250 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2251 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2252 {"G5", PROCESSOR_POWER4,
2253 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2254 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2255 {"power2", PROCESSOR_POWER,
2256 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2257 {"power3", PROCESSOR_PPC630,
2258 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2259 {"power4", PROCESSOR_POWER4,
2260 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2262 {"power5", PROCESSOR_POWER5,
2263 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2264 | MASK_MFCRF | MASK_POPCNTB},
2265 {"power5+", PROCESSOR_POWER5,
2266 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2267 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
2268 {"power6", PROCESSOR_POWER6,
2269 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2270 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP},
2271 {"power6x", PROCESSOR_POWER6,
2272 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2273 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2275 {"power7", PROCESSOR_POWER7,
2276 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
2277 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
2278 | MASK_VSX}, /* Don't add MASK_ISEL by default */
2279 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
2280 {"powerpc64", PROCESSOR_POWERPC64,
2281 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2282 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2283 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2284 {"rios2", PROCESSOR_RIOS2,
2285 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2286 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2287 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2288 {"rs64", PROCESSOR_RS64A,
2289 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
2292 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
2294 /* Some OSs don't support saving the high part of 64-bit registers on
2295 context switch. Other OSs don't support saving Altivec registers.
2296 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
2297 settings; if the user wants either, the user must explicitly specify
2298 them and we won't interfere with the user's specification. */
2301 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
2302 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
2303 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
2304 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
2305 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
2306 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE)
2309 /* Numerous experiment shows that IRA based loop pressure
2310 calculation works better for RTL loop invariant motion on targets
2311 with enough (>= 32) registers. It is an expensive optimization.
2312 So it is on only for peak performance. */
2314 flag_ira_loop_pressure = 1;
2316 /* Set the pointer size. */
2319 rs6000_pmode = (int)DImode;
2320 rs6000_pointer_size = 64;
2324 rs6000_pmode = (int)SImode;
2325 rs6000_pointer_size = 32;
2328 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2329 #ifdef OS_MISSING_POWERPC64
2330 if (OS_MISSING_POWERPC64)
2331 set_masks &= ~MASK_POWERPC64;
2333 #ifdef OS_MISSING_ALTIVEC
2334 if (OS_MISSING_ALTIVEC)
2335 set_masks &= ~MASK_ALTIVEC;
2338 /* Don't override by the processor default if given explicitly. */
2339 set_masks &= ~target_flags_explicit;
2341 /* Identify the processor type. */
2342 rs6000_select[0].string = default_cpu;
2343 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
2345 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2347 ptr = &rs6000_select[i];
2348 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2350 for (j = 0; j < ptt_size; j++)
2351 if (! strcmp (ptr->string, processor_target_table[j].name))
2353 if (ptr->set_tune_p)
2354 rs6000_cpu = processor_target_table[j].processor;
2356 if (ptr->set_arch_p)
2358 target_flags &= ~set_masks;
2359 target_flags |= (processor_target_table[j].target_enable
2366 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
2370 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2371 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2374 error ("AltiVec not supported in this target");
2376 error ("Spe not supported in this target");
2379 /* Disable Cell microcode if we are optimizing for the Cell
2380 and not optimizing for size. */
2381 if (rs6000_gen_cell_microcode == -1)
2382 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2385 /* If we are optimizing big endian systems for space and it's OK to
2386 use instructions that would be microcoded on the Cell, use the
2387 load/store multiple and string instructions. */
2388 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2389 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2391 /* Don't allow -mmultiple or -mstring on little endian systems
2392 unless the cpu is a 750, because the hardware doesn't support the
2393 instructions used in little endian mode, and causes an alignment
2394 trap. The 750 does not cause an alignment trap (except when the
2395 target is unaligned). */
2397 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2399 if (TARGET_MULTIPLE)
2401 target_flags &= ~MASK_MULTIPLE;
2402 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2403 warning (0, "-mmultiple is not supported on little endian systems");
2408 target_flags &= ~MASK_STRING;
2409 if ((target_flags_explicit & MASK_STRING) != 0)
2410 warning (0, "-mstring is not supported on little endian systems");
2414 /* Add some warnings for VSX. */
2417 const char *msg = NULL;
2418 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2419 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2421 if (target_flags_explicit & MASK_VSX)
2422 msg = N_("-mvsx requires hardware floating point");
2424 target_flags &= ~ MASK_VSX;
2426 else if (TARGET_PAIRED_FLOAT)
2427 msg = N_("-mvsx and -mpaired are incompatible");
2428 /* The hardware will allow VSX and little endian, but until we make sure
2429 things like vector select, etc. work don't allow VSX on little endian
2430 systems at this point. */
2431 else if (!BYTES_BIG_ENDIAN)
2432 msg = N_("-mvsx used with little endian code");
2433 else if (TARGET_AVOID_XFORM > 0)
2434 msg = N_("-mvsx needs indexed addressing");
2435 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2437 if (target_flags_explicit & MASK_VSX)
2438 msg = N_("-mvsx and -mno-altivec are incompatible");
2440 msg = N_("-mno-altivec disables vsx");
2446 target_flags &= ~ MASK_VSX;
2448 else if (TARGET_VSX && !TARGET_ALTIVEC)
2449 target_flags |= MASK_ALTIVEC;
2452 /* Set debug flags */
2453 if (rs6000_debug_name)
2455 if (! strcmp (rs6000_debug_name, "all"))
2456 rs6000_debug_stack = rs6000_debug_arg = rs6000_debug_reg
2457 = rs6000_debug_addr = rs6000_debug_cost = 1;
2458 else if (! strcmp (rs6000_debug_name, "stack"))
2459 rs6000_debug_stack = 1;
2460 else if (! strcmp (rs6000_debug_name, "arg"))
2461 rs6000_debug_arg = 1;
2462 else if (! strcmp (rs6000_debug_name, "reg"))
2463 rs6000_debug_reg = 1;
2464 else if (! strcmp (rs6000_debug_name, "addr"))
2465 rs6000_debug_addr = 1;
2466 else if (! strcmp (rs6000_debug_name, "cost"))
2467 rs6000_debug_cost = 1;
2469 error ("unknown -mdebug-%s switch", rs6000_debug_name);
2471 /* If the appropriate debug option is enabled, replace the target hooks
2472 with debug versions that call the real version and then prints
2473 debugging information. */
2474 if (TARGET_DEBUG_COST)
2476 targetm.rtx_costs = rs6000_debug_rtx_costs;
2477 targetm.address_cost = rs6000_debug_address_cost;
2478 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2481 if (TARGET_DEBUG_ADDR)
2483 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2484 targetm.legitimize_address = rs6000_debug_legitimize_address;
2485 rs6000_secondary_reload_class_ptr
2486 = rs6000_debug_secondary_reload_class;
2487 rs6000_secondary_memory_needed_ptr
2488 = rs6000_debug_secondary_memory_needed;
2489 rs6000_cannot_change_mode_class_ptr
2490 = rs6000_debug_cannot_change_mode_class;
2491 rs6000_preferred_reload_class_ptr
2492 = rs6000_debug_preferred_reload_class;
2493 rs6000_legitimize_reload_address_ptr
2494 = rs6000_debug_legitimize_reload_address;
2495 rs6000_mode_dependent_address_ptr
2496 = rs6000_debug_mode_dependent_address;
2500 if (rs6000_traceback_name)
2502 if (! strncmp (rs6000_traceback_name, "full", 4))
2503 rs6000_traceback = traceback_full;
2504 else if (! strncmp (rs6000_traceback_name, "part", 4))
2505 rs6000_traceback = traceback_part;
2506 else if (! strncmp (rs6000_traceback_name, "no", 2))
2507 rs6000_traceback = traceback_none;
2509 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
2510 rs6000_traceback_name);
2513 if (!rs6000_explicit_options.long_double)
2514 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2516 #ifndef POWERPC_LINUX
2517 if (!rs6000_explicit_options.ieee)
2518 rs6000_ieeequad = 1;
2521 /* Enable Altivec ABI for AIX -maltivec. */
2522 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2523 rs6000_altivec_abi = 1;
2525 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2526 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2527 be explicitly overridden in either case. */
2530 if (!rs6000_explicit_options.altivec_abi
2531 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2532 rs6000_altivec_abi = 1;
2534 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2535 if (!rs6000_explicit_options.vrsave)
2536 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2539 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
2540 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2542 rs6000_darwin64_abi = 1;
2544 darwin_one_byte_bool = 1;
2546 /* Default to natural alignment, for better performance. */
2547 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2550 /* Place FP constants in the constant pool instead of TOC
2551 if section anchors enabled. */
2552 if (flag_section_anchors)
2553 TARGET_NO_FP_IN_TOC = 1;
2555 /* Handle -mtls-size option. */
2556 rs6000_parse_tls_size_option ();
2558 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2559 SUBTARGET_OVERRIDE_OPTIONS;
2561 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2562 SUBSUBTARGET_OVERRIDE_OPTIONS;
2564 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2565 SUB3TARGET_OVERRIDE_OPTIONS;
2568 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2569 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2571 /* The e500 and e500mc do not have string instructions, and we set
2572 MASK_STRING above when optimizing for size. */
2573 if ((target_flags & MASK_STRING) != 0)
2574 target_flags = target_flags & ~MASK_STRING;
2576 else if (rs6000_select[1].string != NULL)
2578 /* For the powerpc-eabispe configuration, we set all these by
2579 default, so let's unset them if we manually set another
2580 CPU that is not the E500. */
2581 if (!rs6000_explicit_options.spe_abi)
2583 if (!rs6000_explicit_options.spe)
2585 if (!rs6000_explicit_options.float_gprs)
2586 rs6000_float_gprs = 0;
2587 if (!(target_flags_explicit & MASK_ISEL))
2588 target_flags &= ~MASK_ISEL;
2591 /* Detect invalid option combinations with E500. */
2594 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
2595 && rs6000_cpu != PROCESSOR_POWER5
2596 && rs6000_cpu != PROCESSOR_POWER6
2597 && rs6000_cpu != PROCESSOR_POWER7
2598 && rs6000_cpu != PROCESSOR_PPCA2
2599 && rs6000_cpu != PROCESSOR_CELL);
2600 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
2601 || rs6000_cpu == PROCESSOR_POWER5
2602 || rs6000_cpu == PROCESSOR_POWER7);
2603 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
2604 || rs6000_cpu == PROCESSOR_POWER5
2605 || rs6000_cpu == PROCESSOR_POWER6
2606 || rs6000_cpu == PROCESSOR_POWER7
2607 || rs6000_cpu == PROCESSOR_PPCE500MC
2608 || rs6000_cpu == PROCESSOR_PPCE500MC64);
2610 /* Allow debug switches to override the above settings. */
2611 if (TARGET_ALWAYS_HINT > 0)
2612 rs6000_always_hint = TARGET_ALWAYS_HINT;
2614 if (TARGET_SCHED_GROUPS > 0)
2615 rs6000_sched_groups = TARGET_SCHED_GROUPS;
2617 if (TARGET_ALIGN_BRANCH_TARGETS > 0)
2618 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
2620 rs6000_sched_restricted_insns_priority
2621 = (rs6000_sched_groups ? 1 : 0);
2623 /* Handle -msched-costly-dep option. */
2624 rs6000_sched_costly_dep
2625 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
2627 if (rs6000_sched_costly_dep_str)
2629 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
2630 rs6000_sched_costly_dep = no_dep_costly;
2631 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
2632 rs6000_sched_costly_dep = all_deps_costly;
2633 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
2634 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
2635 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
2636 rs6000_sched_costly_dep = store_to_load_dep_costly;
2638 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
2639 atoi (rs6000_sched_costly_dep_str));
2642 /* Handle -minsert-sched-nops option. */
2643 rs6000_sched_insert_nops
2644 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
2646 if (rs6000_sched_insert_nops_str)
2648 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
2649 rs6000_sched_insert_nops = sched_finish_none;
2650 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
2651 rs6000_sched_insert_nops = sched_finish_pad_groups;
2652 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
2653 rs6000_sched_insert_nops = sched_finish_regroup_exact;
2655 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
2656 atoi (rs6000_sched_insert_nops_str));
2659 #ifdef TARGET_REGNAMES
2660 /* If the user desires alternate register names, copy in the
2661 alternate names now. */
2662 if (TARGET_REGNAMES)
2663 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
2666 /* Set aix_struct_return last, after the ABI is determined.
2667 If -maix-struct-return or -msvr4-struct-return was explicitly
2668 used, don't override with the ABI default. */
2669 if (!rs6000_explicit_options.aix_struct_ret)
2670 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
2672 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
2673 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
2676 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
2678 /* We can only guarantee the availability of DI pseudo-ops when
2679 assembling for 64-bit targets. */
2682 targetm.asm_out.aligned_op.di = NULL;
2683 targetm.asm_out.unaligned_op.di = NULL;
2686 /* Set branch target alignment, if not optimizing for size. */
2689 /* Cell wants to be aligned 8byte for dual issue. */
2690 if (rs6000_cpu == PROCESSOR_CELL)
2692 if (align_functions <= 0)
2693 align_functions = 8;
2694 if (align_jumps <= 0)
2696 if (align_loops <= 0)
2699 if (rs6000_align_branch_targets)
2701 if (align_functions <= 0)
2702 align_functions = 16;
2703 if (align_jumps <= 0)
2705 if (align_loops <= 0)
2708 if (align_jumps_max_skip <= 0)
2709 align_jumps_max_skip = 15;
2710 if (align_loops_max_skip <= 0)
2711 align_loops_max_skip = 15;
2714 /* Arrange to save and restore machine status around nested functions. */
2715 init_machine_status = rs6000_init_machine_status;
2717 /* We should always be splitting complex arguments, but we can't break
2718 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
2719 if (DEFAULT_ABI != ABI_AIX)
2720 targetm.calls.split_complex_arg = NULL;
2722 /* Initialize rs6000_cost with the appropriate target costs. */
2724 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
2728 case PROCESSOR_RIOS1:
2729 rs6000_cost = &rios1_cost;
2732 case PROCESSOR_RIOS2:
2733 rs6000_cost = &rios2_cost;
2736 case PROCESSOR_RS64A:
2737 rs6000_cost = &rs64a_cost;
2740 case PROCESSOR_MPCCORE:
2741 rs6000_cost = &mpccore_cost;
2744 case PROCESSOR_PPC403:
2745 rs6000_cost = &ppc403_cost;
2748 case PROCESSOR_PPC405:
2749 rs6000_cost = &ppc405_cost;
2752 case PROCESSOR_PPC440:
2753 rs6000_cost = &ppc440_cost;
2756 case PROCESSOR_PPC476:
2757 rs6000_cost = &ppc476_cost;
2760 case PROCESSOR_PPC601:
2761 rs6000_cost = &ppc601_cost;
2764 case PROCESSOR_PPC603:
2765 rs6000_cost = &ppc603_cost;
2768 case PROCESSOR_PPC604:
2769 rs6000_cost = &ppc604_cost;
2772 case PROCESSOR_PPC604e:
2773 rs6000_cost = &ppc604e_cost;
2776 case PROCESSOR_PPC620:
2777 rs6000_cost = &ppc620_cost;
2780 case PROCESSOR_PPC630:
2781 rs6000_cost = &ppc630_cost;
2784 case PROCESSOR_CELL:
2785 rs6000_cost = &ppccell_cost;
2788 case PROCESSOR_PPC750:
2789 case PROCESSOR_PPC7400:
2790 rs6000_cost = &ppc750_cost;
2793 case PROCESSOR_PPC7450:
2794 rs6000_cost = &ppc7450_cost;
2797 case PROCESSOR_PPC8540:
2798 rs6000_cost = &ppc8540_cost;
2801 case PROCESSOR_PPCE300C2:
2802 case PROCESSOR_PPCE300C3:
2803 rs6000_cost = &ppce300c2c3_cost;
2806 case PROCESSOR_PPCE500MC:
2807 rs6000_cost = &ppce500mc_cost;
2810 case PROCESSOR_PPCE500MC64:
2811 rs6000_cost = &ppce500mc64_cost;
2814 case PROCESSOR_POWER4:
2815 case PROCESSOR_POWER5:
2816 rs6000_cost = &power4_cost;
2819 case PROCESSOR_POWER6:
2820 rs6000_cost = &power6_cost;
2823 case PROCESSOR_POWER7:
2824 rs6000_cost = &power7_cost;
2827 case PROCESSOR_PPCA2:
2828 rs6000_cost = &ppca2_cost;
2835 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
2836 set_param_value ("simultaneous-prefetches",
2837 rs6000_cost->simultaneous_prefetches);
2838 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
2839 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
2840 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
2841 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
2842 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
2843 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
2845 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2846 can be optimized to ap = __builtin_next_arg (0). */
2847 if (DEFAULT_ABI != ABI_V4)
2848 targetm.expand_builtin_va_start = NULL;
2850 /* Set up single/double float flags.
2851 If TARGET_HARD_FLOAT is set, but neither single or double is set,
2852 then set both flags. */
2853 if (TARGET_HARD_FLOAT && TARGET_FPRS
2854 && rs6000_single_float == 0 && rs6000_double_float == 0)
2855 rs6000_single_float = rs6000_double_float = 1;
2857 /* Reset single and double FP flags if target is E500. */
2860 rs6000_single_float = rs6000_double_float = 0;
2861 if (TARGET_E500_SINGLE)
2862 rs6000_single_float = 1;
2863 if (TARGET_E500_DOUBLE)
2864 rs6000_single_float = rs6000_double_float = 1;
2867 /* If not explicitly specified via option, decide whether to generate indexed
2868 load/store instructions. */
2869 if (TARGET_AVOID_XFORM == -1)
2870 /* Avoid indexed addressing when targeting Power6 in order to avoid
2871 the DERAT mispredict penalty. */
2872 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB);
2874 rs6000_init_hard_regno_mode_ok ();
2877 /* Implement targetm.vectorize.builtin_mask_for_load. */
2879 rs6000_builtin_mask_for_load (void)
2881 if (TARGET_ALTIVEC || TARGET_VSX)
2882 return altivec_builtin_mask_for_load;
2887 /* Implement targetm.vectorize.builtin_conversion.
2888 Returns a decl of a function that implements conversion of an integer vector
2889 into a floating-point vector, or vice-versa. DEST_TYPE is the
2890 destination type and SRC_TYPE the source type of the conversion.
2891 Return NULL_TREE if it is not available. */
2893 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
2895 enum tree_code code = (enum tree_code) tcode;
2899 case FIX_TRUNC_EXPR:
2900 switch (TYPE_MODE (dest_type))
2903 if (!VECTOR_UNIT_VSX_P (V2DFmode))
2906 return TYPE_UNSIGNED (dest_type)
2907 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
2908 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
2911 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
2914 return TYPE_UNSIGNED (dest_type)
2915 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
2916 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
2923 switch (TYPE_MODE (src_type))
2926 if (!VECTOR_UNIT_VSX_P (V2DFmode))
2929 return TYPE_UNSIGNED (src_type)
2930 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
2931 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
2934 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
2937 return TYPE_UNSIGNED (src_type)
2938 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
2939 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
2950 /* Implement targetm.vectorize.builtin_mul_widen_even. */
2952 rs6000_builtin_mul_widen_even (tree type)
2954 if (!TARGET_ALTIVEC)
2957 switch (TYPE_MODE (type))
2960 return TYPE_UNSIGNED (type)
2961 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
2962 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
2965 return TYPE_UNSIGNED (type)
2966 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
2967 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
2973 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
2975 rs6000_builtin_mul_widen_odd (tree type)
2977 if (!TARGET_ALTIVEC)
2980 switch (TYPE_MODE (type))
2983 return TYPE_UNSIGNED (type)
2984 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
2985 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
2988 return TYPE_UNSIGNED (type)
2989 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
2990 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
2997 /* Return true iff, data reference of TYPE can reach vector alignment (16)
2998 after applying N number of iterations. This routine does not determine
2999 how may iterations are required to reach desired alignment. */
3002 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3009 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3012 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3022 /* Assuming that all other types are naturally aligned. CHECKME! */
3027 /* Return true if the vector misalignment factor is supported by the
3030 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3037 /* Return if movmisalign pattern is not supported for this mode. */
3038 if (optab_handler (movmisalign_optab, mode)->insn_code ==
3042 if (misalignment == -1)
3044 /* misalignment factor is unknown at compile time but we know
3045 it's word aligned. */
3046 if (rs6000_vector_alignment_reachable (type, is_packed))
3050 /* VSX supports word-aligned vector. */
3051 if (misalignment % 4 == 0)
3057 /* Implement targetm.vectorize.builtin_vec_perm. */
3059 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
3061 tree inner_type = TREE_TYPE (type);
3062 bool uns_p = TYPE_UNSIGNED (inner_type);
3065 *mask_element_type = unsigned_char_type_node;
3067 switch (TYPE_MODE (type))
3071 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI_UNS]
3072 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI]);
3077 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI_UNS]
3078 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI]);
3083 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI_UNS]
3084 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI]);
3088 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
3092 if (!TARGET_ALLOW_DF_PERMUTE)
3095 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DF];
3099 if (!TARGET_ALLOW_DF_PERMUTE)
3103 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI_UNS]
3104 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI]);
3115 /* Handle generic options of the form -mfoo=yes/no.
3116 NAME is the option name.
3117 VALUE is the option value.
3118 FLAG is the pointer to the flag where to store a 1 or 0, depending on
3119 whether the option value is 'yes' or 'no' respectively. */
3121 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
3125 else if (!strcmp (value, "yes"))
3127 else if (!strcmp (value, "no"))
3130 error ("unknown -m%s= option specified: '%s'", name, value);
3133 /* Validate and record the size specified with the -mtls-size option. */
3136 rs6000_parse_tls_size_option (void)
3138 if (rs6000_tls_size_string == 0)
3140 else if (strcmp (rs6000_tls_size_string, "16") == 0)
3141 rs6000_tls_size = 16;
3142 else if (strcmp (rs6000_tls_size_string, "32") == 0)
3143 rs6000_tls_size = 32;
3144 else if (strcmp (rs6000_tls_size_string, "64") == 0)
3145 rs6000_tls_size = 64;
3147 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
3151 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
3153 if (DEFAULT_ABI == ABI_DARWIN)
3154 /* The Darwin libraries never set errno, so we might as well
3155 avoid calling them when that's the only reason we would. */
3156 flag_errno_math = 0;
3158 /* Double growth factor to counter reduced min jump length. */
3159 set_param_value ("max-grow-copy-bb-insns", 16);
3161 /* Enable section anchors by default.
3162 Skip section anchors for Objective C and Objective C++
3163 until front-ends fixed. */
3164 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
3165 flag_section_anchors = 2;
3168 static enum fpu_type_t
3169 rs6000_parse_fpu_option (const char *option)
3171 if (!strcmp("none", option)) return FPU_NONE;
3172 if (!strcmp("sp_lite", option)) return FPU_SF_LITE;
3173 if (!strcmp("dp_lite", option)) return FPU_DF_LITE;
3174 if (!strcmp("sp_full", option)) return FPU_SF_FULL;
3175 if (!strcmp("dp_full", option)) return FPU_DF_FULL;
3176 error("unknown value %s for -mfpu", option);
3180 /* Returns a function decl for a vectorized version of the builtin function
3181 with builtin function code FN and the result vector type TYPE, or NULL_TREE
3182 if it is not available. */
3185 rs6000_builtin_vectorized_function (tree fndecl, tree type_out,
3188 enum machine_mode in_mode, out_mode;
3190 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3192 if (TREE_CODE (type_out) != VECTOR_TYPE
3193 || TREE_CODE (type_in) != VECTOR_TYPE
3194 || !TARGET_VECTORIZE_BUILTINS
3195 || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
3198 out_mode = TYPE_MODE (TREE_TYPE (type_out));
3199 out_n = TYPE_VECTOR_SUBPARTS (type_out);
3200 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3201 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3205 case BUILT_IN_COPYSIGN:
3206 if (VECTOR_UNIT_VSX_P (V2DFmode)
3207 && out_mode == DFmode && out_n == 2
3208 && in_mode == DFmode && in_n == 2)
3209 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNDP];
3211 case BUILT_IN_COPYSIGNF:
3212 if (out_mode != SFmode || out_n != 4
3213 || in_mode != SFmode || in_n != 4)
3215 if (VECTOR_UNIT_VSX_P (V4SFmode))
3216 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNSP];
3217 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3218 return rs6000_builtin_decls[ALTIVEC_BUILTIN_COPYSIGN_V4SF];
3221 if (VECTOR_UNIT_VSX_P (V2DFmode)
3222 && out_mode == DFmode && out_n == 2
3223 && in_mode == DFmode && in_n == 2)
3224 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTDP];
3226 case BUILT_IN_SQRTF:
3227 if (VECTOR_UNIT_VSX_P (V4SFmode)
3228 && out_mode == SFmode && out_n == 4
3229 && in_mode == SFmode && in_n == 4)
3230 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTSP];
3233 if (VECTOR_UNIT_VSX_P (V2DFmode)
3234 && out_mode == DFmode && out_n == 2
3235 && in_mode == DFmode && in_n == 2)
3236 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIP];
3238 case BUILT_IN_CEILF:
3239 if (out_mode != SFmode || out_n != 4
3240 || in_mode != SFmode || in_n != 4)
3242 if (VECTOR_UNIT_VSX_P (V4SFmode))
3243 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIP];
3244 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3245 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIP];
3247 case BUILT_IN_FLOOR:
3248 if (VECTOR_UNIT_VSX_P (V2DFmode)
3249 && out_mode == DFmode && out_n == 2
3250 && in_mode == DFmode && in_n == 2)
3251 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIM];
3253 case BUILT_IN_FLOORF:
3254 if (out_mode != SFmode || out_n != 4
3255 || in_mode != SFmode || in_n != 4)
3257 if (VECTOR_UNIT_VSX_P (V4SFmode))
3258 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIM];
3259 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3260 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIM];
3262 case BUILT_IN_TRUNC:
3263 if (VECTOR_UNIT_VSX_P (V2DFmode)
3264 && out_mode == DFmode && out_n == 2
3265 && in_mode == DFmode && in_n == 2)
3266 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIZ];
3268 case BUILT_IN_TRUNCF:
3269 if (out_mode != SFmode || out_n != 4
3270 || in_mode != SFmode || in_n != 4)
3272 if (VECTOR_UNIT_VSX_P (V4SFmode))
3273 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIZ];
3274 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3275 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIZ];
3277 case BUILT_IN_NEARBYINT:
3278 if (VECTOR_UNIT_VSX_P (V2DFmode)
3279 && flag_unsafe_math_optimizations
3280 && out_mode == DFmode && out_n == 2
3281 && in_mode == DFmode && in_n == 2)
3282 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPI];
3284 case BUILT_IN_NEARBYINTF:
3285 if (VECTOR_UNIT_VSX_P (V4SFmode)
3286 && flag_unsafe_math_optimizations
3287 && out_mode == SFmode && out_n == 4
3288 && in_mode == SFmode && in_n == 4)
3289 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPI];
3292 if (VECTOR_UNIT_VSX_P (V2DFmode)
3293 && !flag_trapping_math
3294 && out_mode == DFmode && out_n == 2
3295 && in_mode == DFmode && in_n == 2)
3296 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIC];
3298 case BUILT_IN_RINTF:
3299 if (VECTOR_UNIT_VSX_P (V4SFmode)
3300 && !flag_trapping_math
3301 && out_mode == SFmode && out_n == 4
3302 && in_mode == SFmode && in_n == 4)
3303 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIC];
3312 /* Implement TARGET_HANDLE_OPTION. */
3315 rs6000_handle_option (size_t code, const char *arg, int value)
3317 enum fpu_type_t fpu_type = FPU_NONE;
3323 target_flags &= ~(MASK_POWER | MASK_POWER2
3324 | MASK_MULTIPLE | MASK_STRING);
3325 target_flags_explicit |= (MASK_POWER | MASK_POWER2
3326 | MASK_MULTIPLE | MASK_STRING);
3328 case OPT_mno_powerpc:
3329 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
3330 | MASK_PPC_GFXOPT | MASK_POWERPC64);
3331 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
3332 | MASK_PPC_GFXOPT | MASK_POWERPC64);
3335 target_flags &= ~MASK_MINIMAL_TOC;
3336 TARGET_NO_FP_IN_TOC = 0;
3337 TARGET_NO_SUM_IN_TOC = 0;
3338 target_flags_explicit |= MASK_MINIMAL_TOC;
3339 #ifdef TARGET_USES_SYSV4_OPT
3340 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
3341 just the same as -mminimal-toc. */
3342 target_flags |= MASK_MINIMAL_TOC;
3343 target_flags_explicit |= MASK_MINIMAL_TOC;
3347 #ifdef TARGET_USES_SYSV4_OPT
3349 /* Make -mtoc behave like -mminimal-toc. */
3350 target_flags |= MASK_MINIMAL_TOC;
3351 target_flags_explicit |= MASK_MINIMAL_TOC;
3355 #ifdef TARGET_USES_AIX64_OPT
3360 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
3361 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
3362 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
3365 #ifdef TARGET_USES_AIX64_OPT
3370 target_flags &= ~MASK_POWERPC64;
3371 target_flags_explicit |= MASK_POWERPC64;
3374 case OPT_minsert_sched_nops_:
3375 rs6000_sched_insert_nops_str = arg;
3378 case OPT_mminimal_toc:
3381 TARGET_NO_FP_IN_TOC = 0;
3382 TARGET_NO_SUM_IN_TOC = 0;
3389 target_flags |= (MASK_MULTIPLE | MASK_STRING);
3390 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
3397 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
3398 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);