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"
30 #include "insn-config.h"
31 #include "conditions.h"
32 #include "insn-attr.h"
42 #include "basic-block.h"
43 #include "integrate.h"
44 #include "diagnostic-core.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 /* Some local-dynamic symbol. */
119 const char *some_ld_name;
120 /* Whether the instruction chain has been scanned already. */
121 int insn_chain_scanned_p;
122 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
123 int ra_needs_full_frame;
124 /* Flags if __builtin_return_address (0) was used. */
126 /* Cache lr_save_p after expansion of builtin_eh_return. */
128 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
129 varargs save area. */
130 HOST_WIDE_INT varargs_save_offset;
131 /* Temporary stack slot to use for SDmode copies. This slot is
132 64-bits wide and is allocated early enough so that the offset
133 does not overflow the 16-bit load/store offset field. */
134 rtx sdmode_stack_slot;
137 /* Target cpu type */
139 enum processor_type rs6000_cpu;
140 struct rs6000_cpu_select rs6000_select[3] =
142 /* switch name, tune arch */
143 { (const char *)0, "--with-cpu=", 1, 1 },
144 { (const char *)0, "-mcpu=", 1, 1 },
145 { (const char *)0, "-mtune=", 1, 0 },
148 /* Always emit branch hint bits. */
149 static GTY(()) bool rs6000_always_hint;
151 /* Schedule instructions for group formation. */
152 static GTY(()) bool rs6000_sched_groups;
154 /* Align branch targets. */
155 static GTY(()) bool rs6000_align_branch_targets;
157 /* Support for -msched-costly-dep option. */
158 const char *rs6000_sched_costly_dep_str;
159 enum rs6000_dependence_cost rs6000_sched_costly_dep;
161 /* Support for -minsert-sched-nops option. */
162 const char *rs6000_sched_insert_nops_str;
163 enum rs6000_nop_insertion rs6000_sched_insert_nops;
165 /* Support targetm.vectorize.builtin_mask_for_load. */
166 static GTY(()) tree altivec_builtin_mask_for_load;
168 /* Size of long double. */
169 int rs6000_long_double_type_size;
171 /* IEEE quad extended precision long double. */
174 /* Nonzero to use AltiVec ABI. */
175 int rs6000_altivec_abi;
177 /* Nonzero if we want SPE SIMD instructions. */
180 /* Nonzero if we want SPE ABI extensions. */
183 /* Nonzero if floating point operations are done in the GPRs. */
184 int rs6000_float_gprs = 0;
186 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
187 int rs6000_darwin64_abi;
189 /* Set to nonzero once AIX common-mode calls have been defined. */
190 static GTY(()) int common_mode_defined;
192 /* Label number of label created for -mrelocatable, to call to so we can
193 get the address of the GOT section */
194 int rs6000_pic_labelno;
197 /* Which abi to adhere to */
198 const char *rs6000_abi_name;
200 /* Semantics of the small data area */
201 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
203 /* Which small data model to use */
204 const char *rs6000_sdata_name = (char *)0;
206 /* Counter for labels which are to be placed in .fixup. */
207 int fixuplabelno = 0;
210 /* Bit size of immediate TLS offsets and string from which it is decoded. */
211 int rs6000_tls_size = 32;
212 const char *rs6000_tls_size_string;
214 /* ABI enumeration available for subtarget to use. */
215 enum rs6000_abi rs6000_current_abi;
217 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
221 const char *rs6000_debug_name;
222 int rs6000_debug_stack; /* debug stack applications */
223 int rs6000_debug_arg; /* debug argument handling */
224 int rs6000_debug_reg; /* debug register classes */
225 int rs6000_debug_addr; /* debug memory addressing */
226 int rs6000_debug_cost; /* debug rtx_costs */
228 /* Specify the machine mode that pointers have. After generation of rtl, the
229 compiler makes no further distinction between pointers and any other objects
230 of this machine mode. The type is unsigned since not all things that
231 include rs6000.h also include machmode.h. */
232 unsigned rs6000_pmode;
234 /* Width in bits of a pointer. */
235 unsigned rs6000_pointer_size;
238 /* Value is TRUE if register/mode pair is acceptable. */
239 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
241 /* Maximum number of registers needed for a given register class and mode. */
242 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
244 /* How many registers are needed for a given register and mode. */
245 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
247 /* Map register number to register class. */
248 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
250 /* Reload functions based on the type and the vector unit. */
251 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
253 /* Built in types. */
254 tree rs6000_builtin_types[RS6000_BTI_MAX];
255 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
257 const char *rs6000_traceback_name;
259 traceback_default = 0,
265 /* Flag to say the TOC is initialized */
267 char toc_label_name[10];
269 /* Cached value of rs6000_variable_issue. This is cached in
270 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
271 static short cached_can_issue_more;
273 static GTY(()) section *read_only_data_section;
274 static GTY(()) section *private_data_section;
275 static GTY(()) section *read_only_private_data_section;
276 static GTY(()) section *sdata2_section;
277 static GTY(()) section *toc_section;
279 /* Control alignment for fields within structures. */
280 /* String from -malign-XXXXX. */
281 int rs6000_alignment_flags;
283 /* Code model for 64-bit linux. */
284 enum rs6000_cmodel cmodel;
286 /* True for any options that were explicitly set. */
288 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
289 bool alignment; /* True if -malign- was used. */
290 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
291 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
292 bool spe; /* True if -mspe= was used. */
293 bool float_gprs; /* True if -mfloat-gprs= was used. */
294 bool long_double; /* True if -mlong-double- was used. */
295 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
296 bool vrsave; /* True if -mvrsave was used. */
297 bool cmodel; /* True if -mcmodel was used. */
298 } rs6000_explicit_options;
300 struct builtin_description
302 /* mask is not const because we're going to alter it below. This
303 nonsense will go away when we rewrite the -march infrastructure
304 to give us more target flag bits. */
306 const enum insn_code icode;
307 const char *const name;
308 const enum rs6000_builtins code;
311 /* Describe the vector unit used for modes. */
312 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
313 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
315 /* Register classes for various constraints that are based on the target
317 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
319 /* Describe the alignment of a vector. */
320 int rs6000_vector_align[NUM_MACHINE_MODES];
322 /* Map selected modes to types for builtins. */
323 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
325 /* What modes to automatically generate reciprocal divide estimate (fre) and
326 reciprocal sqrt (frsqrte) for. */
327 unsigned char rs6000_recip_bits[MAX_MACHINE_MODE];
329 /* Masks to determine which reciprocal esitmate instructions to generate
331 enum rs6000_recip_mask {
332 RECIP_SF_DIV = 0x001, /* Use divide estimate */
333 RECIP_DF_DIV = 0x002,
334 RECIP_V4SF_DIV = 0x004,
335 RECIP_V2DF_DIV = 0x008,
337 RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */
338 RECIP_DF_RSQRT = 0x020,
339 RECIP_V4SF_RSQRT = 0x040,
340 RECIP_V2DF_RSQRT = 0x080,
342 /* Various combination of flags for -mrecip=xxx. */
344 RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
345 | RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT
346 | RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT),
348 RECIP_HIGH_PRECISION = RECIP_ALL,
350 /* On low precision machines like the power5, don't enable double precision
351 reciprocal square root estimate, since it isn't accurate enough. */
352 RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT))
355 static unsigned int rs6000_recip_control;
356 static const char *rs6000_recip_name;
358 /* -mrecip options. */
361 const char *string; /* option name */
362 unsigned int mask; /* mask bits to set */
363 } recip_options[] = {
364 { "all", RECIP_ALL },
365 { "none", RECIP_NONE },
366 { "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
368 { "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) },
369 { "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) },
370 { "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT
371 | RECIP_V2DF_RSQRT) },
372 { "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) },
373 { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) },
376 /* 2 argument gen function typedef. */
377 typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx);
380 /* Target cpu costs. */
382 struct processor_costs {
383 const int mulsi; /* cost of SImode multiplication. */
384 const int mulsi_const; /* cost of SImode multiplication by constant. */
385 const int mulsi_const9; /* cost of SImode mult by short constant. */
386 const int muldi; /* cost of DImode multiplication. */
387 const int divsi; /* cost of SImode division. */
388 const int divdi; /* cost of DImode division. */
389 const int fp; /* cost of simple SFmode and DFmode insns. */
390 const int dmul; /* cost of DFmode multiplication (and fmadd). */
391 const int sdiv; /* cost of SFmode division (fdivs). */
392 const int ddiv; /* cost of DFmode division (fdiv). */
393 const int cache_line_size; /* cache line size in bytes. */
394 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
395 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
396 const int simultaneous_prefetches; /* number of parallel prefetch
400 const struct processor_costs *rs6000_cost;
402 /* Processor costs (relative to an add) */
404 /* Instruction size costs on 32bit processors. */
406 struct processor_costs size32_cost = {
407 COSTS_N_INSNS (1), /* mulsi */
408 COSTS_N_INSNS (1), /* mulsi_const */
409 COSTS_N_INSNS (1), /* mulsi_const9 */
410 COSTS_N_INSNS (1), /* muldi */
411 COSTS_N_INSNS (1), /* divsi */
412 COSTS_N_INSNS (1), /* divdi */
413 COSTS_N_INSNS (1), /* fp */
414 COSTS_N_INSNS (1), /* dmul */
415 COSTS_N_INSNS (1), /* sdiv */
416 COSTS_N_INSNS (1), /* ddiv */
423 /* Instruction size costs on 64bit processors. */
425 struct processor_costs size64_cost = {
426 COSTS_N_INSNS (1), /* mulsi */
427 COSTS_N_INSNS (1), /* mulsi_const */
428 COSTS_N_INSNS (1), /* mulsi_const9 */
429 COSTS_N_INSNS (1), /* muldi */
430 COSTS_N_INSNS (1), /* divsi */
431 COSTS_N_INSNS (1), /* divdi */
432 COSTS_N_INSNS (1), /* fp */
433 COSTS_N_INSNS (1), /* dmul */
434 COSTS_N_INSNS (1), /* sdiv */
435 COSTS_N_INSNS (1), /* ddiv */
442 /* Instruction costs on RIOS1 processors. */
444 struct processor_costs rios1_cost = {
445 COSTS_N_INSNS (5), /* mulsi */
446 COSTS_N_INSNS (4), /* mulsi_const */
447 COSTS_N_INSNS (3), /* mulsi_const9 */
448 COSTS_N_INSNS (5), /* muldi */
449 COSTS_N_INSNS (19), /* divsi */
450 COSTS_N_INSNS (19), /* divdi */
451 COSTS_N_INSNS (2), /* fp */
452 COSTS_N_INSNS (2), /* dmul */
453 COSTS_N_INSNS (19), /* sdiv */
454 COSTS_N_INSNS (19), /* ddiv */
455 128, /* cache line size */
461 /* Instruction costs on RIOS2 processors. */
463 struct processor_costs rios2_cost = {
464 COSTS_N_INSNS (2), /* mulsi */
465 COSTS_N_INSNS (2), /* mulsi_const */
466 COSTS_N_INSNS (2), /* mulsi_const9 */
467 COSTS_N_INSNS (2), /* muldi */
468 COSTS_N_INSNS (13), /* divsi */
469 COSTS_N_INSNS (13), /* divdi */
470 COSTS_N_INSNS (2), /* fp */
471 COSTS_N_INSNS (2), /* dmul */
472 COSTS_N_INSNS (17), /* sdiv */
473 COSTS_N_INSNS (17), /* ddiv */
474 256, /* cache line size */
480 /* Instruction costs on RS64A processors. */
482 struct processor_costs rs64a_cost = {
483 COSTS_N_INSNS (20), /* mulsi */
484 COSTS_N_INSNS (12), /* mulsi_const */
485 COSTS_N_INSNS (8), /* mulsi_const9 */
486 COSTS_N_INSNS (34), /* muldi */
487 COSTS_N_INSNS (65), /* divsi */
488 COSTS_N_INSNS (67), /* divdi */
489 COSTS_N_INSNS (4), /* fp */
490 COSTS_N_INSNS (4), /* dmul */
491 COSTS_N_INSNS (31), /* sdiv */
492 COSTS_N_INSNS (31), /* ddiv */
493 128, /* cache line size */
499 /* Instruction costs on MPCCORE processors. */
501 struct processor_costs mpccore_cost = {
502 COSTS_N_INSNS (2), /* mulsi */
503 COSTS_N_INSNS (2), /* mulsi_const */
504 COSTS_N_INSNS (2), /* mulsi_const9 */
505 COSTS_N_INSNS (2), /* muldi */
506 COSTS_N_INSNS (6), /* divsi */
507 COSTS_N_INSNS (6), /* divdi */
508 COSTS_N_INSNS (4), /* fp */
509 COSTS_N_INSNS (5), /* dmul */
510 COSTS_N_INSNS (10), /* sdiv */
511 COSTS_N_INSNS (17), /* ddiv */
512 32, /* cache line size */
518 /* Instruction costs on PPC403 processors. */
520 struct processor_costs ppc403_cost = {
521 COSTS_N_INSNS (4), /* mulsi */
522 COSTS_N_INSNS (4), /* mulsi_const */
523 COSTS_N_INSNS (4), /* mulsi_const9 */
524 COSTS_N_INSNS (4), /* muldi */
525 COSTS_N_INSNS (33), /* divsi */
526 COSTS_N_INSNS (33), /* divdi */
527 COSTS_N_INSNS (11), /* fp */
528 COSTS_N_INSNS (11), /* dmul */
529 COSTS_N_INSNS (11), /* sdiv */
530 COSTS_N_INSNS (11), /* ddiv */
531 32, /* cache line size */
537 /* Instruction costs on PPC405 processors. */
539 struct processor_costs ppc405_cost = {
540 COSTS_N_INSNS (5), /* mulsi */
541 COSTS_N_INSNS (4), /* mulsi_const */
542 COSTS_N_INSNS (3), /* mulsi_const9 */
543 COSTS_N_INSNS (5), /* muldi */
544 COSTS_N_INSNS (35), /* divsi */
545 COSTS_N_INSNS (35), /* divdi */
546 COSTS_N_INSNS (11), /* fp */
547 COSTS_N_INSNS (11), /* dmul */
548 COSTS_N_INSNS (11), /* sdiv */
549 COSTS_N_INSNS (11), /* ddiv */
550 32, /* cache line size */
556 /* Instruction costs on PPC440 processors. */
558 struct processor_costs ppc440_cost = {
559 COSTS_N_INSNS (3), /* mulsi */
560 COSTS_N_INSNS (2), /* mulsi_const */
561 COSTS_N_INSNS (2), /* mulsi_const9 */
562 COSTS_N_INSNS (3), /* muldi */
563 COSTS_N_INSNS (34), /* divsi */
564 COSTS_N_INSNS (34), /* divdi */
565 COSTS_N_INSNS (5), /* fp */
566 COSTS_N_INSNS (5), /* dmul */
567 COSTS_N_INSNS (19), /* sdiv */
568 COSTS_N_INSNS (33), /* ddiv */
569 32, /* cache line size */
575 /* Instruction costs on PPC476 processors. */
577 struct processor_costs ppc476_cost = {
578 COSTS_N_INSNS (4), /* mulsi */
579 COSTS_N_INSNS (4), /* mulsi_const */
580 COSTS_N_INSNS (4), /* mulsi_const9 */
581 COSTS_N_INSNS (4), /* muldi */
582 COSTS_N_INSNS (11), /* divsi */
583 COSTS_N_INSNS (11), /* divdi */
584 COSTS_N_INSNS (6), /* fp */
585 COSTS_N_INSNS (6), /* dmul */
586 COSTS_N_INSNS (19), /* sdiv */
587 COSTS_N_INSNS (33), /* ddiv */
588 32, /* l1 cache line size */
594 /* Instruction costs on PPC601 processors. */
596 struct processor_costs ppc601_cost = {
597 COSTS_N_INSNS (5), /* mulsi */
598 COSTS_N_INSNS (5), /* mulsi_const */
599 COSTS_N_INSNS (5), /* mulsi_const9 */
600 COSTS_N_INSNS (5), /* muldi */
601 COSTS_N_INSNS (36), /* divsi */
602 COSTS_N_INSNS (36), /* divdi */
603 COSTS_N_INSNS (4), /* fp */
604 COSTS_N_INSNS (5), /* dmul */
605 COSTS_N_INSNS (17), /* sdiv */
606 COSTS_N_INSNS (31), /* ddiv */
607 32, /* cache line size */
613 /* Instruction costs on PPC603 processors. */
615 struct processor_costs ppc603_cost = {
616 COSTS_N_INSNS (5), /* mulsi */
617 COSTS_N_INSNS (3), /* mulsi_const */
618 COSTS_N_INSNS (2), /* mulsi_const9 */
619 COSTS_N_INSNS (5), /* muldi */
620 COSTS_N_INSNS (37), /* divsi */
621 COSTS_N_INSNS (37), /* divdi */
622 COSTS_N_INSNS (3), /* fp */
623 COSTS_N_INSNS (4), /* dmul */
624 COSTS_N_INSNS (18), /* sdiv */
625 COSTS_N_INSNS (33), /* ddiv */
626 32, /* cache line size */
632 /* Instruction costs on PPC604 processors. */
634 struct processor_costs ppc604_cost = {
635 COSTS_N_INSNS (4), /* mulsi */
636 COSTS_N_INSNS (4), /* mulsi_const */
637 COSTS_N_INSNS (4), /* mulsi_const9 */
638 COSTS_N_INSNS (4), /* muldi */
639 COSTS_N_INSNS (20), /* divsi */
640 COSTS_N_INSNS (20), /* divdi */
641 COSTS_N_INSNS (3), /* fp */
642 COSTS_N_INSNS (3), /* dmul */
643 COSTS_N_INSNS (18), /* sdiv */
644 COSTS_N_INSNS (32), /* ddiv */
645 32, /* cache line size */
651 /* Instruction costs on PPC604e processors. */
653 struct processor_costs ppc604e_cost = {
654 COSTS_N_INSNS (2), /* mulsi */
655 COSTS_N_INSNS (2), /* mulsi_const */
656 COSTS_N_INSNS (2), /* mulsi_const9 */
657 COSTS_N_INSNS (2), /* muldi */
658 COSTS_N_INSNS (20), /* divsi */
659 COSTS_N_INSNS (20), /* divdi */
660 COSTS_N_INSNS (3), /* fp */
661 COSTS_N_INSNS (3), /* dmul */
662 COSTS_N_INSNS (18), /* sdiv */
663 COSTS_N_INSNS (32), /* ddiv */
664 32, /* cache line size */
670 /* Instruction costs on PPC620 processors. */
672 struct processor_costs ppc620_cost = {
673 COSTS_N_INSNS (5), /* mulsi */
674 COSTS_N_INSNS (4), /* mulsi_const */
675 COSTS_N_INSNS (3), /* mulsi_const9 */
676 COSTS_N_INSNS (7), /* muldi */
677 COSTS_N_INSNS (21), /* divsi */
678 COSTS_N_INSNS (37), /* divdi */
679 COSTS_N_INSNS (3), /* fp */
680 COSTS_N_INSNS (3), /* dmul */
681 COSTS_N_INSNS (18), /* sdiv */
682 COSTS_N_INSNS (32), /* ddiv */
683 128, /* cache line size */
689 /* Instruction costs on PPC630 processors. */
691 struct processor_costs ppc630_cost = {
692 COSTS_N_INSNS (5), /* mulsi */
693 COSTS_N_INSNS (4), /* mulsi_const */
694 COSTS_N_INSNS (3), /* mulsi_const9 */
695 COSTS_N_INSNS (7), /* muldi */
696 COSTS_N_INSNS (21), /* divsi */
697 COSTS_N_INSNS (37), /* divdi */
698 COSTS_N_INSNS (3), /* fp */
699 COSTS_N_INSNS (3), /* dmul */
700 COSTS_N_INSNS (17), /* sdiv */
701 COSTS_N_INSNS (21), /* ddiv */
702 128, /* cache line size */
708 /* Instruction costs on Cell processor. */
709 /* COSTS_N_INSNS (1) ~ one add. */
711 struct processor_costs ppccell_cost = {
712 COSTS_N_INSNS (9/2)+2, /* mulsi */
713 COSTS_N_INSNS (6/2), /* mulsi_const */
714 COSTS_N_INSNS (6/2), /* mulsi_const9 */
715 COSTS_N_INSNS (15/2)+2, /* muldi */
716 COSTS_N_INSNS (38/2), /* divsi */
717 COSTS_N_INSNS (70/2), /* divdi */
718 COSTS_N_INSNS (10/2), /* fp */
719 COSTS_N_INSNS (10/2), /* dmul */
720 COSTS_N_INSNS (74/2), /* sdiv */
721 COSTS_N_INSNS (74/2), /* ddiv */
722 128, /* cache line size */
728 /* Instruction costs on PPC750 and PPC7400 processors. */
730 struct processor_costs ppc750_cost = {
731 COSTS_N_INSNS (5), /* mulsi */
732 COSTS_N_INSNS (3), /* mulsi_const */
733 COSTS_N_INSNS (2), /* mulsi_const9 */
734 COSTS_N_INSNS (5), /* muldi */
735 COSTS_N_INSNS (17), /* divsi */
736 COSTS_N_INSNS (17), /* divdi */
737 COSTS_N_INSNS (3), /* fp */
738 COSTS_N_INSNS (3), /* dmul */
739 COSTS_N_INSNS (17), /* sdiv */
740 COSTS_N_INSNS (31), /* ddiv */
741 32, /* cache line size */
747 /* Instruction costs on PPC7450 processors. */
749 struct processor_costs ppc7450_cost = {
750 COSTS_N_INSNS (4), /* mulsi */
751 COSTS_N_INSNS (3), /* mulsi_const */
752 COSTS_N_INSNS (3), /* mulsi_const9 */
753 COSTS_N_INSNS (4), /* muldi */
754 COSTS_N_INSNS (23), /* divsi */
755 COSTS_N_INSNS (23), /* divdi */
756 COSTS_N_INSNS (5), /* fp */
757 COSTS_N_INSNS (5), /* dmul */
758 COSTS_N_INSNS (21), /* sdiv */
759 COSTS_N_INSNS (35), /* ddiv */
760 32, /* cache line size */
766 /* Instruction costs on PPC8540 processors. */
768 struct processor_costs ppc8540_cost = {
769 COSTS_N_INSNS (4), /* mulsi */
770 COSTS_N_INSNS (4), /* mulsi_const */
771 COSTS_N_INSNS (4), /* mulsi_const9 */
772 COSTS_N_INSNS (4), /* muldi */
773 COSTS_N_INSNS (19), /* divsi */
774 COSTS_N_INSNS (19), /* divdi */
775 COSTS_N_INSNS (4), /* fp */
776 COSTS_N_INSNS (4), /* dmul */
777 COSTS_N_INSNS (29), /* sdiv */
778 COSTS_N_INSNS (29), /* ddiv */
779 32, /* cache line size */
782 1, /* prefetch streams /*/
785 /* Instruction costs on E300C2 and E300C3 cores. */
787 struct processor_costs ppce300c2c3_cost = {
788 COSTS_N_INSNS (4), /* mulsi */
789 COSTS_N_INSNS (4), /* mulsi_const */
790 COSTS_N_INSNS (4), /* mulsi_const9 */
791 COSTS_N_INSNS (4), /* muldi */
792 COSTS_N_INSNS (19), /* divsi */
793 COSTS_N_INSNS (19), /* divdi */
794 COSTS_N_INSNS (3), /* fp */
795 COSTS_N_INSNS (4), /* dmul */
796 COSTS_N_INSNS (18), /* sdiv */
797 COSTS_N_INSNS (33), /* ddiv */
801 1, /* prefetch streams /*/
804 /* Instruction costs on PPCE500MC processors. */
806 struct processor_costs ppce500mc_cost = {
807 COSTS_N_INSNS (4), /* mulsi */
808 COSTS_N_INSNS (4), /* mulsi_const */
809 COSTS_N_INSNS (4), /* mulsi_const9 */
810 COSTS_N_INSNS (4), /* muldi */
811 COSTS_N_INSNS (14), /* divsi */
812 COSTS_N_INSNS (14), /* divdi */
813 COSTS_N_INSNS (8), /* fp */
814 COSTS_N_INSNS (10), /* dmul */
815 COSTS_N_INSNS (36), /* sdiv */
816 COSTS_N_INSNS (66), /* ddiv */
817 64, /* cache line size */
820 1, /* prefetch streams /*/
823 /* Instruction costs on PPCE500MC64 processors. */
825 struct processor_costs ppce500mc64_cost = {
826 COSTS_N_INSNS (4), /* mulsi */
827 COSTS_N_INSNS (4), /* mulsi_const */
828 COSTS_N_INSNS (4), /* mulsi_const9 */
829 COSTS_N_INSNS (4), /* muldi */
830 COSTS_N_INSNS (14), /* divsi */
831 COSTS_N_INSNS (14), /* divdi */
832 COSTS_N_INSNS (4), /* fp */
833 COSTS_N_INSNS (10), /* dmul */
834 COSTS_N_INSNS (36), /* sdiv */
835 COSTS_N_INSNS (66), /* ddiv */
836 64, /* cache line size */
839 1, /* prefetch streams /*/
842 /* Instruction costs on AppliedMicro Titan processors. */
844 struct processor_costs titan_cost = {
845 COSTS_N_INSNS (5), /* mulsi */
846 COSTS_N_INSNS (5), /* mulsi_const */
847 COSTS_N_INSNS (5), /* mulsi_const9 */
848 COSTS_N_INSNS (5), /* muldi */
849 COSTS_N_INSNS (18), /* divsi */
850 COSTS_N_INSNS (18), /* divdi */
851 COSTS_N_INSNS (10), /* fp */
852 COSTS_N_INSNS (10), /* dmul */
853 COSTS_N_INSNS (46), /* sdiv */
854 COSTS_N_INSNS (72), /* ddiv */
855 32, /* cache line size */
858 1, /* prefetch streams /*/
861 /* Instruction costs on POWER4 and POWER5 processors. */
863 struct processor_costs power4_cost = {
864 COSTS_N_INSNS (3), /* mulsi */
865 COSTS_N_INSNS (2), /* mulsi_const */
866 COSTS_N_INSNS (2), /* mulsi_const9 */
867 COSTS_N_INSNS (4), /* muldi */
868 COSTS_N_INSNS (18), /* divsi */
869 COSTS_N_INSNS (34), /* divdi */
870 COSTS_N_INSNS (3), /* fp */
871 COSTS_N_INSNS (3), /* dmul */
872 COSTS_N_INSNS (17), /* sdiv */
873 COSTS_N_INSNS (17), /* ddiv */
874 128, /* cache line size */
877 8, /* prefetch streams /*/
880 /* Instruction costs on POWER6 processors. */
882 struct processor_costs power6_cost = {
883 COSTS_N_INSNS (8), /* mulsi */
884 COSTS_N_INSNS (8), /* mulsi_const */
885 COSTS_N_INSNS (8), /* mulsi_const9 */
886 COSTS_N_INSNS (8), /* muldi */
887 COSTS_N_INSNS (22), /* divsi */
888 COSTS_N_INSNS (28), /* divdi */
889 COSTS_N_INSNS (3), /* fp */
890 COSTS_N_INSNS (3), /* dmul */
891 COSTS_N_INSNS (13), /* sdiv */
892 COSTS_N_INSNS (16), /* ddiv */
893 128, /* cache line size */
896 16, /* prefetch streams */
899 /* Instruction costs on POWER7 processors. */
901 struct processor_costs power7_cost = {
902 COSTS_N_INSNS (2), /* mulsi */
903 COSTS_N_INSNS (2), /* mulsi_const */
904 COSTS_N_INSNS (2), /* mulsi_const9 */
905 COSTS_N_INSNS (2), /* muldi */
906 COSTS_N_INSNS (18), /* divsi */
907 COSTS_N_INSNS (34), /* divdi */
908 COSTS_N_INSNS (3), /* fp */
909 COSTS_N_INSNS (3), /* dmul */
910 COSTS_N_INSNS (13), /* sdiv */
911 COSTS_N_INSNS (16), /* ddiv */
912 128, /* cache line size */
915 12, /* prefetch streams */
918 /* Instruction costs on POWER A2 processors. */
920 struct processor_costs ppca2_cost = {
921 COSTS_N_INSNS (16), /* mulsi */
922 COSTS_N_INSNS (16), /* mulsi_const */
923 COSTS_N_INSNS (16), /* mulsi_const9 */
924 COSTS_N_INSNS (16), /* muldi */
925 COSTS_N_INSNS (22), /* divsi */
926 COSTS_N_INSNS (28), /* divdi */
927 COSTS_N_INSNS (3), /* fp */
928 COSTS_N_INSNS (3), /* dmul */
929 COSTS_N_INSNS (59), /* sdiv */
930 COSTS_N_INSNS (72), /* ddiv */
934 16, /* prefetch streams */
938 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
939 #undef RS6000_BUILTIN
940 #undef RS6000_BUILTIN_EQUATE
941 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
942 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
944 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
946 #include "rs6000-builtin.def"
949 #undef RS6000_BUILTIN
950 #undef RS6000_BUILTIN_EQUATE
952 /* Support for -mveclibabi=<xxx> to control which vector library to use. */
953 static tree (*rs6000_veclib_handler) (tree, tree, tree);
956 static bool rs6000_function_ok_for_sibcall (tree, tree);
957 static const char *rs6000_invalid_within_doloop (const_rtx);
958 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
959 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
960 static rtx rs6000_generate_compare (rtx, enum machine_mode);
961 static void rs6000_emit_stack_tie (void);
962 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
963 static bool spe_func_has_64bit_regs_p (void);
964 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
966 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
967 static unsigned rs6000_hash_constant (rtx);
968 static unsigned toc_hash_function (const void *);
969 static int toc_hash_eq (const void *, const void *);
970 static bool reg_offset_addressing_ok_p (enum machine_mode);
971 static bool virtual_stack_registers_memory_p (rtx);
972 static bool constant_pool_expr_p (rtx);
973 static bool legitimate_small_data_p (enum machine_mode, rtx);
974 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
975 static struct machine_function * rs6000_init_machine_status (void);
976 static bool rs6000_assemble_integer (rtx, unsigned int, int);
977 static bool no_global_regs_above (int, bool);
978 #ifdef HAVE_GAS_HIDDEN
979 static void rs6000_assemble_visibility (tree, int);
981 static int rs6000_ra_ever_killed (void);
982 static bool rs6000_attribute_takes_identifier_p (const_tree);
983 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
984 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
985 static bool rs6000_ms_bitfield_layout_p (const_tree);
986 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
987 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
988 static const char *rs6000_mangle_type (const_tree);
989 static void rs6000_set_default_type_attributes (tree);
990 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
991 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
992 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
993 enum machine_mode, bool, bool, bool);
994 static bool rs6000_reg_live_or_pic_offset_p (int);
995 static tree rs6000_builtin_vectorized_libmass (tree, tree, tree);
996 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
997 static int rs6000_savres_strategy (rs6000_stack_t *, bool, int, int);
998 static void rs6000_restore_saved_cr (rtx, int);
999 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
1000 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
1001 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
1003 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
1004 static bool rs6000_return_in_memory (const_tree, const_tree);
1005 static rtx rs6000_function_value (const_tree, const_tree, bool);
1006 static void rs6000_file_start (void);
1008 static int rs6000_elf_reloc_rw_mask (void);
1009 static void rs6000_elf_asm_out_constructor (rtx, int);
1010 static void rs6000_elf_asm_out_destructor (rtx, int);
1011 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
1012 static void rs6000_elf_asm_init_sections (void);
1013 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
1014 unsigned HOST_WIDE_INT);
1015 static void rs6000_elf_encode_section_info (tree, rtx, int)
1018 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
1019 static void rs6000_alloc_sdmode_stack_slot (void);
1020 static void rs6000_instantiate_decls (void);
1022 static void rs6000_xcoff_asm_output_anchor (rtx);
1023 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
1024 static void rs6000_xcoff_asm_init_sections (void);
1025 static int rs6000_xcoff_reloc_rw_mask (void);
1026 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
1027 static section *rs6000_xcoff_select_section (tree, int,
1028 unsigned HOST_WIDE_INT);
1029 static void rs6000_xcoff_unique_section (tree, int);
1030 static section *rs6000_xcoff_select_rtx_section
1031 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
1032 static const char * rs6000_xcoff_strip_name_encoding (const char *);
1033 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
1034 static void rs6000_xcoff_file_start (void);
1035 static void rs6000_xcoff_file_end (void);
1037 static int rs6000_variable_issue (FILE *, int, rtx, int);
1038 static int rs6000_register_move_cost (enum machine_mode,
1039 reg_class_t, reg_class_t);
1040 static int rs6000_memory_move_cost (enum machine_mode, reg_class_t, bool);
1041 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
1042 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
1043 static int rs6000_debug_address_cost (rtx, bool);
1044 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
1045 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
1046 static void rs6000_sched_init (FILE *, int, int);
1047 static bool is_microcoded_insn (rtx);
1048 static bool is_nonpipeline_insn (rtx);
1049 static bool is_cracked_insn (rtx);
1050 static bool is_branch_slot_insn (rtx);
1051 static bool is_load_insn (rtx);
1052 static rtx get_store_dest (rtx pat);
1053 static bool is_store_insn (rtx);
1054 static bool set_to_load_agen (rtx,rtx);
1055 static bool adjacent_mem_locations (rtx,rtx);
1056 static int rs6000_adjust_priority (rtx, int);
1057 static int rs6000_issue_rate (void);
1058 static bool rs6000_is_costly_dependence (dep_t, int, int);
1059 static rtx get_next_active_insn (rtx, rtx);
1060 static bool insn_terminates_group_p (rtx , enum group_termination);
1061 static bool insn_must_be_first_in_group (rtx);
1062 static bool insn_must_be_last_in_group (rtx);
1063 static bool is_costly_group (rtx *, rtx);
1064 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
1065 static int redefine_groups (FILE *, int, rtx, rtx);
1066 static int pad_groups (FILE *, int, rtx, rtx);
1067 static void rs6000_sched_finish (FILE *, int);
1068 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
1069 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
1070 static int rs6000_use_sched_lookahead (void);
1071 static int rs6000_use_sched_lookahead_guard (rtx);
1072 static void * rs6000_alloc_sched_context (void);
1073 static void rs6000_init_sched_context (void *, bool);
1074 static void rs6000_set_sched_context (void *);
1075 static void rs6000_free_sched_context (void *);
1076 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
1077 static tree rs6000_builtin_mask_for_load (void);
1078 static tree rs6000_builtin_mul_widen_even (tree);
1079 static tree rs6000_builtin_mul_widen_odd (tree);
1080 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
1081 static tree rs6000_builtin_vec_perm (tree, tree *);
1082 static bool rs6000_builtin_support_vector_misalignment (enum
1086 static int rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt,
1089 static void def_builtin (int, const char *, tree, int);
1090 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1091 static void rs6000_init_builtins (void);
1092 static tree rs6000_builtin_decl (unsigned, bool);
1094 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1095 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1096 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1097 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1098 static void altivec_init_builtins (void);
1099 static unsigned builtin_hash_function (const void *);
1100 static int builtin_hash_eq (const void *, const void *);
1101 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1102 enum machine_mode, enum machine_mode,
1103 enum rs6000_builtins, const char *name);
1104 static void rs6000_common_init_builtins (void);
1105 static void rs6000_init_libfuncs (void);
1107 static void paired_init_builtins (void);
1108 static rtx paired_expand_builtin (tree, rtx, bool *);
1109 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1110 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1111 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1113 static void enable_mask_for_builtins (struct builtin_description *, int,
1114 enum rs6000_builtins,
1115 enum rs6000_builtins);
1116 static void spe_init_builtins (void);
1117 static rtx spe_expand_builtin (tree, rtx, bool *);
1118 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1119 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1120 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1121 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1122 static rs6000_stack_t *rs6000_stack_info (void);
1123 static void debug_stack_info (rs6000_stack_t *);
1125 static rtx altivec_expand_builtin (tree, rtx, bool *);
1126 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1127 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1128 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1129 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1130 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1131 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1132 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1133 static rtx altivec_expand_vec_set_builtin (tree);
1134 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1135 static int get_element_number (tree, tree);
1136 static bool rs6000_handle_option (size_t, const char *, int);
1137 static void rs6000_parse_tls_size_option (void);
1138 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1139 static int first_altivec_reg_to_save (void);
1140 static unsigned int compute_vrsave_mask (void);
1141 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1142 static void is_altivec_return_reg (rtx, void *);
1143 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1144 int easy_vector_constant (rtx, enum machine_mode);
1145 static rtx rs6000_dwarf_register_span (rtx);
1146 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1147 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1148 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1149 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1150 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1151 static rtx rs6000_delegitimize_address (rtx);
1152 static rtx rs6000_tls_get_addr (void);
1153 static rtx rs6000_got_sym (void);
1154 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1155 static const char *rs6000_get_some_local_dynamic_name (void);
1156 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1157 static rtx rs6000_complex_function_value (enum machine_mode);
1158 static rtx rs6000_spe_function_arg (const CUMULATIVE_ARGS *,
1159 enum machine_mode, const_tree);
1160 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1161 HOST_WIDE_INT, int);
1162 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1165 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1168 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1169 const_tree, HOST_WIDE_INT,
1171 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, bool, bool);
1172 static rtx rs6000_mixed_function_arg (enum machine_mode, const_tree, int);
1173 static void rs6000_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
1175 static rtx rs6000_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
1177 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1178 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1179 enum machine_mode, tree,
1181 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1183 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1185 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1187 static void macho_branch_islands (void);
1188 static int no_previous_def (tree function_name);
1189 static tree get_prev_label (tree function_name);
1190 static void rs6000_darwin_file_start (void);
1193 static tree rs6000_build_builtin_va_list (void);
1194 static void rs6000_va_start (tree, rtx);
1195 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1196 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1197 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1198 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1199 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1200 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1202 static tree rs6000_stack_protect_fail (void);
1204 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1207 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1210 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1212 = rs6000_legitimize_reload_address;
1214 static bool rs6000_mode_dependent_address_p (const_rtx);
1215 static bool rs6000_mode_dependent_address (const_rtx);
1216 static bool rs6000_debug_mode_dependent_address (const_rtx);
1217 static bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1218 = rs6000_mode_dependent_address;
1220 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1221 enum machine_mode, rtx);
1222 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1225 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1226 enum machine_mode, rtx)
1227 = rs6000_secondary_reload_class;
1229 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1230 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1232 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1233 = rs6000_preferred_reload_class;
1235 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1238 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1242 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1244 = rs6000_secondary_memory_needed;
1246 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1249 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1253 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1256 = rs6000_cannot_change_mode_class;
1258 static reg_class_t rs6000_secondary_reload (bool, rtx, reg_class_t,
1260 struct secondary_reload_info *);
1262 static const reg_class_t *rs6000_ira_cover_classes (void);
1264 const int INSN_NOT_AVAILABLE = -1;
1265 static enum machine_mode rs6000_eh_return_filter_mode (void);
1266 static bool rs6000_can_eliminate (const int, const int);
1267 static void rs6000_trampoline_init (rtx, tree, rtx);
1269 /* Hash table stuff for keeping track of TOC entries. */
1271 struct GTY(()) toc_hash_struct
1273 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1274 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1276 enum machine_mode key_mode;
1280 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1282 /* Hash table to keep track of the argument types for builtin functions. */
1284 struct GTY(()) builtin_hash_struct
1287 enum machine_mode mode[4]; /* return value + 3 arguments. */
1288 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1291 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1293 /* Default register names. */
1294 char rs6000_reg_names[][8] =
1296 "0", "1", "2", "3", "4", "5", "6", "7",
1297 "8", "9", "10", "11", "12", "13", "14", "15",
1298 "16", "17", "18", "19", "20", "21", "22", "23",
1299 "24", "25", "26", "27", "28", "29", "30", "31",
1300 "0", "1", "2", "3", "4", "5", "6", "7",
1301 "8", "9", "10", "11", "12", "13", "14", "15",
1302 "16", "17", "18", "19", "20", "21", "22", "23",
1303 "24", "25", "26", "27", "28", "29", "30", "31",
1304 "mq", "lr", "ctr","ap",
1305 "0", "1", "2", "3", "4", "5", "6", "7",
1307 /* AltiVec registers. */
1308 "0", "1", "2", "3", "4", "5", "6", "7",
1309 "8", "9", "10", "11", "12", "13", "14", "15",
1310 "16", "17", "18", "19", "20", "21", "22", "23",
1311 "24", "25", "26", "27", "28", "29", "30", "31",
1313 /* SPE registers. */
1314 "spe_acc", "spefscr",
1315 /* Soft frame pointer. */
1319 #ifdef TARGET_REGNAMES
1320 static const char alt_reg_names[][8] =
1322 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1323 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1324 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1325 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1326 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1327 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1328 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1329 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1330 "mq", "lr", "ctr", "ap",
1331 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1333 /* AltiVec registers. */
1334 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1335 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1336 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1337 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1339 /* SPE registers. */
1340 "spe_acc", "spefscr",
1341 /* Soft frame pointer. */
1346 /* Table of valid machine attributes. */
1348 static const struct attribute_spec rs6000_attribute_table[] =
1350 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1351 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute },
1352 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1353 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1354 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1355 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1356 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1357 SUBTARGET_ATTRIBUTE_TABLE,
1359 { NULL, 0, 0, false, false, false, NULL }
1362 #ifndef MASK_STRICT_ALIGN
1363 #define MASK_STRICT_ALIGN 0
1365 #ifndef TARGET_PROFILE_KERNEL
1366 #define TARGET_PROFILE_KERNEL 0
1369 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1370 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1372 /* Initialize the GCC target structure. */
1373 #undef TARGET_ATTRIBUTE_TABLE
1374 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1375 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1376 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1377 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1378 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1380 #undef TARGET_ASM_ALIGNED_DI_OP
1381 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1383 /* Default unaligned ops are only provided for ELF. Find the ops needed
1384 for non-ELF systems. */
1385 #ifndef OBJECT_FORMAT_ELF
1387 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1389 #undef TARGET_ASM_UNALIGNED_HI_OP
1390 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1391 #undef TARGET_ASM_UNALIGNED_SI_OP
1392 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1393 #undef TARGET_ASM_UNALIGNED_DI_OP
1394 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1397 #undef TARGET_ASM_UNALIGNED_HI_OP
1398 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1399 #undef TARGET_ASM_UNALIGNED_SI_OP
1400 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1401 #undef TARGET_ASM_UNALIGNED_DI_OP
1402 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1403 #undef TARGET_ASM_ALIGNED_DI_OP
1404 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1408 /* This hook deals with fixups for relocatable code and DI-mode objects
1410 #undef TARGET_ASM_INTEGER
1411 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1413 #ifdef HAVE_GAS_HIDDEN
1414 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1415 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1418 #undef TARGET_HAVE_TLS
1419 #define TARGET_HAVE_TLS HAVE_AS_TLS
1421 #undef TARGET_CANNOT_FORCE_CONST_MEM
1422 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1424 #undef TARGET_DELEGITIMIZE_ADDRESS
1425 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1427 #undef TARGET_ASM_FUNCTION_PROLOGUE
1428 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1429 #undef TARGET_ASM_FUNCTION_EPILOGUE
1430 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1432 #undef TARGET_LEGITIMIZE_ADDRESS
1433 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1435 #undef TARGET_SCHED_VARIABLE_ISSUE
1436 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1438 #undef TARGET_SCHED_ISSUE_RATE
1439 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1440 #undef TARGET_SCHED_ADJUST_COST
1441 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1442 #undef TARGET_SCHED_ADJUST_PRIORITY
1443 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1444 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1445 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1446 #undef TARGET_SCHED_INIT
1447 #define TARGET_SCHED_INIT rs6000_sched_init
1448 #undef TARGET_SCHED_FINISH
1449 #define TARGET_SCHED_FINISH rs6000_sched_finish
1450 #undef TARGET_SCHED_REORDER
1451 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1452 #undef TARGET_SCHED_REORDER2
1453 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1455 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1456 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1458 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1459 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1461 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1462 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1463 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1464 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1465 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1466 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1467 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1468 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1470 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1471 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1472 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1473 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1474 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1475 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1476 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1477 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1478 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1479 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1480 #undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
1481 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
1482 rs6000_builtin_support_vector_misalignment
1483 #undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
1484 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1485 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
1486 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \
1487 rs6000_builtin_vectorization_cost
1489 #undef TARGET_INIT_BUILTINS
1490 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1491 #undef TARGET_BUILTIN_DECL
1492 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1494 #undef TARGET_EXPAND_BUILTIN
1495 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1497 #undef TARGET_MANGLE_TYPE
1498 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1500 #undef TARGET_INIT_LIBFUNCS
1501 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1504 #undef TARGET_BINDS_LOCAL_P
1505 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1508 #undef TARGET_MS_BITFIELD_LAYOUT_P
1509 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1511 #undef TARGET_ASM_OUTPUT_MI_THUNK
1512 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1514 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1515 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1517 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1518 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1520 #undef TARGET_INVALID_WITHIN_DOLOOP
1521 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1523 #undef TARGET_REGISTER_MOVE_COST
1524 #define TARGET_REGISTER_MOVE_COST rs6000_register_move_cost
1525 #undef TARGET_MEMORY_MOVE_COST
1526 #define TARGET_MEMORY_MOVE_COST rs6000_memory_move_cost
1527 #undef TARGET_RTX_COSTS
1528 #define TARGET_RTX_COSTS rs6000_rtx_costs
1529 #undef TARGET_ADDRESS_COST
1530 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1532 #undef TARGET_DWARF_REGISTER_SPAN
1533 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1535 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1536 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1538 /* On rs6000, function arguments are promoted, as are function return
1540 #undef TARGET_PROMOTE_FUNCTION_MODE
1541 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1543 #undef TARGET_RETURN_IN_MEMORY
1544 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1546 #undef TARGET_SETUP_INCOMING_VARARGS
1547 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1549 /* Always strict argument naming on rs6000. */
1550 #undef TARGET_STRICT_ARGUMENT_NAMING
1551 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1552 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1553 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1554 #undef TARGET_SPLIT_COMPLEX_ARG
1555 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1556 #undef TARGET_MUST_PASS_IN_STACK
1557 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1558 #undef TARGET_PASS_BY_REFERENCE
1559 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1560 #undef TARGET_ARG_PARTIAL_BYTES
1561 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1562 #undef TARGET_FUNCTION_ARG_ADVANCE
1563 #define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance
1564 #undef TARGET_FUNCTION_ARG
1565 #define TARGET_FUNCTION_ARG rs6000_function_arg
1567 #undef TARGET_BUILD_BUILTIN_VA_LIST
1568 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1570 #undef TARGET_EXPAND_BUILTIN_VA_START
1571 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1573 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1574 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1576 #undef TARGET_EH_RETURN_FILTER_MODE
1577 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1579 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1580 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1582 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1583 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1585 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1586 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1588 #undef TARGET_HANDLE_OPTION
1589 #define TARGET_HANDLE_OPTION rs6000_handle_option
1591 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1592 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1593 rs6000_builtin_vectorized_function
1595 #undef TARGET_DEFAULT_TARGET_FLAGS
1596 #define TARGET_DEFAULT_TARGET_FLAGS \
1599 #undef TARGET_STACK_PROTECT_FAIL
1600 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1602 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1603 The PowerPC architecture requires only weak consistency among
1604 processors--that is, memory accesses between processors need not be
1605 sequentially consistent and memory accesses among processors can occur
1606 in any order. The ability to order memory accesses weakly provides
1607 opportunities for more efficient use of the system bus. Unless a
1608 dependency exists, the 604e allows read operations to precede store
1610 #undef TARGET_RELAXED_ORDERING
1611 #define TARGET_RELAXED_ORDERING true
1614 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1615 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1618 /* Use a 32-bit anchor range. This leads to sequences like:
1620 addis tmp,anchor,high
1623 where tmp itself acts as an anchor, and can be shared between
1624 accesses to the same 64k page. */
1625 #undef TARGET_MIN_ANCHOR_OFFSET
1626 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1627 #undef TARGET_MAX_ANCHOR_OFFSET
1628 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1629 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1630 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1632 #undef TARGET_BUILTIN_RECIPROCAL
1633 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1635 #undef TARGET_EXPAND_TO_RTL_HOOK
1636 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1638 #undef TARGET_INSTANTIATE_DECLS
1639 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1641 #undef TARGET_SECONDARY_RELOAD
1642 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1644 #undef TARGET_IRA_COVER_CLASSES
1645 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1647 #undef TARGET_LEGITIMATE_ADDRESS_P
1648 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1650 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
1651 #define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p
1653 #undef TARGET_CAN_ELIMINATE
1654 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1656 #undef TARGET_TRAMPOLINE_INIT
1657 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1659 #undef TARGET_FUNCTION_VALUE
1660 #define TARGET_FUNCTION_VALUE rs6000_function_value
1662 struct gcc_target targetm = TARGET_INITIALIZER;
1664 /* Return number of consecutive hard regs needed starting at reg REGNO
1665 to hold something of mode MODE.
1666 This is ordinarily the length in words of a value of mode MODE
1667 but can be less for certain modes in special long registers.
1669 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1670 scalar instructions. The upper 32 bits are only available to the
1673 POWER and PowerPC GPRs hold 32 bits worth;
1674 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1677 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1679 unsigned HOST_WIDE_INT reg_size;
1681 if (FP_REGNO_P (regno))
1682 reg_size = (VECTOR_MEM_VSX_P (mode)
1683 ? UNITS_PER_VSX_WORD
1684 : UNITS_PER_FP_WORD);
1686 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1687 reg_size = UNITS_PER_SPE_WORD;
1689 else if (ALTIVEC_REGNO_P (regno))
1690 reg_size = UNITS_PER_ALTIVEC_WORD;
1692 /* The value returned for SCmode in the E500 double case is 2 for
1693 ABI compatibility; storing an SCmode value in a single register
1694 would require function_arg and rs6000_spe_function_arg to handle
1695 SCmode so as to pass the value correctly in a pair of
1697 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1698 && !DECIMAL_FLOAT_MODE_P (mode))
1699 reg_size = UNITS_PER_FP_WORD;
1702 reg_size = UNITS_PER_WORD;
1704 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1707 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1710 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1712 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1714 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1715 implementations. Don't allow an item to be split between a FP register
1716 and an Altivec register. */
1717 if (VECTOR_MEM_VSX_P (mode))
1719 if (FP_REGNO_P (regno))
1720 return FP_REGNO_P (last_regno);
1722 if (ALTIVEC_REGNO_P (regno))
1723 return ALTIVEC_REGNO_P (last_regno);
1726 /* The GPRs can hold any mode, but values bigger than one register
1727 cannot go past R31. */
1728 if (INT_REGNO_P (regno))
1729 return INT_REGNO_P (last_regno);
1731 /* The float registers (except for VSX vector modes) can only hold floating
1732 modes and DImode. This excludes the 32-bit decimal float mode for
1734 if (FP_REGNO_P (regno))
1736 if (SCALAR_FLOAT_MODE_P (mode)
1737 && (mode != TDmode || (regno % 2) == 0)
1738 && FP_REGNO_P (last_regno))
1741 if (GET_MODE_CLASS (mode) == MODE_INT
1742 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1745 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1746 && PAIRED_VECTOR_MODE (mode))
1752 /* The CR register can only hold CC modes. */
1753 if (CR_REGNO_P (regno))
1754 return GET_MODE_CLASS (mode) == MODE_CC;
1756 if (CA_REGNO_P (regno))
1757 return mode == BImode;
1759 /* AltiVec only in AldyVec registers. */
1760 if (ALTIVEC_REGNO_P (regno))
1761 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1763 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1764 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1767 /* We cannot put TImode anywhere except general register and it must be able
1768 to fit within the register set. In the future, allow TImode in the
1769 Altivec or VSX registers. */
1771 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1774 /* Print interesting facts about registers. */
1776 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1780 for (r = first_regno; r <= last_regno; ++r)
1782 const char *comma = "";
1785 if (first_regno == last_regno)
1786 fprintf (stderr, "%s:\t", reg_name);
1788 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1791 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1792 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1796 fprintf (stderr, ",\n\t");
1801 if (rs6000_hard_regno_nregs[m][r] > 1)
1802 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1803 rs6000_hard_regno_nregs[m][r]);
1805 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1810 if (call_used_regs[r])
1814 fprintf (stderr, ",\n\t");
1819 len += fprintf (stderr, "%s%s", comma, "call-used");
1827 fprintf (stderr, ",\n\t");
1832 len += fprintf (stderr, "%s%s", comma, "fixed");
1838 fprintf (stderr, ",\n\t");
1842 fprintf (stderr, "%sregno = %d\n", comma, r);
1846 /* Print various interesting information with -mdebug=reg. */
1848 rs6000_debug_reg_global (void)
1850 const char *nl = (const char *)0;
1852 char costly_num[20];
1854 const char *costly_str;
1855 const char *nop_str;
1857 /* Map enum rs6000_vector to string. */
1858 static const char *rs6000_debug_vector_unit[] = {
1867 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
1868 LAST_VIRTUAL_REGISTER);
1869 rs6000_debug_reg_print (0, 31, "gr");
1870 rs6000_debug_reg_print (32, 63, "fp");
1871 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
1874 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
1875 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
1876 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
1877 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
1878 rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca");
1879 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
1880 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
1881 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
1882 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
1886 "d reg_class = %s\n"
1887 "f reg_class = %s\n"
1888 "v reg_class = %s\n"
1889 "wa reg_class = %s\n"
1890 "wd reg_class = %s\n"
1891 "wf reg_class = %s\n"
1892 "ws reg_class = %s\n\n",
1893 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
1894 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
1895 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
1896 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
1897 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
1898 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
1899 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
1901 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1902 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
1905 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
1907 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
1908 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
1914 if (rs6000_recip_control)
1916 fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control);
1918 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1919 if (rs6000_recip_bits[m])
1922 "Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n",
1924 (RS6000_RECIP_AUTO_RE_P (m)
1926 : (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")),
1927 (RS6000_RECIP_AUTO_RSQRTE_P (m)
1929 : (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none")));
1932 fputs ("\n", stderr);
1935 switch (rs6000_sched_costly_dep)
1937 case max_dep_latency:
1938 costly_str = "max_dep_latency";
1942 costly_str = "no_dep_costly";
1945 case all_deps_costly:
1946 costly_str = "all_deps_costly";
1949 case true_store_to_load_dep_costly:
1950 costly_str = "true_store_to_load_dep_costly";
1953 case store_to_load_dep_costly:
1954 costly_str = "store_to_load_dep_costly";
1958 costly_str = costly_num;
1959 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
1963 switch (rs6000_sched_insert_nops)
1965 case sched_finish_regroup_exact:
1966 nop_str = "sched_finish_regroup_exact";
1969 case sched_finish_pad_groups:
1970 nop_str = "sched_finish_pad_groups";
1973 case sched_finish_none:
1974 nop_str = "sched_finish_none";
1979 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
1984 "always_hint = %s\n"
1985 "align_branch_targets = %s\n"
1986 "sched_restricted_insns_priority = %d\n"
1987 "sched_costly_dep = %s\n"
1988 "sched_insert_nops = %s\n\n",
1989 rs6000_always_hint ? "true" : "false",
1990 rs6000_align_branch_targets ? "true" : "false",
1991 (int)rs6000_sched_restricted_insns_priority,
1992 costly_str, nop_str);
1995 /* Initialize the various global tables that are based on register size. */
1997 rs6000_init_hard_regno_mode_ok (void)
2003 /* Precalculate REGNO_REG_CLASS. */
2004 rs6000_regno_regclass[0] = GENERAL_REGS;
2005 for (r = 1; r < 32; ++r)
2006 rs6000_regno_regclass[r] = BASE_REGS;
2008 for (r = 32; r < 64; ++r)
2009 rs6000_regno_regclass[r] = FLOAT_REGS;
2011 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
2012 rs6000_regno_regclass[r] = NO_REGS;
2014 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
2015 rs6000_regno_regclass[r] = ALTIVEC_REGS;
2017 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
2018 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
2019 rs6000_regno_regclass[r] = CR_REGS;
2021 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
2022 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
2023 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
2024 rs6000_regno_regclass[CA_REGNO] = CA_REGS;
2025 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
2026 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
2027 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
2028 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
2029 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
2030 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
2032 /* Precalculate vector information, this must be set up before the
2033 rs6000_hard_regno_nregs_internal below. */
2034 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2036 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
2037 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
2038 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
2041 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
2042 rs6000_constraints[c] = NO_REGS;
2044 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
2045 believes it can use native alignment or still uses 128-bit alignment. */
2046 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
2057 /* V2DF mode, VSX only. */
2060 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
2061 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
2062 rs6000_vector_align[V2DFmode] = align64;
2065 /* V4SF mode, either VSX or Altivec. */
2068 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
2069 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
2070 rs6000_vector_align[V4SFmode] = align32;
2072 else if (TARGET_ALTIVEC)
2074 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
2075 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
2076 rs6000_vector_align[V4SFmode] = align32;
2079 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
2083 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
2084 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
2085 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
2086 rs6000_vector_align[V4SImode] = align32;
2087 rs6000_vector_align[V8HImode] = align32;
2088 rs6000_vector_align[V16QImode] = align32;
2092 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
2093 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
2094 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
2098 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
2099 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
2100 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
2104 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
2105 Altivec doesn't have 64-bit support. */
2108 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
2109 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
2110 rs6000_vector_align[V2DImode] = align64;
2113 /* DFmode, see if we want to use the VSX unit. */
2114 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
2116 rs6000_vector_unit[DFmode] = VECTOR_VSX;
2117 rs6000_vector_mem[DFmode]
2118 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
2119 rs6000_vector_align[DFmode] = align64;
2122 /* TODO add SPE and paired floating point vector support. */
2124 /* Register class constaints for the constraints that depend on compile
2126 if (TARGET_HARD_FLOAT && TARGET_FPRS)
2127 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2129 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2130 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2134 /* At present, we just use VSX_REGS, but we have different constraints
2135 based on the use, in case we want to fine tune the default register
2136 class used. wa = any VSX register, wf = register class to use for
2137 V4SF, wd = register class to use for V2DF, and ws = register classs to
2138 use for DF scalars. */
2139 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2140 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2141 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2142 rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
2148 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2150 /* Set up the reload helper functions. */
2151 if (TARGET_VSX || TARGET_ALTIVEC)
2155 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2156 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2157 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2158 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2159 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2160 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2161 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2162 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2163 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2164 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2165 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2166 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2170 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2171 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2172 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2173 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2174 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2175 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2176 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2177 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2178 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2179 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2180 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2181 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2185 /* Precalculate HARD_REGNO_NREGS. */
2186 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2187 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2188 rs6000_hard_regno_nregs[m][r]
2189 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2191 /* Precalculate HARD_REGNO_MODE_OK. */
2192 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2193 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2194 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2195 rs6000_hard_regno_mode_ok_p[m][r] = true;
2197 /* Precalculate CLASS_MAX_NREGS sizes. */
2198 for (c = 0; c < LIM_REG_CLASSES; ++c)
2202 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2203 reg_size = UNITS_PER_VSX_WORD;
2205 else if (c == ALTIVEC_REGS)
2206 reg_size = UNITS_PER_ALTIVEC_WORD;
2208 else if (c == FLOAT_REGS)
2209 reg_size = UNITS_PER_FP_WORD;
2212 reg_size = UNITS_PER_WORD;
2214 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2215 rs6000_class_max_nregs[m][c]
2216 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2219 if (TARGET_E500_DOUBLE)
2220 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2222 /* Calculate which modes to automatically generate code to use a the
2223 reciprocal divide and square root instructions. In the future, possibly
2224 automatically generate the instructions even if the user did not specify
2225 -mrecip. The older machines double precision reciprocal sqrt estimate is
2226 not accurate enough. */
2227 memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits));
2229 rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2231 rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2232 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2233 rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2234 if (VECTOR_UNIT_VSX_P (V2DFmode))
2235 rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2237 if (TARGET_FRSQRTES)
2238 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2240 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2241 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2242 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2243 if (VECTOR_UNIT_VSX_P (V2DFmode))
2244 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2246 if (rs6000_recip_control)
2248 if (!TARGET_FUSED_MADD)
2249 warning (0, "-mrecip requires -mfused-madd");
2250 if (!flag_finite_math_only)
2251 warning (0, "-mrecip requires -ffinite-math or -ffast-math");
2252 if (flag_trapping_math)
2253 warning (0, "-mrecip requires -fno-trapping-math or -ffast-math");
2254 if (!flag_reciprocal_math)
2255 warning (0, "-mrecip requires -freciprocal-math or -ffast-math");
2256 if (TARGET_FUSED_MADD && flag_finite_math_only && !flag_trapping_math
2257 && flag_reciprocal_math)
2259 if (RS6000_RECIP_HAVE_RE_P (SFmode)
2260 && (rs6000_recip_control & RECIP_SF_DIV) != 0)
2261 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2263 if (RS6000_RECIP_HAVE_RE_P (DFmode)
2264 && (rs6000_recip_control & RECIP_DF_DIV) != 0)
2265 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2267 if (RS6000_RECIP_HAVE_RE_P (V4SFmode)
2268 && (rs6000_recip_control & RECIP_V4SF_DIV) != 0)
2269 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2271 if (RS6000_RECIP_HAVE_RE_P (V2DFmode)
2272 && (rs6000_recip_control & RECIP_V2DF_DIV) != 0)
2273 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2275 if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode)
2276 && (rs6000_recip_control & RECIP_SF_RSQRT) != 0)
2277 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2279 if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode)
2280 && (rs6000_recip_control & RECIP_DF_RSQRT) != 0)
2281 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2283 if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode)
2284 && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0)
2285 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2287 if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode)
2288 && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0)
2289 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2293 if (TARGET_DEBUG_REG)
2294 rs6000_debug_reg_global ();
2296 if (TARGET_DEBUG_COST || TARGET_DEBUG_REG)
2298 "SImode variable mult cost = %d\n"
2299 "SImode constant mult cost = %d\n"
2300 "SImode short constant mult cost = %d\n"
2301 "DImode multipliciation cost = %d\n"
2302 "SImode division cost = %d\n"
2303 "DImode division cost = %d\n"
2304 "Simple fp operation cost = %d\n"
2305 "DFmode multiplication cost = %d\n"
2306 "SFmode division cost = %d\n"
2307 "DFmode division cost = %d\n"
2308 "cache line size = %d\n"
2309 "l1 cache size = %d\n"
2310 "l2 cache size = %d\n"
2311 "simultaneous prefetches = %d\n"
2314 rs6000_cost->mulsi_const,
2315 rs6000_cost->mulsi_const9,
2323 rs6000_cost->cache_line_size,
2324 rs6000_cost->l1_cache_size,
2325 rs6000_cost->l2_cache_size,
2326 rs6000_cost->simultaneous_prefetches);
2330 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2333 darwin_rs6000_override_options (void)
2335 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2337 rs6000_altivec_abi = 1;
2338 TARGET_ALTIVEC_VRSAVE = 1;
2339 if (DEFAULT_ABI == ABI_DARWIN)
2341 if (MACHO_DYNAMIC_NO_PIC_P)
2344 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
2347 else if (flag_pic == 1)
2352 darwin_one_byte_bool = 1;
2354 if (TARGET_64BIT && ! TARGET_POWERPC64)
2356 target_flags |= MASK_POWERPC64;
2357 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2361 rs6000_default_long_calls = 1;
2362 target_flags |= MASK_SOFT_FLOAT;
2365 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2367 if (!flag_mkernel && !flag_apple_kext
2369 && ! (target_flags_explicit & MASK_ALTIVEC))
2370 target_flags |= MASK_ALTIVEC;
2372 /* Unless the user (not the configurer) has explicitly overridden
2373 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2374 G4 unless targetting the kernel. */
2377 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2378 && ! (target_flags_explicit & MASK_ALTIVEC)
2379 && ! rs6000_select[1].string)
2381 target_flags |= MASK_ALTIVEC;
2386 /* If not otherwise specified by a target, make 'long double' equivalent to
2389 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2390 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2393 /* Override command line options. Mostly we process the processor
2394 type and sometimes adjust other TARGET_ options. */
2397 rs6000_override_options (const char *default_cpu)
2400 struct rs6000_cpu_select *ptr;
2403 /* Simplifications for entries below. */
2406 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
2407 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
2410 /* This table occasionally claims that a processor does not support
2411 a particular feature even though it does, but the feature is slower
2412 than the alternative. Thus, it shouldn't be relied on as a
2413 complete description of the processor's support.
2415 Please keep this list in order, and don't forget to update the
2416 documentation in invoke.texi when adding a new processor or
2420 const char *const name; /* Canonical processor name. */
2421 const enum processor_type processor; /* Processor type enum value. */
2422 const int target_enable; /* Target flags to enable. */
2423 } const processor_target_table[]
2424 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2425 {"403", PROCESSOR_PPC403,
2426 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
2427 {"405", PROCESSOR_PPC405,
2428 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2429 {"405fp", PROCESSOR_PPC405,
2430 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2431 {"440", PROCESSOR_PPC440,
2432 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2433 {"440fp", PROCESSOR_PPC440,
2434 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2435 {"464", PROCESSOR_PPC440,
2436 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2437 {"464fp", PROCESSOR_PPC440,
2438 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2439 {"476", PROCESSOR_PPC476,
2440 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
2441 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2442 {"476fp", PROCESSOR_PPC476,
2443 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
2444 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2445 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
2446 {"601", PROCESSOR_PPC601,
2447 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
2448 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2449 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2450 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2451 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2452 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2453 {"620", PROCESSOR_PPC620,
2454 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2455 {"630", PROCESSOR_PPC630,
2456 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2457 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2458 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
2459 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2460 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2461 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2462 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2463 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2464 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2466 /* 8548 has a dummy entry for now. */
2467 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2469 {"a2", PROCESSOR_PPCA2,
2470 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
2471 | MASK_CMPB | MASK_NO_UPDATE },
2472 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2473 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
2474 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
2476 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
2477 | MASK_PPC_GFXOPT | MASK_ISEL},
2478 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2479 {"970", PROCESSOR_POWER4,
2480 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2481 {"cell", PROCESSOR_CELL,
2482 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2483 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
2484 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2485 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2486 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2487 {"G5", PROCESSOR_POWER4,
2488 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2489 {"titan", PROCESSOR_TITAN,
2490 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2491 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2492 {"power2", PROCESSOR_POWER,
2493 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2494 {"power3", PROCESSOR_PPC630,
2495 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2496 {"power4", PROCESSOR_POWER4,
2497 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2499 {"power5", PROCESSOR_POWER5,
2500 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2501 | MASK_MFCRF | MASK_POPCNTB},
2502 {"power5+", PROCESSOR_POWER5,
2503 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2504 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
2505 {"power6", PROCESSOR_POWER6,
2506 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2507 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2508 | MASK_RECIP_PRECISION},
2509 {"power6x", PROCESSOR_POWER6,
2510 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2511 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2512 | MASK_MFPGPR | MASK_RECIP_PRECISION},
2513 {"power7", PROCESSOR_POWER7, /* Don't add MASK_ISEL by default */
2514 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
2515 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
2516 | MASK_VSX | MASK_RECIP_PRECISION},
2517 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
2518 {"powerpc64", PROCESSOR_POWERPC64,
2519 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2520 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2521 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2522 {"rios2", PROCESSOR_RIOS2,
2523 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2524 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2525 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2526 {"rs64", PROCESSOR_RS64A,
2527 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
2530 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
2532 /* Some OSs don't support saving the high part of 64-bit registers on
2533 context switch. Other OSs don't support saving Altivec registers.
2534 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
2535 settings; if the user wants either, the user must explicitly specify
2536 them and we won't interfere with the user's specification. */
2539 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
2540 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
2541 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
2542 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
2543 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
2544 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE
2545 | MASK_RECIP_PRECISION)
2548 /* Masks for instructions set at various powerpc ISAs. */
2550 ISA_2_1_MASKS = MASK_MFCRF,
2551 ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB | MASK_FPRND),
2553 /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't
2554 add ALTIVEC, since in general it isn't a win on power6. In ISA 2.04,
2555 fsel, fre, fsqrt, etc. were no longer documented as optional. Group
2556 masks by server and embedded. */
2557 ISA_2_5_MASKS_EMBEDDED = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION
2558 | MASK_PPC_GFXOPT | MASK_PPC_GPOPT),
2559 ISA_2_5_MASKS_SERVER = (ISA_2_5_MASKS_EMBEDDED | MASK_DFP),
2561 /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
2562 altivec is a win so enable it. */
2563 ISA_2_6_MASKS_EMBEDDED = (ISA_2_5_MASKS_EMBEDDED | MASK_POPCNTD),
2564 ISA_2_6_MASKS_SERVER = (ISA_2_5_MASKS_SERVER | MASK_POPCNTD | MASK_ALTIVEC
2568 /* Numerous experiment shows that IRA based loop pressure
2569 calculation works better for RTL loop invariant motion on targets
2570 with enough (>= 32) registers. It is an expensive optimization.
2571 So it is on only for peak performance. */
2573 flag_ira_loop_pressure = 1;
2575 /* Set the pointer size. */
2578 rs6000_pmode = (int)DImode;
2579 rs6000_pointer_size = 64;
2583 rs6000_pmode = (int)SImode;
2584 rs6000_pointer_size = 32;
2587 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2588 #ifdef OS_MISSING_POWERPC64
2589 if (OS_MISSING_POWERPC64)
2590 set_masks &= ~MASK_POWERPC64;
2592 #ifdef OS_MISSING_ALTIVEC
2593 if (OS_MISSING_ALTIVEC)
2594 set_masks &= ~MASK_ALTIVEC;
2597 /* Don't override by the processor default if given explicitly. */
2598 set_masks &= ~target_flags_explicit;
2600 /* Identify the processor type. */
2601 rs6000_select[0].string = default_cpu;
2602 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
2604 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2606 ptr = &rs6000_select[i];
2607 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2609 for (j = 0; j < ptt_size; j++)
2610 if (! strcmp (ptr->string, processor_target_table[j].name))
2612 if (ptr->set_tune_p)
2613 rs6000_cpu = processor_target_table[j].processor;
2615 if (ptr->set_arch_p)
2617 target_flags &= ~set_masks;
2618 target_flags |= (processor_target_table[j].target_enable
2625 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
2629 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2630 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2633 error ("AltiVec not supported in this target");
2635 error ("Spe not supported in this target");
2638 /* Disable Cell microcode if we are optimizing for the Cell
2639 and not optimizing for size. */
2640 if (rs6000_gen_cell_microcode == -1)
2641 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2644 /* If we are optimizing big endian systems for space and it's OK to
2645 use instructions that would be microcoded on the Cell, use the
2646 load/store multiple and string instructions. */
2647 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2648 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2650 /* Don't allow -mmultiple or -mstring on little endian systems
2651 unless the cpu is a 750, because the hardware doesn't support the
2652 instructions used in little endian mode, and causes an alignment
2653 trap. The 750 does not cause an alignment trap (except when the
2654 target is unaligned). */
2656 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2658 if (TARGET_MULTIPLE)
2660 target_flags &= ~MASK_MULTIPLE;
2661 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2662 warning (0, "-mmultiple is not supported on little endian systems");
2667 target_flags &= ~MASK_STRING;
2668 if ((target_flags_explicit & MASK_STRING) != 0)
2669 warning (0, "-mstring is not supported on little endian systems");
2673 /* Add some warnings for VSX. */
2676 const char *msg = NULL;
2677 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2678 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2680 if (target_flags_explicit & MASK_VSX)
2681 msg = N_("-mvsx requires hardware floating point");
2683 target_flags &= ~ MASK_VSX;
2685 else if (TARGET_PAIRED_FLOAT)
2686 msg = N_("-mvsx and -mpaired are incompatible");
2687 /* The hardware will allow VSX and little endian, but until we make sure
2688 things like vector select, etc. work don't allow VSX on little endian
2689 systems at this point. */
2690 else if (!BYTES_BIG_ENDIAN)
2691 msg = N_("-mvsx used with little endian code");
2692 else if (TARGET_AVOID_XFORM > 0)
2693 msg = N_("-mvsx needs indexed addressing");
2694 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2696 if (target_flags_explicit & MASK_VSX)
2697 msg = N_("-mvsx and -mno-altivec are incompatible");
2699 msg = N_("-mno-altivec disables vsx");
2705 target_flags &= ~ MASK_VSX;
2706 target_flags_explicit |= MASK_VSX;
2710 /* For the newer switches (vsx, dfp, etc.) set some of the older options,
2711 unless the user explicitly used the -mno-<option> to disable the code. */
2713 target_flags |= (ISA_2_6_MASKS_SERVER & ~target_flags_explicit);
2714 else if (TARGET_POPCNTD)
2715 target_flags |= (ISA_2_6_MASKS_EMBEDDED & ~target_flags_explicit);
2716 else if (TARGET_DFP)
2717 target_flags |= (ISA_2_5_MASKS_SERVER & ~target_flags_explicit);
2718 else if (TARGET_CMPB)
2719 target_flags |= (ISA_2_5_MASKS_EMBEDDED & ~target_flags_explicit);
2720 else if (TARGET_POPCNTB || TARGET_FPRND)
2721 target_flags |= (ISA_2_2_MASKS & ~target_flags_explicit);
2722 else if (TARGET_ALTIVEC)
2723 target_flags |= (MASK_PPC_GFXOPT & ~target_flags_explicit);
2725 /* E500mc does "better" if we inline more aggressively. Respect the
2726 user's opinion, though. */
2727 if (rs6000_block_move_inline_limit == 0
2728 && (rs6000_cpu == PROCESSOR_PPCE500MC
2729 || rs6000_cpu == PROCESSOR_PPCE500MC64))
2730 rs6000_block_move_inline_limit = 128;
2732 /* store_one_arg depends on expand_block_move to handle at least the
2733 size of reg_parm_stack_space. */
2734 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32))
2735 rs6000_block_move_inline_limit = (TARGET_POWERPC64 ? 64 : 32);
2737 /* Set debug flags */
2738 if (rs6000_debug_name)
2740 if (! strcmp (rs6000_debug_name, "all"))
2741 rs6000_debug_stack = rs6000_debug_arg = rs6000_debug_reg
2742 = rs6000_debug_addr = rs6000_debug_cost = 1;
2743 else if (! strcmp (rs6000_debug_name, "stack"))
2744 rs6000_debug_stack = 1;
2745 else if (! strcmp (rs6000_debug_name, "arg"))
2746 rs6000_debug_arg = 1;
2747 else if (! strcmp (rs6000_debug_name, "reg"))
2748 rs6000_debug_reg = 1;
2749 else if (! strcmp (rs6000_debug_name, "addr"))
2750 rs6000_debug_addr = 1;
2751 else if (! strcmp (rs6000_debug_name, "cost"))
2752 rs6000_debug_cost = 1;
2754 error ("unknown -mdebug-%s switch", rs6000_debug_name);
2756 /* If the appropriate debug option is enabled, replace the target hooks
2757 with debug versions that call the real version and then prints
2758 debugging information. */
2759 if (TARGET_DEBUG_COST)
2761 targetm.rtx_costs = rs6000_debug_rtx_costs;
2762 targetm.address_cost = rs6000_debug_address_cost;
2763 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2766 if (TARGET_DEBUG_ADDR)
2768 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2769 targetm.legitimize_address = rs6000_debug_legitimize_address;
2770 rs6000_secondary_reload_class_ptr
2771 = rs6000_debug_secondary_reload_class;
2772 rs6000_secondary_memory_needed_ptr
2773 = rs6000_debug_secondary_memory_needed;
2774 rs6000_cannot_change_mode_class_ptr
2775 = rs6000_debug_cannot_change_mode_class;
2776 rs6000_preferred_reload_class_ptr
2777 = rs6000_debug_preferred_reload_class;
2778 rs6000_legitimize_reload_address_ptr
2779 = rs6000_debug_legitimize_reload_address;
2780 rs6000_mode_dependent_address_ptr
2781 = rs6000_debug_mode_dependent_address;
2785 if (rs6000_traceback_name)
2787 if (! strncmp (rs6000_traceback_name, "full", 4))
2788 rs6000_traceback = traceback_full;
2789 else if (! strncmp (rs6000_traceback_name, "part", 4))
2790 rs6000_traceback = traceback_part;
2791 else if (! strncmp (rs6000_traceback_name, "no", 2))
2792 rs6000_traceback = traceback_none;
2794 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
2795 rs6000_traceback_name);
2798 if (rs6000_veclibabi_name)
2800 if (strcmp (rs6000_veclibabi_name, "mass") == 0)
2801 rs6000_veclib_handler = rs6000_builtin_vectorized_libmass;
2803 error ("unknown vectorization library ABI type (%s) for "
2804 "-mveclibabi= switch", rs6000_veclibabi_name);
2807 if (!rs6000_explicit_options.long_double)
2808 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2810 #ifndef POWERPC_LINUX
2811 if (!rs6000_explicit_options.ieee)
2812 rs6000_ieeequad = 1;
2815 /* Enable Altivec ABI for AIX -maltivec. */
2816 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2817 rs6000_altivec_abi = 1;
2819 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2820 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2821 be explicitly overridden in either case. */
2824 if (!rs6000_explicit_options.altivec_abi
2825 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2826 rs6000_altivec_abi = 1;
2828 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2829 if (!rs6000_explicit_options.vrsave)
2830 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2833 /* Set the Darwin64 ABI as default for 64-bit Darwin.
2834 So far, the only darwin64 targets are also MACH-O. */
2836 && DEFAULT_ABI == ABI_DARWIN
2839 rs6000_darwin64_abi = 1;
2840 /* Default to natural alignment, for better performance. */
2841 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2844 /* Place FP constants in the constant pool instead of TOC
2845 if section anchors enabled. */
2846 if (flag_section_anchors)
2847 TARGET_NO_FP_IN_TOC = 1;
2849 /* Handle -mtls-size option. */
2850 rs6000_parse_tls_size_option ();
2852 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2853 SUBTARGET_OVERRIDE_OPTIONS;
2855 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2856 SUBSUBTARGET_OVERRIDE_OPTIONS;
2858 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2859 SUB3TARGET_OVERRIDE_OPTIONS;
2862 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2863 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2865 /* The e500 and e500mc do not have string instructions, and we set
2866 MASK_STRING above when optimizing for size. */
2867 if ((target_flags & MASK_STRING) != 0)
2868 target_flags = target_flags & ~MASK_STRING;
2870 else if (rs6000_select[1].string != NULL)
2872 /* For the powerpc-eabispe configuration, we set all these by
2873 default, so let's unset them if we manually set another
2874 CPU that is not the E500. */
2875 if (!rs6000_explicit_options.spe_abi)
2877 if (!rs6000_explicit_options.spe)
2879 if (!rs6000_explicit_options.float_gprs)
2880 rs6000_float_gprs = 0;
2881 if (!(target_flags_explicit & MASK_ISEL))
2882 target_flags &= ~MASK_ISEL;
2885 /* Detect invalid option combinations with E500. */
2888 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
2889 && rs6000_cpu != PROCESSOR_POWER5
2890 && rs6000_cpu != PROCESSOR_POWER6
2891 && rs6000_cpu != PROCESSOR_POWER7
2892 && rs6000_cpu != PROCESSOR_PPCA2
2893 && rs6000_cpu != PROCESSOR_CELL);
2894 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
2895 || rs6000_cpu == PROCESSOR_POWER5
2896 || rs6000_cpu == PROCESSOR_POWER7);
2897 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
2898 || rs6000_cpu == PROCESSOR_POWER5
2899 || rs6000_cpu == PROCESSOR_POWER6
2900 || rs6000_cpu == PROCESSOR_POWER7
2901 || rs6000_cpu == PROCESSOR_PPCE500MC
2902 || rs6000_cpu == PROCESSOR_PPCE500MC64);
2904 /* Allow debug switches to override the above settings. */
2905 if (TARGET_ALWAYS_HINT > 0)
2906 rs6000_always_hint = TARGET_ALWAYS_HINT;
2908 if (TARGET_SCHED_GROUPS > 0)
2909 rs6000_sched_groups = TARGET_SCHED_GROUPS;
2911 if (TARGET_ALIGN_BRANCH_TARGETS > 0)
2912 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
2914 rs6000_sched_restricted_insns_priority
2915 = (rs6000_sched_groups ? 1 : 0);
2917 /* Handle -msched-costly-dep option. */
2918 rs6000_sched_costly_dep
2919 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
2921 if (rs6000_sched_costly_dep_str)
2923 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
2924 rs6000_sched_costly_dep = no_dep_costly;
2925 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
2926 rs6000_sched_costly_dep = all_deps_costly;
2927 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
2928 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
2929 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
2930 rs6000_sched_costly_dep = store_to_load_dep_costly;
2932 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
2933 atoi (rs6000_sched_costly_dep_str));
2936 /* Handle -minsert-sched-nops option. */
2937 rs6000_sched_insert_nops
2938 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
2940 if (rs6000_sched_insert_nops_str)
2942 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
2943 rs6000_sched_insert_nops = sched_finish_none;
2944 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
2945 rs6000_sched_insert_nops = sched_finish_pad_groups;
2946 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
2947 rs6000_sched_insert_nops = sched_finish_regroup_exact;
2949 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
2950 atoi (rs6000_sched_insert_nops_str));
2953 #ifdef TARGET_REGNAMES
2954 /* If the user desires alternate register names, copy in the
2955 alternate names now. */
2956 if (TARGET_REGNAMES)
2957 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
2960 /* Set aix_struct_return last, after the ABI is determined.
2961 If -maix-struct-return or -msvr4-struct-return was explicitly
2962 used, don't override with the ABI default. */
2963 if (!rs6000_explicit_options.aix_struct_ret)
2964 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
2967 /* IBM XL compiler defaults to unsigned bitfields. */
2968 if (TARGET_XL_COMPAT)
2969 flag_signed_bitfields = 0;
2972 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
2973 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
2976 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
2978 /* We can only guarantee the availability of DI pseudo-ops when
2979 assembling for 64-bit targets. */
2982 targetm.asm_out.aligned_op.di = NULL;
2983 targetm.asm_out.unaligned_op.di = NULL;
2986 /* Set branch target alignment, if not optimizing for size. */
2989 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be
2990 aligned 8byte to avoid misprediction by the branch predictor. */
2991 if (rs6000_cpu == PROCESSOR_TITAN
2992 || rs6000_cpu == PROCESSOR_CELL)
2994 if (align_functions <= 0)
2995 align_functions = 8;
2996 if (align_jumps <= 0)
2998 if (align_loops <= 0)
3001 if (rs6000_align_branch_targets)
3003 if (align_functions <= 0)
3004 align_functions = 16;
3005 if (align_jumps <= 0)
3007 if (align_loops <= 0)
3010 if (align_jumps_max_skip <= 0)
3011 align_jumps_max_skip = 15;
3012 if (align_loops_max_skip <= 0)
3013 align_loops_max_skip = 15;
3016 /* Arrange to save and restore machine status around nested functions. */
3017 init_machine_status = rs6000_init_machine_status;
3019 /* We should always be splitting complex arguments, but we can't break
3020 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
3021 if (DEFAULT_ABI != ABI_AIX)
3022 targetm.calls.split_complex_arg = NULL;
3024 /* Initialize rs6000_cost with the appropriate target costs. */
3026 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
3030 case PROCESSOR_RIOS1:
3031 rs6000_cost = &rios1_cost;
3034 case PROCESSOR_RIOS2:
3035 rs6000_cost = &rios2_cost;
3038 case PROCESSOR_RS64A:
3039 rs6000_cost = &rs64a_cost;
3042 case PROCESSOR_MPCCORE:
3043 rs6000_cost = &mpccore_cost;
3046 case PROCESSOR_PPC403:
3047 rs6000_cost = &ppc403_cost;
3050 case PROCESSOR_PPC405:
3051 rs6000_cost = &ppc405_cost;
3054 case PROCESSOR_PPC440:
3055 rs6000_cost = &ppc440_cost;
3058 case PROCESSOR_PPC476:
3059 rs6000_cost = &ppc476_cost;
3062 case PROCESSOR_PPC601:
3063 rs6000_cost = &ppc601_cost;
3066 case PROCESSOR_PPC603:
3067 rs6000_cost = &ppc603_cost;
3070 case PROCESSOR_PPC604:
3071 rs6000_cost = &ppc604_cost;
3074 case PROCESSOR_PPC604e:
3075 rs6000_cost = &ppc604e_cost;
3078 case PROCESSOR_PPC620:
3079 rs6000_cost = &ppc620_cost;
3082 case PROCESSOR_PPC630:
3083 rs6000_cost = &ppc630_cost;
3086 case PROCESSOR_CELL:
3087 rs6000_cost = &ppccell_cost;
3090 case PROCESSOR_PPC750:
3091 case PROCESSOR_PPC7400:
3092 rs6000_cost = &ppc750_cost;
3095 case PROCESSOR_PPC7450:
3096 rs6000_cost = &ppc7450_cost;
3099 case PROCESSOR_PPC8540:
3100 rs6000_cost = &ppc8540_cost;
3103 case PROCESSOR_PPCE300C2:
3104 case PROCESSOR_PPCE300C3:
3105 rs6000_cost = &ppce300c2c3_cost;
3108 case PROCESSOR_PPCE500MC:
3109 rs6000_cost = &ppce500mc_cost;
3112 case PROCESSOR_PPCE500MC64:
3113 rs6000_cost = &ppce500mc64_cost;
3116 case PROCESSOR_TITAN:
3117 rs6000_cost = &titan_cost;
3120 case PROCESSOR_POWER4:
3121 case PROCESSOR_POWER5:
3122 rs6000_cost = &power4_cost;
3125 case PROCESSOR_POWER6:
3126 rs6000_cost = &power6_cost;
3129 case PROCESSOR_POWER7:
3130 rs6000_cost = &power7_cost;
3133 case PROCESSOR_PPCA2:
3134 rs6000_cost = &ppca2_cost;
3141 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
3142 set_param_value ("simultaneous-prefetches",
3143 rs6000_cost->simultaneous_prefetches);
3144 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
3145 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
3146 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
3147 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
3148 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
3149 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
3151 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
3152 can be optimized to ap = __builtin_next_arg (0). */
3153 if (DEFAULT_ABI != ABI_V4)
3154 targetm.expand_builtin_va_start = NULL;
3156 /* Set up single/double float flags.
3157 If TARGET_HARD_FLOAT is set, but neither single or double is set,
3158 then set both flags. */
3159 if (TARGET_HARD_FLOAT && TARGET_FPRS
3160 && rs6000_single_float == 0 && rs6000_double_float == 0)
3161 rs6000_single_float = rs6000_double_float = 1;
3163 /* Reset single and double FP flags if target is E500. */
3166 rs6000_single_float = rs6000_double_float = 0;
3167 if (TARGET_E500_SINGLE)
3168 rs6000_single_float = 1;
3169 if (TARGET_E500_DOUBLE)
3170 rs6000_single_float = rs6000_double_float = 1;
3173 /* If not explicitly specified via option, decide whether to generate indexed
3174 load/store instructions. */
3175 if (TARGET_AVOID_XFORM == -1)
3176 /* Avoid indexed addressing when targeting Power6 in order to avoid
3177 the DERAT mispredict penalty. */
3178 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB);
3180 /* Set the -mrecip options. */
3181 if (rs6000_recip_name)
3183 char *p = ASTRDUP (rs6000_recip_name);
3185 unsigned int mask, i;
3188 while ((q = strtok (p, ",")) != NULL)
3199 if (!strcmp (q, "default"))
3200 mask = ((TARGET_RECIP_PRECISION)
3201 ? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION);
3204 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
3205 if (!strcmp (q, recip_options[i].string))
3207 mask = recip_options[i].mask;
3211 if (i == ARRAY_SIZE (recip_options))
3213 error ("Unknown option for -mrecip=%s", q);
3220 rs6000_recip_control &= ~mask;
3222 rs6000_recip_control |= mask;
3226 rs6000_init_hard_regno_mode_ok ();
3229 /* Implement targetm.vectorize.builtin_mask_for_load. */
3231 rs6000_builtin_mask_for_load (void)
3233 if (TARGET_ALTIVEC || TARGET_VSX)
3234 return altivec_builtin_mask_for_load;
3239 /* Implement targetm.vectorize.builtin_conversion.
3240 Returns a decl of a function that implements conversion of an integer vector
3241 into a floating-point vector, or vice-versa. DEST_TYPE is the
3242 destination type and SRC_TYPE the source type of the conversion.
3243 Return NULL_TREE if it is not available. */
3245 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
3247 enum tree_code code = (enum tree_code) tcode;
3251 case FIX_TRUNC_EXPR:
3252 switch (TYPE_MODE (dest_type))
3255 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3258 return TYPE_UNSIGNED (dest_type)
3259 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
3260 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
3263 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3266 return TYPE_UNSIGNED (dest_type)
3267 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
3268 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
3275 switch (TYPE_MODE (src_type))
3278 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3281 return TYPE_UNSIGNED (src_type)
3282 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
3283 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
3286 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3289 return TYPE_UNSIGNED (src_type)
3290 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
3291 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
3302 /* Implement targetm.vectorize.builtin_mul_widen_even. */
3304 rs6000_builtin_mul_widen_even (tree type)
3306 if (!TARGET_ALTIVEC)
3309 switch (TYPE_MODE (type))
3312 return TYPE_UNSIGNED (type)
3313 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
3314 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
3317 return TYPE_UNSIGNED (type)
3318 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
3319 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
3325 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
3327 rs6000_builtin_mul_widen_odd (tree type)
3329 if (!TARGET_ALTIVEC)
3332 switch (TYPE_MODE (type))
3335 return TYPE_UNSIGNED (type)
3336 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
3337 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
3340 return TYPE_UNSIGNED (type)
3341 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
3342 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
3349 /* Return true iff, data reference of TYPE can reach vector alignment (16)
3350 after applying N number of iterations. This routine does not determine
3351 how may iterations are required to reach desired alignment. */
3354 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3361 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3364 if (rs6000_alignment_flags == MASK_ALIGN_POWER)