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"
49 #include "target-def.h"
50 #include "langhooks.h"
52 #include "cfglayout.h"
53 #include "sched-int.h"
55 #include "tree-flow.h"
58 #include "tm-constrs.h"
60 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
63 #include "gstab.h" /* for N_SLINE */
66 #ifndef TARGET_NO_PROTOTYPE
67 #define TARGET_NO_PROTOTYPE 0
70 #define min(A,B) ((A) < (B) ? (A) : (B))
71 #define max(A,B) ((A) > (B) ? (A) : (B))
73 /* Structure used to define the rs6000 stack */
74 typedef struct rs6000_stack {
75 int first_gp_reg_save; /* first callee saved GP register used */
76 int first_fp_reg_save; /* first callee saved FP register used */
77 int first_altivec_reg_save; /* first callee saved AltiVec register used */
78 int lr_save_p; /* true if the link reg needs to be saved */
79 int cr_save_p; /* true if the CR reg needs to be saved */
80 unsigned int vrsave_mask; /* mask of vec registers to save */
81 int push_p; /* true if we need to allocate stack space */
82 int calls_p; /* true if the function makes any calls */
83 int world_save_p; /* true if we're saving *everything*:
84 r13-r31, cr, f14-f31, vrsave, v20-v31 */
85 enum rs6000_abi abi; /* which ABI to use */
86 int gp_save_offset; /* offset to save GP regs from initial SP */
87 int fp_save_offset; /* offset to save FP regs from initial SP */
88 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
89 int lr_save_offset; /* offset to save LR from initial SP */
90 int cr_save_offset; /* offset to save CR from initial SP */
91 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
92 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
93 int varargs_save_offset; /* offset to save the varargs registers */
94 int ehrd_offset; /* offset to EH return data */
95 int reg_size; /* register size (4 or 8) */
96 HOST_WIDE_INT vars_size; /* variable save area size */
97 int parm_size; /* outgoing parameter size */
98 int save_size; /* save area size */
99 int fixed_size; /* fixed size of stack frame */
100 int gp_size; /* size of saved GP registers */
101 int fp_size; /* size of saved FP registers */
102 int altivec_size; /* size of saved AltiVec registers */
103 int cr_size; /* size to hold CR if not in save_size */
104 int vrsave_size; /* size to hold VRSAVE if not in save_size */
105 int altivec_padding_size; /* size of altivec alignment padding if
107 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
108 int spe_padding_size;
109 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
110 int spe_64bit_regs_used;
113 /* A C structure for machine-specific, per-function data.
114 This is added to the cfun structure. */
115 typedef struct GTY(()) machine_function
117 /* Some local-dynamic symbol. */
118 const char *some_ld_name;
119 /* Whether the instruction chain has been scanned already. */
120 int insn_chain_scanned_p;
121 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
122 int ra_needs_full_frame;
123 /* Flags if __builtin_return_address (0) was used. */
125 /* Cache lr_save_p after expansion of builtin_eh_return. */
127 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
128 varargs save area. */
129 HOST_WIDE_INT varargs_save_offset;
130 /* Temporary stack slot to use for SDmode copies. This slot is
131 64-bits wide and is allocated early enough so that the offset
132 does not overflow the 16-bit load/store offset field. */
133 rtx sdmode_stack_slot;
136 /* Target cpu type */
138 enum processor_type rs6000_cpu;
139 struct rs6000_cpu_select rs6000_select[3] =
141 /* switch name, tune arch */
142 { (const char *)0, "--with-cpu=", 1, 1 },
143 { (const char *)0, "-mcpu=", 1, 1 },
144 { (const char *)0, "-mtune=", 1, 0 },
147 /* Always emit branch hint bits. */
148 static GTY(()) bool rs6000_always_hint;
150 /* Schedule instructions for group formation. */
151 static GTY(()) bool rs6000_sched_groups;
153 /* Align branch targets. */
154 static GTY(()) bool rs6000_align_branch_targets;
156 /* Support for -msched-costly-dep option. */
157 const char *rs6000_sched_costly_dep_str;
158 enum rs6000_dependence_cost rs6000_sched_costly_dep;
160 /* Support for -minsert-sched-nops option. */
161 const char *rs6000_sched_insert_nops_str;
162 enum rs6000_nop_insertion rs6000_sched_insert_nops;
164 /* Support targetm.vectorize.builtin_mask_for_load. */
165 static GTY(()) tree altivec_builtin_mask_for_load;
167 /* Size of long double. */
168 int rs6000_long_double_type_size;
170 /* IEEE quad extended precision long double. */
173 /* Nonzero to use AltiVec ABI. */
174 int rs6000_altivec_abi;
176 /* Nonzero if we want SPE SIMD instructions. */
179 /* Nonzero if we want SPE ABI extensions. */
182 /* Nonzero if floating point operations are done in the GPRs. */
183 int rs6000_float_gprs = 0;
185 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
186 int rs6000_darwin64_abi;
188 /* Set to nonzero once AIX common-mode calls have been defined. */
189 static GTY(()) int common_mode_defined;
191 /* Label number of label created for -mrelocatable, to call to so we can
192 get the address of the GOT section */
193 int rs6000_pic_labelno;
196 /* Which abi to adhere to */
197 const char *rs6000_abi_name;
199 /* Semantics of the small data area */
200 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
202 /* Which small data model to use */
203 const char *rs6000_sdata_name = (char *)0;
205 /* Counter for labels which are to be placed in .fixup. */
206 int fixuplabelno = 0;
209 /* Bit size of immediate TLS offsets and string from which it is decoded. */
210 int rs6000_tls_size = 32;
211 const char *rs6000_tls_size_string;
213 /* ABI enumeration available for subtarget to use. */
214 enum rs6000_abi rs6000_current_abi;
216 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
220 const char *rs6000_debug_name;
221 int rs6000_debug_stack; /* debug stack applications */
222 int rs6000_debug_arg; /* debug argument handling */
223 int rs6000_debug_reg; /* debug register classes */
224 int rs6000_debug_addr; /* debug memory addressing */
225 int rs6000_debug_cost; /* debug rtx_costs */
227 /* Specify the machine mode that pointers have. After generation of rtl, the
228 compiler makes no further distinction between pointers and any other objects
229 of this machine mode. The type is unsigned since not all things that
230 include rs6000.h also include machmode.h. */
231 unsigned rs6000_pmode;
233 /* Width in bits of a pointer. */
234 unsigned rs6000_pointer_size;
237 /* Value is TRUE if register/mode pair is acceptable. */
238 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
240 /* Maximum number of registers needed for a given register class and mode. */
241 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
243 /* How many registers are needed for a given register and mode. */
244 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
246 /* Map register number to register class. */
247 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
249 /* Reload functions based on the type and the vector unit. */
250 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
252 /* Built in types. */
253 tree rs6000_builtin_types[RS6000_BTI_MAX];
254 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
256 const char *rs6000_traceback_name;
258 traceback_default = 0,
264 /* Flag to say the TOC is initialized */
266 char toc_label_name[10];
268 /* Cached value of rs6000_variable_issue. This is cached in
269 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
270 static short cached_can_issue_more;
272 static GTY(()) section *read_only_data_section;
273 static GTY(()) section *private_data_section;
274 static GTY(()) section *read_only_private_data_section;
275 static GTY(()) section *sdata2_section;
276 static GTY(()) section *toc_section;
278 /* Control alignment for fields within structures. */
279 /* String from -malign-XXXXX. */
280 int rs6000_alignment_flags;
282 /* Code model for 64-bit linux. */
283 enum rs6000_cmodel cmodel;
285 /* True for any options that were explicitly set. */
287 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
288 bool alignment; /* True if -malign- was used. */
289 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
290 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
291 bool spe; /* True if -mspe= was used. */
292 bool float_gprs; /* True if -mfloat-gprs= was used. */
293 bool long_double; /* True if -mlong-double- was used. */
294 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
295 bool vrsave; /* True if -mvrsave was used. */
296 bool cmodel; /* True if -mcmodel was used. */
297 } rs6000_explicit_options;
299 struct builtin_description
301 /* mask is not const because we're going to alter it below. This
302 nonsense will go away when we rewrite the -march infrastructure
303 to give us more target flag bits. */
305 const enum insn_code icode;
306 const char *const name;
307 const enum rs6000_builtins code;
310 /* Describe the vector unit used for modes. */
311 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
312 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
314 /* Register classes for various constraints that are based on the target
316 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
318 /* Describe the alignment of a vector. */
319 int rs6000_vector_align[NUM_MACHINE_MODES];
321 /* Map selected modes to types for builtins. */
322 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
324 /* What modes to automatically generate reciprocal divide estimate (fre) and
325 reciprocal sqrt (frsqrte) for. */
326 unsigned char rs6000_recip_bits[MAX_MACHINE_MODE];
328 /* Masks to determine which reciprocal esitmate instructions to generate
330 enum rs6000_recip_mask {
331 RECIP_SF_DIV = 0x001, /* Use divide estimate */
332 RECIP_DF_DIV = 0x002,
333 RECIP_V4SF_DIV = 0x004,
334 RECIP_V2DF_DIV = 0x008,
336 RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */
337 RECIP_DF_RSQRT = 0x020,
338 RECIP_V4SF_RSQRT = 0x040,
339 RECIP_V2DF_RSQRT = 0x080,
341 /* Various combination of flags for -mrecip=xxx. */
343 RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
344 | RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT
345 | RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT),
347 RECIP_HIGH_PRECISION = RECIP_ALL,
349 /* On low precision machines like the power5, don't enable double precision
350 reciprocal square root estimate, since it isn't accurate enough. */
351 RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT))
354 static unsigned int rs6000_recip_control;
355 static const char *rs6000_recip_name;
357 /* -mrecip options. */
360 const char *string; /* option name */
361 unsigned int mask; /* mask bits to set */
362 } recip_options[] = {
363 { "all", RECIP_ALL },
364 { "none", RECIP_NONE },
365 { "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
367 { "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) },
368 { "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) },
369 { "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT
370 | RECIP_V2DF_RSQRT) },
371 { "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) },
372 { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) },
375 /* 2 argument gen function typedef. */
376 typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx);
379 /* Target cpu costs. */
381 struct processor_costs {
382 const int mulsi; /* cost of SImode multiplication. */
383 const int mulsi_const; /* cost of SImode multiplication by constant. */
384 const int mulsi_const9; /* cost of SImode mult by short constant. */
385 const int muldi; /* cost of DImode multiplication. */
386 const int divsi; /* cost of SImode division. */
387 const int divdi; /* cost of DImode division. */
388 const int fp; /* cost of simple SFmode and DFmode insns. */
389 const int dmul; /* cost of DFmode multiplication (and fmadd). */
390 const int sdiv; /* cost of SFmode division (fdivs). */
391 const int ddiv; /* cost of DFmode division (fdiv). */
392 const int cache_line_size; /* cache line size in bytes. */
393 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
394 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
395 const int simultaneous_prefetches; /* number of parallel prefetch
399 const struct processor_costs *rs6000_cost;
401 /* Processor costs (relative to an add) */
403 /* Instruction size costs on 32bit processors. */
405 struct processor_costs size32_cost = {
406 COSTS_N_INSNS (1), /* mulsi */
407 COSTS_N_INSNS (1), /* mulsi_const */
408 COSTS_N_INSNS (1), /* mulsi_const9 */
409 COSTS_N_INSNS (1), /* muldi */
410 COSTS_N_INSNS (1), /* divsi */
411 COSTS_N_INSNS (1), /* divdi */
412 COSTS_N_INSNS (1), /* fp */
413 COSTS_N_INSNS (1), /* dmul */
414 COSTS_N_INSNS (1), /* sdiv */
415 COSTS_N_INSNS (1), /* ddiv */
422 /* Instruction size costs on 64bit processors. */
424 struct processor_costs size64_cost = {
425 COSTS_N_INSNS (1), /* mulsi */
426 COSTS_N_INSNS (1), /* mulsi_const */
427 COSTS_N_INSNS (1), /* mulsi_const9 */
428 COSTS_N_INSNS (1), /* muldi */
429 COSTS_N_INSNS (1), /* divsi */
430 COSTS_N_INSNS (1), /* divdi */
431 COSTS_N_INSNS (1), /* fp */
432 COSTS_N_INSNS (1), /* dmul */
433 COSTS_N_INSNS (1), /* sdiv */
434 COSTS_N_INSNS (1), /* ddiv */
441 /* Instruction costs on RIOS1 processors. */
443 struct processor_costs rios1_cost = {
444 COSTS_N_INSNS (5), /* mulsi */
445 COSTS_N_INSNS (4), /* mulsi_const */
446 COSTS_N_INSNS (3), /* mulsi_const9 */
447 COSTS_N_INSNS (5), /* muldi */
448 COSTS_N_INSNS (19), /* divsi */
449 COSTS_N_INSNS (19), /* divdi */
450 COSTS_N_INSNS (2), /* fp */
451 COSTS_N_INSNS (2), /* dmul */
452 COSTS_N_INSNS (19), /* sdiv */
453 COSTS_N_INSNS (19), /* ddiv */
454 128, /* cache line size */
460 /* Instruction costs on RIOS2 processors. */
462 struct processor_costs rios2_cost = {
463 COSTS_N_INSNS (2), /* mulsi */
464 COSTS_N_INSNS (2), /* mulsi_const */
465 COSTS_N_INSNS (2), /* mulsi_const9 */
466 COSTS_N_INSNS (2), /* muldi */
467 COSTS_N_INSNS (13), /* divsi */
468 COSTS_N_INSNS (13), /* divdi */
469 COSTS_N_INSNS (2), /* fp */
470 COSTS_N_INSNS (2), /* dmul */
471 COSTS_N_INSNS (17), /* sdiv */
472 COSTS_N_INSNS (17), /* ddiv */
473 256, /* cache line size */
479 /* Instruction costs on RS64A processors. */
481 struct processor_costs rs64a_cost = {
482 COSTS_N_INSNS (20), /* mulsi */
483 COSTS_N_INSNS (12), /* mulsi_const */
484 COSTS_N_INSNS (8), /* mulsi_const9 */
485 COSTS_N_INSNS (34), /* muldi */
486 COSTS_N_INSNS (65), /* divsi */
487 COSTS_N_INSNS (67), /* divdi */
488 COSTS_N_INSNS (4), /* fp */
489 COSTS_N_INSNS (4), /* dmul */
490 COSTS_N_INSNS (31), /* sdiv */
491 COSTS_N_INSNS (31), /* ddiv */
492 128, /* cache line size */
498 /* Instruction costs on MPCCORE processors. */
500 struct processor_costs mpccore_cost = {
501 COSTS_N_INSNS (2), /* mulsi */
502 COSTS_N_INSNS (2), /* mulsi_const */
503 COSTS_N_INSNS (2), /* mulsi_const9 */
504 COSTS_N_INSNS (2), /* muldi */
505 COSTS_N_INSNS (6), /* divsi */
506 COSTS_N_INSNS (6), /* divdi */
507 COSTS_N_INSNS (4), /* fp */
508 COSTS_N_INSNS (5), /* dmul */
509 COSTS_N_INSNS (10), /* sdiv */
510 COSTS_N_INSNS (17), /* ddiv */
511 32, /* cache line size */
517 /* Instruction costs on PPC403 processors. */
519 struct processor_costs ppc403_cost = {
520 COSTS_N_INSNS (4), /* mulsi */
521 COSTS_N_INSNS (4), /* mulsi_const */
522 COSTS_N_INSNS (4), /* mulsi_const9 */
523 COSTS_N_INSNS (4), /* muldi */
524 COSTS_N_INSNS (33), /* divsi */
525 COSTS_N_INSNS (33), /* divdi */
526 COSTS_N_INSNS (11), /* fp */
527 COSTS_N_INSNS (11), /* dmul */
528 COSTS_N_INSNS (11), /* sdiv */
529 COSTS_N_INSNS (11), /* ddiv */
530 32, /* cache line size */
536 /* Instruction costs on PPC405 processors. */
538 struct processor_costs ppc405_cost = {
539 COSTS_N_INSNS (5), /* mulsi */
540 COSTS_N_INSNS (4), /* mulsi_const */
541 COSTS_N_INSNS (3), /* mulsi_const9 */
542 COSTS_N_INSNS (5), /* muldi */
543 COSTS_N_INSNS (35), /* divsi */
544 COSTS_N_INSNS (35), /* divdi */
545 COSTS_N_INSNS (11), /* fp */
546 COSTS_N_INSNS (11), /* dmul */
547 COSTS_N_INSNS (11), /* sdiv */
548 COSTS_N_INSNS (11), /* ddiv */
549 32, /* cache line size */
555 /* Instruction costs on PPC440 processors. */
557 struct processor_costs ppc440_cost = {
558 COSTS_N_INSNS (3), /* mulsi */
559 COSTS_N_INSNS (2), /* mulsi_const */
560 COSTS_N_INSNS (2), /* mulsi_const9 */
561 COSTS_N_INSNS (3), /* muldi */
562 COSTS_N_INSNS (34), /* divsi */
563 COSTS_N_INSNS (34), /* divdi */
564 COSTS_N_INSNS (5), /* fp */
565 COSTS_N_INSNS (5), /* dmul */
566 COSTS_N_INSNS (19), /* sdiv */
567 COSTS_N_INSNS (33), /* ddiv */
568 32, /* cache line size */
574 /* Instruction costs on PPC476 processors. */
576 struct processor_costs ppc476_cost = {
577 COSTS_N_INSNS (4), /* mulsi */
578 COSTS_N_INSNS (4), /* mulsi_const */
579 COSTS_N_INSNS (4), /* mulsi_const9 */
580 COSTS_N_INSNS (4), /* muldi */
581 COSTS_N_INSNS (11), /* divsi */
582 COSTS_N_INSNS (11), /* divdi */
583 COSTS_N_INSNS (6), /* fp */
584 COSTS_N_INSNS (6), /* dmul */
585 COSTS_N_INSNS (19), /* sdiv */
586 COSTS_N_INSNS (33), /* ddiv */
587 32, /* l1 cache line size */
593 /* Instruction costs on PPC601 processors. */
595 struct processor_costs ppc601_cost = {
596 COSTS_N_INSNS (5), /* mulsi */
597 COSTS_N_INSNS (5), /* mulsi_const */
598 COSTS_N_INSNS (5), /* mulsi_const9 */
599 COSTS_N_INSNS (5), /* muldi */
600 COSTS_N_INSNS (36), /* divsi */
601 COSTS_N_INSNS (36), /* divdi */
602 COSTS_N_INSNS (4), /* fp */
603 COSTS_N_INSNS (5), /* dmul */
604 COSTS_N_INSNS (17), /* sdiv */
605 COSTS_N_INSNS (31), /* ddiv */
606 32, /* cache line size */
612 /* Instruction costs on PPC603 processors. */
614 struct processor_costs ppc603_cost = {
615 COSTS_N_INSNS (5), /* mulsi */
616 COSTS_N_INSNS (3), /* mulsi_const */
617 COSTS_N_INSNS (2), /* mulsi_const9 */
618 COSTS_N_INSNS (5), /* muldi */
619 COSTS_N_INSNS (37), /* divsi */
620 COSTS_N_INSNS (37), /* divdi */
621 COSTS_N_INSNS (3), /* fp */
622 COSTS_N_INSNS (4), /* dmul */
623 COSTS_N_INSNS (18), /* sdiv */
624 COSTS_N_INSNS (33), /* ddiv */
625 32, /* cache line size */
631 /* Instruction costs on PPC604 processors. */
633 struct processor_costs ppc604_cost = {
634 COSTS_N_INSNS (4), /* mulsi */
635 COSTS_N_INSNS (4), /* mulsi_const */
636 COSTS_N_INSNS (4), /* mulsi_const9 */
637 COSTS_N_INSNS (4), /* muldi */
638 COSTS_N_INSNS (20), /* divsi */
639 COSTS_N_INSNS (20), /* divdi */
640 COSTS_N_INSNS (3), /* fp */
641 COSTS_N_INSNS (3), /* dmul */
642 COSTS_N_INSNS (18), /* sdiv */
643 COSTS_N_INSNS (32), /* ddiv */
644 32, /* cache line size */
650 /* Instruction costs on PPC604e processors. */
652 struct processor_costs ppc604e_cost = {
653 COSTS_N_INSNS (2), /* mulsi */
654 COSTS_N_INSNS (2), /* mulsi_const */
655 COSTS_N_INSNS (2), /* mulsi_const9 */
656 COSTS_N_INSNS (2), /* muldi */
657 COSTS_N_INSNS (20), /* divsi */
658 COSTS_N_INSNS (20), /* divdi */
659 COSTS_N_INSNS (3), /* fp */
660 COSTS_N_INSNS (3), /* dmul */
661 COSTS_N_INSNS (18), /* sdiv */
662 COSTS_N_INSNS (32), /* ddiv */
663 32, /* cache line size */
669 /* Instruction costs on PPC620 processors. */
671 struct processor_costs ppc620_cost = {
672 COSTS_N_INSNS (5), /* mulsi */
673 COSTS_N_INSNS (4), /* mulsi_const */
674 COSTS_N_INSNS (3), /* mulsi_const9 */
675 COSTS_N_INSNS (7), /* muldi */
676 COSTS_N_INSNS (21), /* divsi */
677 COSTS_N_INSNS (37), /* divdi */
678 COSTS_N_INSNS (3), /* fp */
679 COSTS_N_INSNS (3), /* dmul */
680 COSTS_N_INSNS (18), /* sdiv */
681 COSTS_N_INSNS (32), /* ddiv */
682 128, /* cache line size */
688 /* Instruction costs on PPC630 processors. */
690 struct processor_costs ppc630_cost = {
691 COSTS_N_INSNS (5), /* mulsi */
692 COSTS_N_INSNS (4), /* mulsi_const */
693 COSTS_N_INSNS (3), /* mulsi_const9 */
694 COSTS_N_INSNS (7), /* muldi */
695 COSTS_N_INSNS (21), /* divsi */
696 COSTS_N_INSNS (37), /* divdi */
697 COSTS_N_INSNS (3), /* fp */
698 COSTS_N_INSNS (3), /* dmul */
699 COSTS_N_INSNS (17), /* sdiv */
700 COSTS_N_INSNS (21), /* ddiv */
701 128, /* cache line size */
707 /* Instruction costs on Cell processor. */
708 /* COSTS_N_INSNS (1) ~ one add. */
710 struct processor_costs ppccell_cost = {
711 COSTS_N_INSNS (9/2)+2, /* mulsi */
712 COSTS_N_INSNS (6/2), /* mulsi_const */
713 COSTS_N_INSNS (6/2), /* mulsi_const9 */
714 COSTS_N_INSNS (15/2)+2, /* muldi */
715 COSTS_N_INSNS (38/2), /* divsi */
716 COSTS_N_INSNS (70/2), /* divdi */
717 COSTS_N_INSNS (10/2), /* fp */
718 COSTS_N_INSNS (10/2), /* dmul */
719 COSTS_N_INSNS (74/2), /* sdiv */
720 COSTS_N_INSNS (74/2), /* ddiv */
721 128, /* cache line size */
727 /* Instruction costs on PPC750 and PPC7400 processors. */
729 struct processor_costs ppc750_cost = {
730 COSTS_N_INSNS (5), /* mulsi */
731 COSTS_N_INSNS (3), /* mulsi_const */
732 COSTS_N_INSNS (2), /* mulsi_const9 */
733 COSTS_N_INSNS (5), /* muldi */
734 COSTS_N_INSNS (17), /* divsi */
735 COSTS_N_INSNS (17), /* divdi */
736 COSTS_N_INSNS (3), /* fp */
737 COSTS_N_INSNS (3), /* dmul */
738 COSTS_N_INSNS (17), /* sdiv */
739 COSTS_N_INSNS (31), /* ddiv */
740 32, /* cache line size */
746 /* Instruction costs on PPC7450 processors. */
748 struct processor_costs ppc7450_cost = {
749 COSTS_N_INSNS (4), /* mulsi */
750 COSTS_N_INSNS (3), /* mulsi_const */
751 COSTS_N_INSNS (3), /* mulsi_const9 */
752 COSTS_N_INSNS (4), /* muldi */
753 COSTS_N_INSNS (23), /* divsi */
754 COSTS_N_INSNS (23), /* divdi */
755 COSTS_N_INSNS (5), /* fp */
756 COSTS_N_INSNS (5), /* dmul */
757 COSTS_N_INSNS (21), /* sdiv */
758 COSTS_N_INSNS (35), /* ddiv */
759 32, /* cache line size */
765 /* Instruction costs on PPC8540 processors. */
767 struct processor_costs ppc8540_cost = {
768 COSTS_N_INSNS (4), /* mulsi */
769 COSTS_N_INSNS (4), /* mulsi_const */
770 COSTS_N_INSNS (4), /* mulsi_const9 */
771 COSTS_N_INSNS (4), /* muldi */
772 COSTS_N_INSNS (19), /* divsi */
773 COSTS_N_INSNS (19), /* divdi */
774 COSTS_N_INSNS (4), /* fp */
775 COSTS_N_INSNS (4), /* dmul */
776 COSTS_N_INSNS (29), /* sdiv */
777 COSTS_N_INSNS (29), /* ddiv */
778 32, /* cache line size */
781 1, /* prefetch streams /*/
784 /* Instruction costs on E300C2 and E300C3 cores. */
786 struct processor_costs ppce300c2c3_cost = {
787 COSTS_N_INSNS (4), /* mulsi */
788 COSTS_N_INSNS (4), /* mulsi_const */
789 COSTS_N_INSNS (4), /* mulsi_const9 */
790 COSTS_N_INSNS (4), /* muldi */
791 COSTS_N_INSNS (19), /* divsi */
792 COSTS_N_INSNS (19), /* divdi */
793 COSTS_N_INSNS (3), /* fp */
794 COSTS_N_INSNS (4), /* dmul */
795 COSTS_N_INSNS (18), /* sdiv */
796 COSTS_N_INSNS (33), /* ddiv */
800 1, /* prefetch streams /*/
803 /* Instruction costs on PPCE500MC processors. */
805 struct processor_costs ppce500mc_cost = {
806 COSTS_N_INSNS (4), /* mulsi */
807 COSTS_N_INSNS (4), /* mulsi_const */
808 COSTS_N_INSNS (4), /* mulsi_const9 */
809 COSTS_N_INSNS (4), /* muldi */
810 COSTS_N_INSNS (14), /* divsi */
811 COSTS_N_INSNS (14), /* divdi */
812 COSTS_N_INSNS (8), /* fp */
813 COSTS_N_INSNS (10), /* dmul */
814 COSTS_N_INSNS (36), /* sdiv */
815 COSTS_N_INSNS (66), /* ddiv */
816 64, /* cache line size */
819 1, /* prefetch streams /*/
822 /* Instruction costs on PPCE500MC64 processors. */
824 struct processor_costs ppce500mc64_cost = {
825 COSTS_N_INSNS (4), /* mulsi */
826 COSTS_N_INSNS (4), /* mulsi_const */
827 COSTS_N_INSNS (4), /* mulsi_const9 */
828 COSTS_N_INSNS (4), /* muldi */
829 COSTS_N_INSNS (14), /* divsi */
830 COSTS_N_INSNS (14), /* divdi */
831 COSTS_N_INSNS (4), /* fp */
832 COSTS_N_INSNS (10), /* dmul */
833 COSTS_N_INSNS (36), /* sdiv */
834 COSTS_N_INSNS (66), /* ddiv */
835 64, /* cache line size */
838 1, /* prefetch streams /*/
841 /* Instruction costs on POWER4 and POWER5 processors. */
843 struct processor_costs power4_cost = {
844 COSTS_N_INSNS (3), /* mulsi */
845 COSTS_N_INSNS (2), /* mulsi_const */
846 COSTS_N_INSNS (2), /* mulsi_const9 */
847 COSTS_N_INSNS (4), /* muldi */
848 COSTS_N_INSNS (18), /* divsi */
849 COSTS_N_INSNS (34), /* divdi */
850 COSTS_N_INSNS (3), /* fp */
851 COSTS_N_INSNS (3), /* dmul */
852 COSTS_N_INSNS (17), /* sdiv */
853 COSTS_N_INSNS (17), /* ddiv */
854 128, /* cache line size */
857 8, /* prefetch streams /*/
860 /* Instruction costs on POWER6 processors. */
862 struct processor_costs power6_cost = {
863 COSTS_N_INSNS (8), /* mulsi */
864 COSTS_N_INSNS (8), /* mulsi_const */
865 COSTS_N_INSNS (8), /* mulsi_const9 */
866 COSTS_N_INSNS (8), /* muldi */
867 COSTS_N_INSNS (22), /* divsi */
868 COSTS_N_INSNS (28), /* divdi */
869 COSTS_N_INSNS (3), /* fp */
870 COSTS_N_INSNS (3), /* dmul */
871 COSTS_N_INSNS (13), /* sdiv */
872 COSTS_N_INSNS (16), /* ddiv */
873 128, /* cache line size */
876 16, /* prefetch streams */
879 /* Instruction costs on POWER7 processors. */
881 struct processor_costs power7_cost = {
882 COSTS_N_INSNS (2), /* mulsi */
883 COSTS_N_INSNS (2), /* mulsi_const */
884 COSTS_N_INSNS (2), /* mulsi_const9 */
885 COSTS_N_INSNS (2), /* muldi */
886 COSTS_N_INSNS (18), /* divsi */
887 COSTS_N_INSNS (34), /* divdi */
888 COSTS_N_INSNS (3), /* fp */
889 COSTS_N_INSNS (3), /* dmul */
890 COSTS_N_INSNS (13), /* sdiv */
891 COSTS_N_INSNS (16), /* ddiv */
892 128, /* cache line size */
895 12, /* prefetch streams */
898 /* Instruction costs on POWER A2 processors. */
900 struct processor_costs ppca2_cost = {
901 COSTS_N_INSNS (16), /* mulsi */
902 COSTS_N_INSNS (16), /* mulsi_const */
903 COSTS_N_INSNS (16), /* mulsi_const9 */
904 COSTS_N_INSNS (16), /* muldi */
905 COSTS_N_INSNS (22), /* divsi */
906 COSTS_N_INSNS (28), /* divdi */
907 COSTS_N_INSNS (3), /* fp */
908 COSTS_N_INSNS (3), /* dmul */
909 COSTS_N_INSNS (59), /* sdiv */
910 COSTS_N_INSNS (72), /* ddiv */
914 16, /* prefetch streams */
918 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
919 #undef RS6000_BUILTIN
920 #undef RS6000_BUILTIN_EQUATE
921 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
922 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
924 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
926 #include "rs6000-builtin.def"
929 #undef RS6000_BUILTIN
930 #undef RS6000_BUILTIN_EQUATE
933 static bool rs6000_function_ok_for_sibcall (tree, tree);
934 static const char *rs6000_invalid_within_doloop (const_rtx);
935 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
936 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
937 static rtx rs6000_generate_compare (rtx, enum machine_mode);
938 static void rs6000_emit_stack_tie (void);
939 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
940 static bool spe_func_has_64bit_regs_p (void);
941 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
943 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
944 static unsigned rs6000_hash_constant (rtx);
945 static unsigned toc_hash_function (const void *);
946 static int toc_hash_eq (const void *, const void *);
947 static bool reg_offset_addressing_ok_p (enum machine_mode);
948 static bool virtual_stack_registers_memory_p (rtx);
949 static bool constant_pool_expr_p (rtx);
950 static bool legitimate_small_data_p (enum machine_mode, rtx);
951 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
952 static struct machine_function * rs6000_init_machine_status (void);
953 static bool rs6000_assemble_integer (rtx, unsigned int, int);
954 static bool no_global_regs_above (int, bool);
955 #ifdef HAVE_GAS_HIDDEN
956 static void rs6000_assemble_visibility (tree, int);
958 static int rs6000_ra_ever_killed (void);
959 static bool rs6000_attribute_takes_identifier_p (const_tree);
960 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
961 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
962 static bool rs6000_ms_bitfield_layout_p (const_tree);
963 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
964 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
965 static const char *rs6000_mangle_type (const_tree);
966 static void rs6000_set_default_type_attributes (tree);
967 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
968 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
969 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
970 enum machine_mode, bool, bool, bool);
971 static bool rs6000_reg_live_or_pic_offset_p (int);
972 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
973 static int rs6000_savres_strategy (rs6000_stack_t *, bool, int, int);
974 static void rs6000_restore_saved_cr (rtx, int);
975 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
976 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
977 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
979 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
980 static bool rs6000_return_in_memory (const_tree, const_tree);
981 static rtx rs6000_function_value (const_tree, const_tree, bool);
982 static void rs6000_file_start (void);
984 static int rs6000_elf_reloc_rw_mask (void);
985 static void rs6000_elf_asm_out_constructor (rtx, int);
986 static void rs6000_elf_asm_out_destructor (rtx, int);
987 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
988 static void rs6000_elf_asm_init_sections (void);
989 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
990 unsigned HOST_WIDE_INT);
991 static void rs6000_elf_encode_section_info (tree, rtx, int)
994 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
995 static void rs6000_alloc_sdmode_stack_slot (void);
996 static void rs6000_instantiate_decls (void);
998 static void rs6000_xcoff_asm_output_anchor (rtx);
999 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
1000 static void rs6000_xcoff_asm_init_sections (void);
1001 static int rs6000_xcoff_reloc_rw_mask (void);
1002 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
1003 static section *rs6000_xcoff_select_section (tree, int,
1004 unsigned HOST_WIDE_INT);
1005 static void rs6000_xcoff_unique_section (tree, int);
1006 static section *rs6000_xcoff_select_rtx_section
1007 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
1008 static const char * rs6000_xcoff_strip_name_encoding (const char *);
1009 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
1010 static void rs6000_xcoff_file_start (void);
1011 static void rs6000_xcoff_file_end (void);
1013 static int rs6000_variable_issue (FILE *, int, rtx, int);
1014 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
1015 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
1016 static int rs6000_debug_address_cost (rtx, bool);
1017 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
1018 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
1019 static void rs6000_sched_init (FILE *, int, int);
1020 static bool is_microcoded_insn (rtx);
1021 static bool is_nonpipeline_insn (rtx);
1022 static bool is_cracked_insn (rtx);
1023 static bool is_branch_slot_insn (rtx);
1024 static bool is_load_insn (rtx);
1025 static rtx get_store_dest (rtx pat);
1026 static bool is_store_insn (rtx);
1027 static bool set_to_load_agen (rtx,rtx);
1028 static bool adjacent_mem_locations (rtx,rtx);
1029 static int rs6000_adjust_priority (rtx, int);
1030 static int rs6000_issue_rate (void);
1031 static bool rs6000_is_costly_dependence (dep_t, int, int);
1032 static rtx get_next_active_insn (rtx, rtx);
1033 static bool insn_terminates_group_p (rtx , enum group_termination);
1034 static bool insn_must_be_first_in_group (rtx);
1035 static bool insn_must_be_last_in_group (rtx);
1036 static bool is_costly_group (rtx *, rtx);
1037 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
1038 static int redefine_groups (FILE *, int, rtx, rtx);
1039 static int pad_groups (FILE *, int, rtx, rtx);
1040 static void rs6000_sched_finish (FILE *, int);
1041 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
1042 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
1043 static int rs6000_use_sched_lookahead (void);
1044 static int rs6000_use_sched_lookahead_guard (rtx);
1045 static void * rs6000_alloc_sched_context (void);
1046 static void rs6000_init_sched_context (void *, bool);
1047 static void rs6000_set_sched_context (void *);
1048 static void rs6000_free_sched_context (void *);
1049 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
1050 static tree rs6000_builtin_mask_for_load (void);
1051 static tree rs6000_builtin_mul_widen_even (tree);
1052 static tree rs6000_builtin_mul_widen_odd (tree);
1053 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
1054 static tree rs6000_builtin_vec_perm (tree, tree *);
1055 static bool rs6000_builtin_support_vector_misalignment (enum
1060 static void def_builtin (int, const char *, tree, int);
1061 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1062 static void rs6000_init_builtins (void);
1063 static tree rs6000_builtin_decl (unsigned, bool);
1065 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1066 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1067 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1068 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1069 static void altivec_init_builtins (void);
1070 static unsigned builtin_hash_function (const void *);
1071 static int builtin_hash_eq (const void *, const void *);
1072 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1073 enum machine_mode, enum machine_mode,
1074 enum rs6000_builtins, const char *name);
1075 static void rs6000_common_init_builtins (void);
1076 static void rs6000_init_libfuncs (void);
1078 static void paired_init_builtins (void);
1079 static rtx paired_expand_builtin (tree, rtx, bool *);
1080 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1081 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1082 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1084 static void enable_mask_for_builtins (struct builtin_description *, int,
1085 enum rs6000_builtins,
1086 enum rs6000_builtins);
1087 static void spe_init_builtins (void);
1088 static rtx spe_expand_builtin (tree, rtx, bool *);
1089 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1090 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1091 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1092 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1093 static rs6000_stack_t *rs6000_stack_info (void);
1094 static void debug_stack_info (rs6000_stack_t *);
1096 static rtx altivec_expand_builtin (tree, rtx, bool *);
1097 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1098 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1099 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1100 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1101 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1102 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1103 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1104 static rtx altivec_expand_vec_set_builtin (tree);
1105 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1106 static int get_element_number (tree, tree);
1107 static bool rs6000_handle_option (size_t, const char *, int);
1108 static void rs6000_parse_tls_size_option (void);
1109 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1110 static int first_altivec_reg_to_save (void);
1111 static unsigned int compute_vrsave_mask (void);
1112 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1113 static void is_altivec_return_reg (rtx, void *);
1114 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1115 int easy_vector_constant (rtx, enum machine_mode);
1116 static rtx rs6000_dwarf_register_span (rtx);
1117 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1118 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1119 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1120 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1121 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1122 static rtx rs6000_delegitimize_address (rtx);
1123 static rtx rs6000_tls_get_addr (void);
1124 static rtx rs6000_got_sym (void);
1125 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1126 static const char *rs6000_get_some_local_dynamic_name (void);
1127 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1128 static rtx rs6000_complex_function_value (enum machine_mode);
1129 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
1130 enum machine_mode, tree);
1131 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1133 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1134 tree, HOST_WIDE_INT);
1135 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1138 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1139 const_tree, HOST_WIDE_INT,
1141 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
1142 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
1143 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1144 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1145 enum machine_mode, tree,
1147 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1149 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1151 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1153 static void macho_branch_islands (void);
1154 static int no_previous_def (tree function_name);
1155 static tree get_prev_label (tree function_name);
1156 static void rs6000_darwin_file_start (void);
1159 static tree rs6000_build_builtin_va_list (void);
1160 static void rs6000_va_start (tree, rtx);
1161 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1162 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1163 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1164 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1165 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1166 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1168 static tree rs6000_stack_protect_fail (void);
1170 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1173 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1176 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1178 = rs6000_legitimize_reload_address;
1180 static bool rs6000_mode_dependent_address_p (const_rtx);
1181 static bool rs6000_mode_dependent_address (const_rtx);
1182 static bool rs6000_debug_mode_dependent_address (const_rtx);
1183 static bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1184 = rs6000_mode_dependent_address;
1186 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1187 enum machine_mode, rtx);
1188 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1191 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1192 enum machine_mode, rtx)
1193 = rs6000_secondary_reload_class;
1195 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1196 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1198 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1199 = rs6000_preferred_reload_class;
1201 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1204 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1208 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1210 = rs6000_secondary_memory_needed;
1212 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1215 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1219 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1222 = rs6000_cannot_change_mode_class;
1224 static enum reg_class rs6000_secondary_reload (bool, rtx, enum reg_class,
1226 struct secondary_reload_info *);
1228 static const enum reg_class *rs6000_ira_cover_classes (void);
1230 const int INSN_NOT_AVAILABLE = -1;
1231 static enum machine_mode rs6000_eh_return_filter_mode (void);
1232 static bool rs6000_can_eliminate (const int, const int);
1233 static void rs6000_trampoline_init (rtx, tree, rtx);
1235 /* Hash table stuff for keeping track of TOC entries. */
1237 struct GTY(()) toc_hash_struct
1239 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1240 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1242 enum machine_mode key_mode;
1246 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1248 /* Hash table to keep track of the argument types for builtin functions. */
1250 struct GTY(()) builtin_hash_struct
1253 enum machine_mode mode[4]; /* return value + 3 arguments. */
1254 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1257 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1259 /* Default register names. */
1260 char rs6000_reg_names[][8] =
1262 "0", "1", "2", "3", "4", "5", "6", "7",
1263 "8", "9", "10", "11", "12", "13", "14", "15",
1264 "16", "17", "18", "19", "20", "21", "22", "23",
1265 "24", "25", "26", "27", "28", "29", "30", "31",
1266 "0", "1", "2", "3", "4", "5", "6", "7",
1267 "8", "9", "10", "11", "12", "13", "14", "15",
1268 "16", "17", "18", "19", "20", "21", "22", "23",
1269 "24", "25", "26", "27", "28", "29", "30", "31",
1270 "mq", "lr", "ctr","ap",
1271 "0", "1", "2", "3", "4", "5", "6", "7",
1273 /* AltiVec registers. */
1274 "0", "1", "2", "3", "4", "5", "6", "7",
1275 "8", "9", "10", "11", "12", "13", "14", "15",
1276 "16", "17", "18", "19", "20", "21", "22", "23",
1277 "24", "25", "26", "27", "28", "29", "30", "31",
1279 /* SPE registers. */
1280 "spe_acc", "spefscr",
1281 /* Soft frame pointer. */
1285 #ifdef TARGET_REGNAMES
1286 static const char alt_reg_names[][8] =
1288 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1289 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1290 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1291 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1292 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1293 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1294 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1295 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1296 "mq", "lr", "ctr", "ap",
1297 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1299 /* AltiVec registers. */
1300 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1301 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1302 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1303 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1305 /* SPE registers. */
1306 "spe_acc", "spefscr",
1307 /* Soft frame pointer. */
1312 /* Table of valid machine attributes. */
1314 static const struct attribute_spec rs6000_attribute_table[] =
1316 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1317 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute },
1318 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1319 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1320 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1321 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1322 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1323 SUBTARGET_ATTRIBUTE_TABLE,
1325 { NULL, 0, 0, false, false, false, NULL }
1328 #ifndef MASK_STRICT_ALIGN
1329 #define MASK_STRICT_ALIGN 0
1331 #ifndef TARGET_PROFILE_KERNEL
1332 #define TARGET_PROFILE_KERNEL 0
1335 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1336 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1338 /* Initialize the GCC target structure. */
1339 #undef TARGET_ATTRIBUTE_TABLE
1340 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1341 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1342 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1343 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1344 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1346 #undef TARGET_ASM_ALIGNED_DI_OP
1347 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1349 /* Default unaligned ops are only provided for ELF. Find the ops needed
1350 for non-ELF systems. */
1351 #ifndef OBJECT_FORMAT_ELF
1353 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1355 #undef TARGET_ASM_UNALIGNED_HI_OP
1356 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1357 #undef TARGET_ASM_UNALIGNED_SI_OP
1358 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1359 #undef TARGET_ASM_UNALIGNED_DI_OP
1360 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1363 #undef TARGET_ASM_UNALIGNED_HI_OP
1364 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1365 #undef TARGET_ASM_UNALIGNED_SI_OP
1366 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1367 #undef TARGET_ASM_UNALIGNED_DI_OP
1368 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1369 #undef TARGET_ASM_ALIGNED_DI_OP
1370 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1374 /* This hook deals with fixups for relocatable code and DI-mode objects
1376 #undef TARGET_ASM_INTEGER
1377 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1379 #ifdef HAVE_GAS_HIDDEN
1380 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1381 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1384 #undef TARGET_HAVE_TLS
1385 #define TARGET_HAVE_TLS HAVE_AS_TLS
1387 #undef TARGET_CANNOT_FORCE_CONST_MEM
1388 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1390 #undef TARGET_DELEGITIMIZE_ADDRESS
1391 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1393 #undef TARGET_ASM_FUNCTION_PROLOGUE
1394 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1395 #undef TARGET_ASM_FUNCTION_EPILOGUE
1396 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1398 #undef TARGET_LEGITIMIZE_ADDRESS
1399 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1401 #undef TARGET_SCHED_VARIABLE_ISSUE
1402 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1404 #undef TARGET_SCHED_ISSUE_RATE
1405 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1406 #undef TARGET_SCHED_ADJUST_COST
1407 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1408 #undef TARGET_SCHED_ADJUST_PRIORITY
1409 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1410 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1411 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1412 #undef TARGET_SCHED_INIT
1413 #define TARGET_SCHED_INIT rs6000_sched_init
1414 #undef TARGET_SCHED_FINISH
1415 #define TARGET_SCHED_FINISH rs6000_sched_finish
1416 #undef TARGET_SCHED_REORDER
1417 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1418 #undef TARGET_SCHED_REORDER2
1419 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1421 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1422 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1424 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1425 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1427 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1428 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1429 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1430 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1431 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1432 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1433 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1434 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1436 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1437 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1438 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1439 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1440 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1441 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1442 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1443 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1444 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1445 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1446 #undef TARGET_SUPPORT_VECTOR_MISALIGNMENT
1447 #define TARGET_SUPPORT_VECTOR_MISALIGNMENT \
1448 rs6000_builtin_support_vector_misalignment
1449 #undef TARGET_VECTOR_ALIGNMENT_REACHABLE
1450 #define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1452 #undef TARGET_INIT_BUILTINS
1453 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1454 #undef TARGET_BUILTIN_DECL
1455 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1457 #undef TARGET_EXPAND_BUILTIN
1458 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1460 #undef TARGET_MANGLE_TYPE
1461 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1463 #undef TARGET_INIT_LIBFUNCS
1464 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1467 #undef TARGET_BINDS_LOCAL_P
1468 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1471 #undef TARGET_MS_BITFIELD_LAYOUT_P
1472 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1474 #undef TARGET_ASM_OUTPUT_MI_THUNK
1475 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1477 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1478 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1480 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1481 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1483 #undef TARGET_INVALID_WITHIN_DOLOOP
1484 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1486 #undef TARGET_RTX_COSTS
1487 #define TARGET_RTX_COSTS rs6000_rtx_costs
1488 #undef TARGET_ADDRESS_COST
1489 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1491 #undef TARGET_DWARF_REGISTER_SPAN
1492 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1494 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1495 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1497 /* On rs6000, function arguments are promoted, as are function return
1499 #undef TARGET_PROMOTE_FUNCTION_MODE
1500 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1502 #undef TARGET_RETURN_IN_MEMORY
1503 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1505 #undef TARGET_SETUP_INCOMING_VARARGS
1506 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1508 /* Always strict argument naming on rs6000. */
1509 #undef TARGET_STRICT_ARGUMENT_NAMING
1510 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1511 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1512 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1513 #undef TARGET_SPLIT_COMPLEX_ARG
1514 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1515 #undef TARGET_MUST_PASS_IN_STACK
1516 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1517 #undef TARGET_PASS_BY_REFERENCE
1518 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1519 #undef TARGET_ARG_PARTIAL_BYTES
1520 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1522 #undef TARGET_BUILD_BUILTIN_VA_LIST
1523 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1525 #undef TARGET_EXPAND_BUILTIN_VA_START
1526 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1528 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1529 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1531 #undef TARGET_EH_RETURN_FILTER_MODE
1532 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1534 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1535 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1537 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1538 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1540 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1541 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1543 #undef TARGET_HANDLE_OPTION
1544 #define TARGET_HANDLE_OPTION rs6000_handle_option
1546 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1547 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1548 rs6000_builtin_vectorized_function
1550 #undef TARGET_DEFAULT_TARGET_FLAGS
1551 #define TARGET_DEFAULT_TARGET_FLAGS \
1554 #undef TARGET_STACK_PROTECT_FAIL
1555 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1557 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1558 The PowerPC architecture requires only weak consistency among
1559 processors--that is, memory accesses between processors need not be
1560 sequentially consistent and memory accesses among processors can occur
1561 in any order. The ability to order memory accesses weakly provides
1562 opportunities for more efficient use of the system bus. Unless a
1563 dependency exists, the 604e allows read operations to precede store
1565 #undef TARGET_RELAXED_ORDERING
1566 #define TARGET_RELAXED_ORDERING true
1569 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1570 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1573 /* Use a 32-bit anchor range. This leads to sequences like:
1575 addis tmp,anchor,high
1578 where tmp itself acts as an anchor, and can be shared between
1579 accesses to the same 64k page. */
1580 #undef TARGET_MIN_ANCHOR_OFFSET
1581 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1582 #undef TARGET_MAX_ANCHOR_OFFSET
1583 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1584 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1585 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1587 #undef TARGET_BUILTIN_RECIPROCAL
1588 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1590 #undef TARGET_EXPAND_TO_RTL_HOOK
1591 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1593 #undef TARGET_INSTANTIATE_DECLS
1594 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1596 #undef TARGET_SECONDARY_RELOAD
1597 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1599 #undef TARGET_IRA_COVER_CLASSES
1600 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1602 #undef TARGET_LEGITIMATE_ADDRESS_P
1603 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1605 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
1606 #define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p
1608 #undef TARGET_CAN_ELIMINATE
1609 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1611 #undef TARGET_TRAMPOLINE_INIT
1612 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1614 #undef TARGET_FUNCTION_VALUE
1615 #define TARGET_FUNCTION_VALUE rs6000_function_value
1617 struct gcc_target targetm = TARGET_INITIALIZER;
1619 /* Return number of consecutive hard regs needed starting at reg REGNO
1620 to hold something of mode MODE.
1621 This is ordinarily the length in words of a value of mode MODE
1622 but can be less for certain modes in special long registers.
1624 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1625 scalar instructions. The upper 32 bits are only available to the
1628 POWER and PowerPC GPRs hold 32 bits worth;
1629 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1632 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1634 unsigned HOST_WIDE_INT reg_size;
1636 if (FP_REGNO_P (regno))
1637 reg_size = (VECTOR_MEM_VSX_P (mode)
1638 ? UNITS_PER_VSX_WORD
1639 : UNITS_PER_FP_WORD);
1641 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1642 reg_size = UNITS_PER_SPE_WORD;
1644 else if (ALTIVEC_REGNO_P (regno))
1645 reg_size = UNITS_PER_ALTIVEC_WORD;
1647 /* The value returned for SCmode in the E500 double case is 2 for
1648 ABI compatibility; storing an SCmode value in a single register
1649 would require function_arg and rs6000_spe_function_arg to handle
1650 SCmode so as to pass the value correctly in a pair of
1652 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1653 && !DECIMAL_FLOAT_MODE_P (mode))
1654 reg_size = UNITS_PER_FP_WORD;
1657 reg_size = UNITS_PER_WORD;
1659 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1662 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1665 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1667 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1669 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1670 implementations. Don't allow an item to be split between a FP register
1671 and an Altivec register. */
1672 if (VECTOR_MEM_VSX_P (mode))
1674 if (FP_REGNO_P (regno))
1675 return FP_REGNO_P (last_regno);
1677 if (ALTIVEC_REGNO_P (regno))
1678 return ALTIVEC_REGNO_P (last_regno);
1681 /* The GPRs can hold any mode, but values bigger than one register
1682 cannot go past R31. */
1683 if (INT_REGNO_P (regno))
1684 return INT_REGNO_P (last_regno);
1686 /* The float registers (except for VSX vector modes) can only hold floating
1687 modes and DImode. This excludes the 32-bit decimal float mode for
1689 if (FP_REGNO_P (regno))
1691 if (SCALAR_FLOAT_MODE_P (mode)
1692 && (mode != TDmode || (regno % 2) == 0)
1693 && FP_REGNO_P (last_regno))
1696 if (GET_MODE_CLASS (mode) == MODE_INT
1697 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1700 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1701 && PAIRED_VECTOR_MODE (mode))
1707 /* The CR register can only hold CC modes. */
1708 if (CR_REGNO_P (regno))
1709 return GET_MODE_CLASS (mode) == MODE_CC;
1711 if (CA_REGNO_P (regno))
1712 return mode == BImode;
1714 /* AltiVec only in AldyVec registers. */
1715 if (ALTIVEC_REGNO_P (regno))
1716 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1718 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1719 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1722 /* We cannot put TImode anywhere except general register and it must be able
1723 to fit within the register set. In the future, allow TImode in the
1724 Altivec or VSX registers. */
1726 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1729 /* Print interesting facts about registers. */
1731 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1735 for (r = first_regno; r <= last_regno; ++r)
1737 const char *comma = "";
1740 if (first_regno == last_regno)
1741 fprintf (stderr, "%s:\t", reg_name);
1743 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1746 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1747 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1751 fprintf (stderr, ",\n\t");
1756 if (rs6000_hard_regno_nregs[m][r] > 1)
1757 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1758 rs6000_hard_regno_nregs[m][r]);
1760 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1765 if (call_used_regs[r])
1769 fprintf (stderr, ",\n\t");
1774 len += fprintf (stderr, "%s%s", comma, "call-used");
1782 fprintf (stderr, ",\n\t");
1787 len += fprintf (stderr, "%s%s", comma, "fixed");
1793 fprintf (stderr, ",\n\t");
1797 fprintf (stderr, "%sregno = %d\n", comma, r);
1801 /* Print various interesting information with -mdebug=reg. */
1803 rs6000_debug_reg_global (void)
1805 const char *nl = (const char *)0;
1807 char costly_num[20];
1809 const char *costly_str;
1810 const char *nop_str;
1812 /* Map enum rs6000_vector to string. */
1813 static const char *rs6000_debug_vector_unit[] = {
1822 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
1823 LAST_VIRTUAL_REGISTER);
1824 rs6000_debug_reg_print (0, 31, "gr");
1825 rs6000_debug_reg_print (32, 63, "fp");
1826 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
1829 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
1830 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
1831 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
1832 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
1833 rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca");
1834 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
1835 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
1836 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
1837 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
1841 "d reg_class = %s\n"
1842 "f reg_class = %s\n"
1843 "v reg_class = %s\n"
1844 "wa reg_class = %s\n"
1845 "wd reg_class = %s\n"
1846 "wf reg_class = %s\n"
1847 "ws reg_class = %s\n\n",
1848 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
1849 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
1850 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
1851 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
1852 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
1853 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
1854 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
1856 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1857 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
1860 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
1862 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
1863 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
1869 if (rs6000_recip_control)
1871 fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control);
1873 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1874 if (rs6000_recip_bits[m])
1877 "Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n",
1879 (RS6000_RECIP_AUTO_RE_P (m)
1881 : (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")),
1882 (RS6000_RECIP_AUTO_RSQRTE_P (m)
1884 : (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none")));
1887 fputs ("\n", stderr);
1890 switch (rs6000_sched_costly_dep)
1892 case max_dep_latency:
1893 costly_str = "max_dep_latency";
1897 costly_str = "no_dep_costly";
1900 case all_deps_costly:
1901 costly_str = "all_deps_costly";
1904 case true_store_to_load_dep_costly:
1905 costly_str = "true_store_to_load_dep_costly";
1908 case store_to_load_dep_costly:
1909 costly_str = "store_to_load_dep_costly";
1913 costly_str = costly_num;
1914 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
1918 switch (rs6000_sched_insert_nops)
1920 case sched_finish_regroup_exact:
1921 nop_str = "sched_finish_regroup_exact";
1924 case sched_finish_pad_groups:
1925 nop_str = "sched_finish_pad_groups";
1928 case sched_finish_none:
1929 nop_str = "sched_finish_none";
1934 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
1939 "always_hint = %s\n"
1940 "align_branch_targets = %s\n"
1941 "sched_restricted_insns_priority = %d\n"
1942 "sched_costly_dep = %s\n"
1943 "sched_insert_nops = %s\n\n",
1944 rs6000_always_hint ? "true" : "false",
1945 rs6000_align_branch_targets ? "true" : "false",
1946 (int)rs6000_sched_restricted_insns_priority,
1947 costly_str, nop_str);
1950 /* Initialize the various global tables that are based on register size. */
1952 rs6000_init_hard_regno_mode_ok (void)
1958 /* Precalculate REGNO_REG_CLASS. */
1959 rs6000_regno_regclass[0] = GENERAL_REGS;
1960 for (r = 1; r < 32; ++r)
1961 rs6000_regno_regclass[r] = BASE_REGS;
1963 for (r = 32; r < 64; ++r)
1964 rs6000_regno_regclass[r] = FLOAT_REGS;
1966 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
1967 rs6000_regno_regclass[r] = NO_REGS;
1969 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
1970 rs6000_regno_regclass[r] = ALTIVEC_REGS;
1972 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
1973 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
1974 rs6000_regno_regclass[r] = CR_REGS;
1976 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
1977 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
1978 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
1979 rs6000_regno_regclass[CA_REGNO] = CA_REGS;
1980 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
1981 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
1982 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
1983 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
1984 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
1985 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
1987 /* Precalculate vector information, this must be set up before the
1988 rs6000_hard_regno_nregs_internal below. */
1989 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1991 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
1992 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
1993 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
1996 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
1997 rs6000_constraints[c] = NO_REGS;
1999 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
2000 believes it can use native alignment or still uses 128-bit alignment. */
2001 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
2012 /* V2DF mode, VSX only. */
2015 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
2016 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
2017 rs6000_vector_align[V2DFmode] = align64;
2020 /* V4SF mode, either VSX or Altivec. */
2023 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
2024 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
2025 rs6000_vector_align[V4SFmode] = align32;
2027 else if (TARGET_ALTIVEC)
2029 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
2030 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
2031 rs6000_vector_align[V4SFmode] = align32;
2034 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
2038 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
2039 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
2040 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
2041 rs6000_vector_align[V4SImode] = align32;
2042 rs6000_vector_align[V8HImode] = align32;
2043 rs6000_vector_align[V16QImode] = align32;
2047 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
2048 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
2049 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
2053 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
2054 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
2055 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
2059 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
2060 Altivec doesn't have 64-bit support. */
2063 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
2064 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
2065 rs6000_vector_align[V2DImode] = align64;
2068 /* DFmode, see if we want to use the VSX unit. */
2069 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
2071 rs6000_vector_unit[DFmode] = VECTOR_VSX;
2072 rs6000_vector_mem[DFmode]
2073 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
2074 rs6000_vector_align[DFmode] = align64;
2077 /* TODO add SPE and paired floating point vector support. */
2079 /* Register class constaints for the constraints that depend on compile
2081 if (TARGET_HARD_FLOAT && TARGET_FPRS)
2082 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2084 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2085 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2089 /* At present, we just use VSX_REGS, but we have different constraints
2090 based on the use, in case we want to fine tune the default register
2091 class used. wa = any VSX register, wf = register class to use for
2092 V4SF, wd = register class to use for V2DF, and ws = register classs to
2093 use for DF scalars. */
2094 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2095 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2096 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2097 rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
2103 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2105 /* Set up the reload helper functions. */
2106 if (TARGET_VSX || TARGET_ALTIVEC)
2110 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2111 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2112 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2113 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2114 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2115 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2116 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2117 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2118 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2119 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2120 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2121 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2125 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2126 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2127 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2128 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2129 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2130 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2131 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2132 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2133 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2134 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2135 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2136 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2140 /* Precalculate HARD_REGNO_NREGS. */
2141 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2142 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2143 rs6000_hard_regno_nregs[m][r]
2144 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2146 /* Precalculate HARD_REGNO_MODE_OK. */
2147 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2148 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2149 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2150 rs6000_hard_regno_mode_ok_p[m][r] = true;
2152 /* Precalculate CLASS_MAX_NREGS sizes. */
2153 for (c = 0; c < LIM_REG_CLASSES; ++c)
2157 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2158 reg_size = UNITS_PER_VSX_WORD;
2160 else if (c == ALTIVEC_REGS)
2161 reg_size = UNITS_PER_ALTIVEC_WORD;
2163 else if (c == FLOAT_REGS)
2164 reg_size = UNITS_PER_FP_WORD;
2167 reg_size = UNITS_PER_WORD;
2169 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2170 rs6000_class_max_nregs[m][c]
2171 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2174 if (TARGET_E500_DOUBLE)
2175 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2177 /* Calculate which modes to automatically generate code to use a the
2178 reciprocal divide and square root instructions. In the future, possibly
2179 automatically generate the instructions even if the user did not specify
2180 -mrecip. The older machines double precision reciprocal sqrt estimate is
2181 not accurate enough. */
2182 memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits));
2184 rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2186 rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2187 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2188 rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2189 if (VECTOR_UNIT_VSX_P (V2DFmode))
2190 rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2192 if (TARGET_FRSQRTES)
2193 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2195 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2196 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2197 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2198 if (VECTOR_UNIT_VSX_P (V2DFmode))
2199 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2201 if (rs6000_recip_control)
2203 if (!TARGET_FUSED_MADD)
2204 warning (0, "-mrecip requires -mfused-madd");
2205 if (!flag_finite_math_only)
2206 warning (0, "-mrecip requires -ffinite-math or -ffast-math");
2207 if (flag_trapping_math)
2208 warning (0, "-mrecip requires -fno-trapping-math or -ffast-math");
2209 if (!flag_reciprocal_math)
2210 warning (0, "-mrecip requires -freciprocal-math or -ffast-math");
2211 if (TARGET_FUSED_MADD && flag_finite_math_only && !flag_trapping_math
2212 && flag_reciprocal_math)
2214 if (RS6000_RECIP_HAVE_RE_P (SFmode)
2215 && (rs6000_recip_control & RECIP_SF_DIV) != 0)
2216 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2218 if (RS6000_RECIP_HAVE_RE_P (DFmode)
2219 && (rs6000_recip_control & RECIP_DF_DIV) != 0)
2220 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2222 if (RS6000_RECIP_HAVE_RE_P (V4SFmode)
2223 && (rs6000_recip_control & RECIP_V4SF_DIV) != 0)
2224 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2226 if (RS6000_RECIP_HAVE_RE_P (V2DFmode)
2227 && (rs6000_recip_control & RECIP_V2DF_DIV) != 0)
2228 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2230 if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode)
2231 && (rs6000_recip_control & RECIP_SF_RSQRT) != 0)
2232 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2234 if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode)
2235 && (rs6000_recip_control & RECIP_DF_RSQRT) != 0)
2236 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2238 if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode)
2239 && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0)
2240 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2242 if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode)
2243 && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0)
2244 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2248 if (TARGET_DEBUG_REG)
2249 rs6000_debug_reg_global ();
2251 if (TARGET_DEBUG_COST || TARGET_DEBUG_REG)
2253 "SImode variable mult cost = %d\n"
2254 "SImode constant mult cost = %d\n"
2255 "SImode short constant mult cost = %d\n"
2256 "DImode multipliciation cost = %d\n"
2257 "SImode division cost = %d\n"
2258 "DImode division cost = %d\n"
2259 "Simple fp operation cost = %d\n"
2260 "DFmode multiplication cost = %d\n"
2261 "SFmode division cost = %d\n"
2262 "DFmode division cost = %d\n"
2263 "cache line size = %d\n"
2264 "l1 cache size = %d\n"
2265 "l2 cache size = %d\n"
2266 "simultaneous prefetches = %d\n"
2269 rs6000_cost->mulsi_const,
2270 rs6000_cost->mulsi_const9,
2278 rs6000_cost->cache_line_size,
2279 rs6000_cost->l1_cache_size,
2280 rs6000_cost->l2_cache_size,
2281 rs6000_cost->simultaneous_prefetches);
2285 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2288 darwin_rs6000_override_options (void)
2290 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2292 rs6000_altivec_abi = 1;
2293 TARGET_ALTIVEC_VRSAVE = 1;
2294 if (DEFAULT_ABI == ABI_DARWIN)
2296 if (MACHO_DYNAMIC_NO_PIC_P)
2299 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
2302 else if (flag_pic == 1)
2307 if (TARGET_64BIT && ! TARGET_POWERPC64)
2309 target_flags |= MASK_POWERPC64;
2310 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2314 rs6000_default_long_calls = 1;
2315 target_flags |= MASK_SOFT_FLOAT;
2318 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2320 if (!flag_mkernel && !flag_apple_kext
2322 && ! (target_flags_explicit & MASK_ALTIVEC))
2323 target_flags |= MASK_ALTIVEC;
2325 /* Unless the user (not the configurer) has explicitly overridden
2326 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2327 G4 unless targetting the kernel. */
2330 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2331 && ! (target_flags_explicit & MASK_ALTIVEC)
2332 && ! rs6000_select[1].string)
2334 target_flags |= MASK_ALTIVEC;
2339 /* If not otherwise specified by a target, make 'long double' equivalent to
2342 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2343 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2346 /* Override command line options. Mostly we process the processor
2347 type and sometimes adjust other TARGET_ options. */
2350 rs6000_override_options (const char *default_cpu)
2353 struct rs6000_cpu_select *ptr;
2356 /* Simplifications for entries below. */
2359 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
2360 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
2363 /* This table occasionally claims that a processor does not support
2364 a particular feature even though it does, but the feature is slower
2365 than the alternative. Thus, it shouldn't be relied on as a
2366 complete description of the processor's support.
2368 Please keep this list in order, and don't forget to update the
2369 documentation in invoke.texi when adding a new processor or
2373 const char *const name; /* Canonical processor name. */
2374 const enum processor_type processor; /* Processor type enum value. */
2375 const int target_enable; /* Target flags to enable. */
2376 } const processor_target_table[]
2377 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2378 {"403", PROCESSOR_PPC403,
2379 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
2380 {"405", PROCESSOR_PPC405,
2381 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2382 {"405fp", PROCESSOR_PPC405,
2383 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2384 {"440", PROCESSOR_PPC440,
2385 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2386 {"440fp", PROCESSOR_PPC440,
2387 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2388 {"464", PROCESSOR_PPC440,
2389 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2390 {"464fp", PROCESSOR_PPC440,
2391 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2392 {"476", PROCESSOR_PPC476,
2393 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
2394 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2395 {"476fp", PROCESSOR_PPC476,
2396 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
2397 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2398 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
2399 {"601", PROCESSOR_PPC601,
2400 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
2401 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2402 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2403 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2404 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2405 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2406 {"620", PROCESSOR_PPC620,
2407 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2408 {"630", PROCESSOR_PPC630,
2409 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2410 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2411 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
2412 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2413 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2414 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2415 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2416 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2417 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2419 /* 8548 has a dummy entry for now. */
2420 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2422 {"a2", PROCESSOR_PPCA2,
2423 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
2424 | MASK_CMPB | MASK_NO_UPDATE },
2425 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2426 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
2427 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
2429 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
2430 | MASK_PPC_GFXOPT | MASK_ISEL},
2431 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2432 {"970", PROCESSOR_POWER4,
2433 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2434 {"cell", PROCESSOR_CELL,
2435 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2436 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
2437 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2438 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2439 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2440 {"G5", PROCESSOR_POWER4,
2441 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2442 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2443 {"power2", PROCESSOR_POWER,
2444 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2445 {"power3", PROCESSOR_PPC630,
2446 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2447 {"power4", PROCESSOR_POWER4,
2448 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2450 {"power5", PROCESSOR_POWER5,
2451 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2452 | MASK_MFCRF | MASK_POPCNTB},
2453 {"power5+", PROCESSOR_POWER5,
2454 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2455 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
2456 {"power6", PROCESSOR_POWER6,
2457 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2458 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2459 | MASK_RECIP_PRECISION},
2460 {"power6x", PROCESSOR_POWER6,
2461 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2462 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2463 | MASK_MFPGPR | MASK_RECIP_PRECISION},
2464 {"power7", PROCESSOR_POWER7,
2465 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
2466 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
2467 | MASK_VSX| MASK_RECIP_PRECISION}, /* Don't add MASK_ISEL by default */
2468 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
2469 {"powerpc64", PROCESSOR_POWERPC64,
2470 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2471 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2472 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2473 {"rios2", PROCESSOR_RIOS2,
2474 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2475 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2476 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2477 {"rs64", PROCESSOR_RS64A,
2478 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
2481 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
2483 /* Some OSs don't support saving the high part of 64-bit registers on
2484 context switch. Other OSs don't support saving Altivec registers.
2485 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
2486 settings; if the user wants either, the user must explicitly specify
2487 them and we won't interfere with the user's specification. */
2490 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
2491 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
2492 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
2493 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
2494 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
2495 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE
2496 | MASK_RECIP_PRECISION)
2499 /* Masks for instructions set at various powerpc ISAs. */
2501 ISA_2_1_MASKS = MASK_MFCRF,
2502 ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB | MASK_FPRND),
2504 /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and
2505 don't add ALTIVEC, since in general it isn't a win on power6. */
2506 ISA_2_5_MASKS = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION
2509 /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
2510 altivec is a win so enable it. */
2511 ISA_2_6_MASKS = (ISA_2_5_MASKS | MASK_ALTIVEC | MASK_POPCNTD
2512 | MASK_VSX | MASK_RECIP_PRECISION)
2515 /* Numerous experiment shows that IRA based loop pressure
2516 calculation works better for RTL loop invariant motion on targets
2517 with enough (>= 32) registers. It is an expensive optimization.
2518 So it is on only for peak performance. */
2520 flag_ira_loop_pressure = 1;
2522 /* Set the pointer size. */
2525 rs6000_pmode = (int)DImode;
2526 rs6000_pointer_size = 64;
2530 rs6000_pmode = (int)SImode;
2531 rs6000_pointer_size = 32;
2534 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2535 #ifdef OS_MISSING_POWERPC64
2536 if (OS_MISSING_POWERPC64)
2537 set_masks &= ~MASK_POWERPC64;
2539 #ifdef OS_MISSING_ALTIVEC
2540 if (OS_MISSING_ALTIVEC)
2541 set_masks &= ~MASK_ALTIVEC;
2544 /* Don't override by the processor default if given explicitly. */
2545 set_masks &= ~target_flags_explicit;
2547 /* Identify the processor type. */
2548 rs6000_select[0].string = default_cpu;
2549 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
2551 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2553 ptr = &rs6000_select[i];
2554 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2556 for (j = 0; j < ptt_size; j++)
2557 if (! strcmp (ptr->string, processor_target_table[j].name))
2559 if (ptr->set_tune_p)
2560 rs6000_cpu = processor_target_table[j].processor;
2562 if (ptr->set_arch_p)
2564 target_flags &= ~set_masks;
2565 target_flags |= (processor_target_table[j].target_enable
2572 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
2576 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2577 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2580 error ("AltiVec not supported in this target");
2582 error ("Spe not supported in this target");
2585 /* Disable Cell microcode if we are optimizing for the Cell
2586 and not optimizing for size. */
2587 if (rs6000_gen_cell_microcode == -1)
2588 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2591 /* If we are optimizing big endian systems for space and it's OK to
2592 use instructions that would be microcoded on the Cell, use the
2593 load/store multiple and string instructions. */
2594 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2595 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2597 /* Don't allow -mmultiple or -mstring on little endian systems
2598 unless the cpu is a 750, because the hardware doesn't support the
2599 instructions used in little endian mode, and causes an alignment
2600 trap. The 750 does not cause an alignment trap (except when the
2601 target is unaligned). */
2603 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2605 if (TARGET_MULTIPLE)
2607 target_flags &= ~MASK_MULTIPLE;
2608 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2609 warning (0, "-mmultiple is not supported on little endian systems");
2614 target_flags &= ~MASK_STRING;
2615 if ((target_flags_explicit & MASK_STRING) != 0)
2616 warning (0, "-mstring is not supported on little endian systems");
2620 /* Add some warnings for VSX. */
2623 const char *msg = NULL;
2624 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2625 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2627 if (target_flags_explicit & MASK_VSX)
2628 msg = N_("-mvsx requires hardware floating point");
2630 target_flags &= ~ MASK_VSX;
2632 else if (TARGET_PAIRED_FLOAT)
2633 msg = N_("-mvsx and -mpaired are incompatible");
2634 /* The hardware will allow VSX and little endian, but until we make sure
2635 things like vector select, etc. work don't allow VSX on little endian
2636 systems at this point. */
2637 else if (!BYTES_BIG_ENDIAN)
2638 msg = N_("-mvsx used with little endian code");
2639 else if (TARGET_AVOID_XFORM > 0)
2640 msg = N_("-mvsx needs indexed addressing");
2641 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2643 if (target_flags_explicit & MASK_VSX)
2644 msg = N_("-mvsx and -mno-altivec are incompatible");
2646 msg = N_("-mno-altivec disables vsx");
2652 target_flags &= ~ MASK_VSX;
2656 /* For the newer switches (vsx, dfp, etc.) set some of the older options,
2657 unless the user explicitly used the -mno-<option> to disable the code. */
2659 target_flags |= (ISA_2_6_MASKS & (target_flags_explicit & ~ISA_2_6_MASKS));
2660 else if (TARGET_DFP)
2661 target_flags |= (ISA_2_5_MASKS & (target_flags_explicit & ~ISA_2_5_MASKS));
2662 else if (TARGET_ALTIVEC)
2663 target_flags |= (MASK_PPC_GFXOPT & (target_flags_explicit & ~MASK_PPC_GFXOPT));
2665 /* Set debug flags */
2666 if (rs6000_debug_name)
2668 if (! strcmp (rs6000_debug_name, "all"))
2669 rs6000_debug_stack = rs6000_debug_arg = rs6000_debug_reg
2670 = rs6000_debug_addr = rs6000_debug_cost = 1;
2671 else if (! strcmp (rs6000_debug_name, "stack"))
2672 rs6000_debug_stack = 1;
2673 else if (! strcmp (rs6000_debug_name, "arg"))
2674 rs6000_debug_arg = 1;
2675 else if (! strcmp (rs6000_debug_name, "reg"))
2676 rs6000_debug_reg = 1;
2677 else if (! strcmp (rs6000_debug_name, "addr"))
2678 rs6000_debug_addr = 1;
2679 else if (! strcmp (rs6000_debug_name, "cost"))
2680 rs6000_debug_cost = 1;
2682 error ("unknown -mdebug-%s switch", rs6000_debug_name);
2684 /* If the appropriate debug option is enabled, replace the target hooks
2685 with debug versions that call the real version and then prints
2686 debugging information. */
2687 if (TARGET_DEBUG_COST)
2689 targetm.rtx_costs = rs6000_debug_rtx_costs;
2690 targetm.address_cost = rs6000_debug_address_cost;
2691 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2694 if (TARGET_DEBUG_ADDR)
2696 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2697 targetm.legitimize_address = rs6000_debug_legitimize_address;
2698 rs6000_secondary_reload_class_ptr
2699 = rs6000_debug_secondary_reload_class;
2700 rs6000_secondary_memory_needed_ptr
2701 = rs6000_debug_secondary_memory_needed;
2702 rs6000_cannot_change_mode_class_ptr
2703 = rs6000_debug_cannot_change_mode_class;
2704 rs6000_preferred_reload_class_ptr
2705 = rs6000_debug_preferred_reload_class;
2706 rs6000_legitimize_reload_address_ptr
2707 = rs6000_debug_legitimize_reload_address;
2708 rs6000_mode_dependent_address_ptr
2709 = rs6000_debug_mode_dependent_address;
2713 if (rs6000_traceback_name)
2715 if (! strncmp (rs6000_traceback_name, "full", 4))
2716 rs6000_traceback = traceback_full;
2717 else if (! strncmp (rs6000_traceback_name, "part", 4))
2718 rs6000_traceback = traceback_part;
2719 else if (! strncmp (rs6000_traceback_name, "no", 2))
2720 rs6000_traceback = traceback_none;
2722 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
2723 rs6000_traceback_name);
2726 if (!rs6000_explicit_options.long_double)
2727 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2729 #ifndef POWERPC_LINUX
2730 if (!rs6000_explicit_options.ieee)
2731 rs6000_ieeequad = 1;
2734 /* Enable Altivec ABI for AIX -maltivec. */
2735 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2736 rs6000_altivec_abi = 1;
2738 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2739 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2740 be explicitly overridden in either case. */
2743 if (!rs6000_explicit_options.altivec_abi
2744 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2745 rs6000_altivec_abi = 1;
2747 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2748 if (!rs6000_explicit_options.vrsave)
2749 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2752 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
2753 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2755 rs6000_darwin64_abi = 1;
2757 darwin_one_byte_bool = 1;
2759 /* Default to natural alignment, for better performance. */
2760 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2763 /* Place FP constants in the constant pool instead of TOC
2764 if section anchors enabled. */
2765 if (flag_section_anchors)
2766 TARGET_NO_FP_IN_TOC = 1;
2768 /* Handle -mtls-size option. */
2769 rs6000_parse_tls_size_option ();
2771 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2772 SUBTARGET_OVERRIDE_OPTIONS;
2774 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2775 SUBSUBTARGET_OVERRIDE_OPTIONS;
2777 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2778 SUB3TARGET_OVERRIDE_OPTIONS;
2781 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2782 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2784 /* The e500 and e500mc do not have string instructions, and we set
2785 MASK_STRING above when optimizing for size. */
2786 if ((target_flags & MASK_STRING) != 0)
2787 target_flags = target_flags & ~MASK_STRING;
2789 else if (rs6000_select[1].string != NULL)
2791 /* For the powerpc-eabispe configuration, we set all these by
2792 default, so let's unset them if we manually set another
2793 CPU that is not the E500. */
2794 if (!rs6000_explicit_options.spe_abi)
2796 if (!rs6000_explicit_options.spe)
2798 if (!rs6000_explicit_options.float_gprs)
2799 rs6000_float_gprs = 0;
2800 if (!(target_flags_explicit & MASK_ISEL))
2801 target_flags &= ~MASK_ISEL;
2804 /* Detect invalid option combinations with E500. */
2807 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
2808 && rs6000_cpu != PROCESSOR_POWER5
2809 && rs6000_cpu != PROCESSOR_POWER6
2810 && rs6000_cpu != PROCESSOR_POWER7
2811 && rs6000_cpu != PROCESSOR_PPCA2
2812 && rs6000_cpu != PROCESSOR_CELL);
2813 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
2814 || rs6000_cpu == PROCESSOR_POWER5
2815 || rs6000_cpu == PROCESSOR_POWER7);
2816 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
2817 || rs6000_cpu == PROCESSOR_POWER5
2818 || rs6000_cpu == PROCESSOR_POWER6
2819 || rs6000_cpu == PROCESSOR_POWER7
2820 || rs6000_cpu == PROCESSOR_PPCE500MC
2821 || rs6000_cpu == PROCESSOR_PPCE500MC64);
2823 /* Allow debug switches to override the above settings. */
2824 if (TARGET_ALWAYS_HINT > 0)
2825 rs6000_always_hint = TARGET_ALWAYS_HINT;
2827 if (TARGET_SCHED_GROUPS > 0)
2828 rs6000_sched_groups = TARGET_SCHED_GROUPS;
2830 if (TARGET_ALIGN_BRANCH_TARGETS > 0)
2831 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
2833 rs6000_sched_restricted_insns_priority
2834 = (rs6000_sched_groups ? 1 : 0);
2836 /* Handle -msched-costly-dep option. */
2837 rs6000_sched_costly_dep
2838 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
2840 if (rs6000_sched_costly_dep_str)
2842 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
2843 rs6000_sched_costly_dep = no_dep_costly;
2844 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
2845 rs6000_sched_costly_dep = all_deps_costly;
2846 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
2847 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
2848 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
2849 rs6000_sched_costly_dep = store_to_load_dep_costly;
2851 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
2852 atoi (rs6000_sched_costly_dep_str));
2855 /* Handle -minsert-sched-nops option. */
2856 rs6000_sched_insert_nops
2857 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
2859 if (rs6000_sched_insert_nops_str)
2861 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
2862 rs6000_sched_insert_nops = sched_finish_none;
2863 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
2864 rs6000_sched_insert_nops = sched_finish_pad_groups;
2865 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
2866 rs6000_sched_insert_nops = sched_finish_regroup_exact;
2868 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
2869 atoi (rs6000_sched_insert_nops_str));
2872 #ifdef TARGET_REGNAMES
2873 /* If the user desires alternate register names, copy in the
2874 alternate names now. */
2875 if (TARGET_REGNAMES)
2876 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
2879 /* Set aix_struct_return last, after the ABI is determined.
2880 If -maix-struct-return or -msvr4-struct-return was explicitly
2881 used, don't override with the ABI default. */
2882 if (!rs6000_explicit_options.aix_struct_ret)
2883 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
2885 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
2886 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
2889 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
2891 /* We can only guarantee the availability of DI pseudo-ops when
2892 assembling for 64-bit targets. */
2895 targetm.asm_out.aligned_op.di = NULL;
2896 targetm.asm_out.unaligned_op.di = NULL;
2899 /* Set branch target alignment, if not optimizing for size. */
2902 /* Cell wants to be aligned 8byte for dual issue. */
2903 if (rs6000_cpu == PROCESSOR_CELL)
2905 if (align_functions <= 0)
2906 align_functions = 8;
2907 if (align_jumps <= 0)
2909 if (align_loops <= 0)
2912 if (rs6000_align_branch_targets)
2914 if (align_functions <= 0)
2915 align_functions = 16;
2916 if (align_jumps <= 0)
2918 if (align_loops <= 0)
2921 if (align_jumps_max_skip <= 0)
2922 align_jumps_max_skip = 15;
2923 if (align_loops_max_skip <= 0)
2924 align_loops_max_skip = 15;
2927 /* Arrange to save and restore machine status around nested functions. */
2928 init_machine_status = rs6000_init_machine_status;
2930 /* We should always be splitting complex arguments, but we can't break
2931 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
2932 if (DEFAULT_ABI != ABI_AIX)
2933 targetm.calls.split_complex_arg = NULL;
2935 /* Initialize rs6000_cost with the appropriate target costs. */
2937 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
2941 case PROCESSOR_RIOS1:
2942 rs6000_cost = &rios1_cost;
2945 case PROCESSOR_RIOS2:
2946 rs6000_cost = &rios2_cost;
2949 case PROCESSOR_RS64A:
2950 rs6000_cost = &rs64a_cost;
2953 case PROCESSOR_MPCCORE:
2954 rs6000_cost = &mpccore_cost;
2957 case PROCESSOR_PPC403:
2958 rs6000_cost = &ppc403_cost;
2961 case PROCESSOR_PPC405:
2962 rs6000_cost = &ppc405_cost;
2965 case PROCESSOR_PPC440:
2966 rs6000_cost = &ppc440_cost;
2969 case PROCESSOR_PPC476:
2970 rs6000_cost = &ppc476_cost;
2973 case PROCESSOR_PPC601:
2974 rs6000_cost = &ppc601_cost;
2977 case PROCESSOR_PPC603:
2978 rs6000_cost = &ppc603_cost;
2981 case PROCESSOR_PPC604:
2982 rs6000_cost = &ppc604_cost;
2985 case PROCESSOR_PPC604e:
2986 rs6000_cost = &ppc604e_cost;
2989 case PROCESSOR_PPC620:
2990 rs6000_cost = &ppc620_cost;
2993 case PROCESSOR_PPC630:
2994 rs6000_cost = &ppc630_cost;
2997 case PROCESSOR_CELL:
2998 rs6000_cost = &ppccell_cost;
3001 case PROCESSOR_PPC750:
3002 case PROCESSOR_PPC7400:
3003 rs6000_cost = &ppc750_cost;
3006 case PROCESSOR_PPC7450:
3007 rs6000_cost = &ppc7450_cost;
3010 case PROCESSOR_PPC8540:
3011 rs6000_cost = &ppc8540_cost;
3014 case PROCESSOR_PPCE300C2:
3015 case PROCESSOR_PPCE300C3:
3016 rs6000_cost = &ppce300c2c3_cost;
3019 case PROCESSOR_PPCE500MC:
3020 rs6000_cost = &ppce500mc_cost;
3023 case PROCESSOR_PPCE500MC64:
3024 rs6000_cost = &ppce500mc64_cost;
3027 case PROCESSOR_POWER4:
3028 case PROCESSOR_POWER5:
3029 rs6000_cost = &power4_cost;
3032 case PROCESSOR_POWER6:
3033 rs6000_cost = &power6_cost;
3036 case PROCESSOR_POWER7:
3037 rs6000_cost = &power7_cost;
3040 case PROCESSOR_PPCA2:
3041 rs6000_cost = &ppca2_cost;
3048 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
3049 set_param_value ("simultaneous-prefetches",
3050 rs6000_cost->simultaneous_prefetches);
3051 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
3052 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
3053 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
3054 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
3055 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
3056 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
3058 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
3059 can be optimized to ap = __builtin_next_arg (0). */
3060 if (DEFAULT_ABI != ABI_V4)
3061 targetm.expand_builtin_va_start = NULL;
3063 /* Set up single/double float flags.
3064 If TARGET_HARD_FLOAT is set, but neither single or double is set,
3065 then set both flags. */
3066 if (TARGET_HARD_FLOAT && TARGET_FPRS
3067 && rs6000_single_float == 0 && rs6000_double_float == 0)
3068 rs6000_single_float = rs6000_double_float = 1;
3070 /* Reset single and double FP flags if target is E500. */
3073 rs6000_single_float = rs6000_double_float = 0;
3074 if (TARGET_E500_SINGLE)
3075 rs6000_single_float = 1;
3076 if (TARGET_E500_DOUBLE)
3077 rs6000_single_float = rs6000_double_float = 1;
3080 /* If not explicitly specified via option, decide whether to generate indexed
3081 load/store instructions. */
3082 if (TARGET_AVOID_XFORM == -1)
3083 /* Avoid indexed addressing when targeting Power6 in order to avoid
3084 the DERAT mispredict penalty. */
3085 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB);
3087 /* Set the -mrecip options. */
3088 if (rs6000_recip_name)
3090 char *p = ASTRDUP (rs6000_recip_name);
3092 unsigned int mask, i;
3095 while ((q = strtok (p, ",")) != NULL)
3106 if (!strcmp (q, "default"))
3107 mask = ((TARGET_RECIP_PRECISION)
3108 ? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION);
3111 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
3112 if (!strcmp (q, recip_options[i].string))
3114 mask = recip_options[i].mask;
3118 if (i == ARRAY_SIZE (recip_options))
3120 error ("Unknown option for -mrecip=%s", q);
3127 rs6000_recip_control &= ~mask;
3129 rs6000_recip_control |= mask;
3133 rs6000_init_hard_regno_mode_ok ();
3136 /* Implement targetm.vectorize.builtin_mask_for_load. */
3138 rs6000_builtin_mask_for_load (void)
3140 if (TARGET_ALTIVEC || TARGET_VSX)
3141 return altivec_builtin_mask_for_load;
3146 /* Implement targetm.vectorize.builtin_conversion.
3147 Returns a decl of a function that implements conversion of an integer vector
3148 into a floating-point vector, or vice-versa. DEST_TYPE is the
3149 destination type and SRC_TYPE the source type of the conversion.
3150 Return NULL_TREE if it is not available. */
3152 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
3154 enum tree_code code = (enum tree_code) tcode;
3158 case FIX_TRUNC_EXPR:
3159 switch (TYPE_MODE (dest_type))
3162 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3165 return TYPE_UNSIGNED (dest_type)
3166 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
3167 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
3170 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3173 return TYPE_UNSIGNED (dest_type)
3174 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
3175 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
3182 switch (TYPE_MODE (src_type))
3185 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3188 return TYPE_UNSIGNED (src_type)
3189 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
3190 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
3193 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3196 return TYPE_UNSIGNED (src_type)
3197 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
3198 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
3209 /* Implement targetm.vectorize.builtin_mul_widen_even. */
3211 rs6000_builtin_mul_widen_even (tree type)
3213 if (!TARGET_ALTIVEC)
3216 switch (TYPE_MODE (type))
3219 return TYPE_UNSIGNED (type)
3220 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
3221 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
3224 return TYPE_UNSIGNED (type)
3225 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
3226 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
3232 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
3234 rs6000_builtin_mul_widen_odd (tree type)
3236 if (!TARGET_ALTIVEC)
3239 switch (TYPE_MODE (type))
3242 return TYPE_UNSIGNED (type)
3243 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
3244 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
3247 return TYPE_UNSIGNED (type)
3248 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
3249 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
3256 /* Return true iff, data reference of TYPE can reach vector alignment (16)
3257 after applying N number of iterations. This routine does not determine
3258 how may iterations are required to reach desired alignment. */
3261 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3268 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3271 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3281 /* Assuming that all other types are naturally aligned. CHECKME! */
3286 /* Return true if the vector misalignment factor is supported by the
3289 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3296 /* Return if movmisalign pattern is not supported for this mode. */
3297 if (optab_handler (movmisalign_optab, mode)->insn_code ==
3301 if (misalignment == -1)
3303 /* misalignment factor is unknown at compile time but we know
3304 it's word aligned. */
3305 if (rs6000_vector_alignment_reachable (type, is_packed))
3309 /* VSX supports word-aligned vector. */
3310 if (misalignment % 4 == 0)
3316 /* Implement targetm.vectorize.builtin_vec_perm. */
3318 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
3320 tree inner_type = TREE_TYPE (type);
3321 bool uns_p = TYPE_UNSIGNED (inner_type);
3324 *mask_element_type = unsigned_char_type_node;
3326 switch (TYPE_MODE (type))
3330 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI_UNS]
3331 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI]);
3336 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI_UNS]
3337 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI]);
3342 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI_UNS]
3343 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI]);
3347 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
3351 if (!TARGET_ALLOW_DF_PERMUTE)
3354 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DF];
3358 if (!TARGET_ALLOW_DF_PERMUTE)
3362 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI_UNS]
3363 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI]);
3374 /* Handle generic options of the form -mfoo=yes/no.
3375 NAME is the option name.
3376 VALUE is the option value.