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, 2011
4 Free Software Foundation, Inc.
5 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 3, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
30 #include "insn-config.h"
31 #include "conditions.h"
32 #include "insn-attr.h"
42 #include "basic-block.h"
43 #include "integrate.h"
44 #include "diagnostic-core.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
55 #include "sched-int.h"
57 #include "tree-flow.h"
60 #include "tm-constrs.h"
62 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
65 #include "gstab.h" /* for N_SLINE */
68 #ifndef TARGET_NO_PROTOTYPE
69 #define TARGET_NO_PROTOTYPE 0
72 #define min(A,B) ((A) < (B) ? (A) : (B))
73 #define max(A,B) ((A) > (B) ? (A) : (B))
75 /* Structure used to define the rs6000 stack */
76 typedef struct rs6000_stack {
77 int reload_completed; /* stack info won't change from here on */
78 int first_gp_reg_save; /* first callee saved GP register used */
79 int first_fp_reg_save; /* first callee saved FP register used */
80 int first_altivec_reg_save; /* first callee saved AltiVec register used */
81 int lr_save_p; /* true if the link reg needs to be saved */
82 int cr_save_p; /* true if the CR reg needs to be saved */
83 unsigned int vrsave_mask; /* mask of vec registers to save */
84 int push_p; /* true if we need to allocate stack space */
85 int calls_p; /* true if the function makes any calls */
86 int world_save_p; /* true if we're saving *everything*:
87 r13-r31, cr, f14-f31, vrsave, v20-v31 */
88 enum rs6000_abi abi; /* which ABI to use */
89 int gp_save_offset; /* offset to save GP regs from initial SP */
90 int fp_save_offset; /* offset to save FP regs from initial SP */
91 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
92 int lr_save_offset; /* offset to save LR from initial SP */
93 int cr_save_offset; /* offset to save CR from initial SP */
94 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
95 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
96 int varargs_save_offset; /* offset to save the varargs registers */
97 int ehrd_offset; /* offset to EH return data */
98 int reg_size; /* register size (4 or 8) */
99 HOST_WIDE_INT vars_size; /* variable save area size */
100 int parm_size; /* outgoing parameter size */
101 int save_size; /* save area size */
102 int fixed_size; /* fixed size of stack frame */
103 int gp_size; /* size of saved GP registers */
104 int fp_size; /* size of saved FP registers */
105 int altivec_size; /* size of saved AltiVec registers */
106 int cr_size; /* size to hold CR if not in save_size */
107 int vrsave_size; /* size to hold VRSAVE if not in save_size */
108 int altivec_padding_size; /* size of altivec alignment padding if
110 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
111 int spe_padding_size;
112 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
113 int spe_64bit_regs_used;
117 /* A C structure for machine-specific, per-function data.
118 This is added to the cfun structure. */
119 typedef struct GTY(()) machine_function
121 /* Some local-dynamic symbol. */
122 const char *some_ld_name;
123 /* Whether the instruction chain has been scanned already. */
124 int insn_chain_scanned_p;
125 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
126 int ra_needs_full_frame;
127 /* Flags if __builtin_return_address (0) was used. */
129 /* Cache lr_save_p after expansion of builtin_eh_return. */
131 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
132 varargs save area. */
133 HOST_WIDE_INT varargs_save_offset;
134 /* Temporary stack slot to use for SDmode copies. This slot is
135 64-bits wide and is allocated early enough so that the offset
136 does not overflow the 16-bit load/store offset field. */
137 rtx sdmode_stack_slot;
140 /* Target cpu type */
142 struct rs6000_cpu_select rs6000_select[3] =
144 /* switch name, tune arch */
145 { (const char *)0, "--with-cpu=", 1, 1 },
146 { (const char *)0, "-mcpu=", 1, 1 },
147 { (const char *)0, "-mtune=", 1, 0 },
150 /* String variables to hold the various options. */
151 static const char *rs6000_sched_insert_nops_str;
152 static const char *rs6000_sched_costly_dep_str;
153 static const char *rs6000_recip_name;
156 static const char *rs6000_abi_name;
157 static const char *rs6000_sdata_name;
160 /* Support targetm.vectorize.builtin_mask_for_load. */
161 static GTY(()) tree altivec_builtin_mask_for_load;
163 /* Set to nonzero once AIX common-mode calls have been defined. */
164 static GTY(()) int common_mode_defined;
166 /* Label number of label created for -mrelocatable, to call to so we can
167 get the address of the GOT section */
168 static int rs6000_pic_labelno;
171 /* Counter for labels which are to be placed in .fixup. */
172 int fixuplabelno = 0;
175 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
178 /* Specify the machine mode that pointers have. After generation of rtl, the
179 compiler makes no further distinction between pointers and any other objects
180 of this machine mode. The type is unsigned since not all things that
181 include rs6000.h also include machmode.h. */
182 unsigned rs6000_pmode;
184 /* Width in bits of a pointer. */
185 unsigned rs6000_pointer_size;
188 /* Value is TRUE if register/mode pair is acceptable. */
189 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
191 /* Maximum number of registers needed for a given register class and mode. */
192 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
194 /* How many registers are needed for a given register and mode. */
195 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
197 /* Map register number to register class. */
198 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
200 /* Reload functions based on the type and the vector unit. */
201 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
203 /* Built in types. */
204 tree rs6000_builtin_types[RS6000_BTI_MAX];
205 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
207 /* Flag to say the TOC is initialized */
209 char toc_label_name[10];
211 /* Cached value of rs6000_variable_issue. This is cached in
212 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
213 static short cached_can_issue_more;
215 static GTY(()) section *read_only_data_section;
216 static GTY(()) section *private_data_section;
217 static GTY(()) section *read_only_private_data_section;
218 static GTY(()) section *sdata2_section;
219 static GTY(()) section *toc_section;
221 /* True for any options that were explicitly set. */
223 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
224 bool alignment; /* True if -malign- was used. */
225 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
226 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
227 bool spe; /* True if -mspe= was used. */
228 bool float_gprs; /* True if -mfloat-gprs= was used. */
229 bool long_double; /* True if -mlong-double- was used. */
230 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
231 bool vrsave; /* True if -mvrsave was used. */
232 bool cmodel; /* True if -mcmodel was used. */
233 } rs6000_explicit_options;
235 struct builtin_description
237 /* mask is not const because we're going to alter it below. This
238 nonsense will go away when we rewrite the -march infrastructure
239 to give us more target flag bits. */
241 const enum insn_code icode;
242 const char *const name;
243 const enum rs6000_builtins code;
246 /* Describe the vector unit used for modes. */
247 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
248 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
250 /* Register classes for various constraints that are based on the target
252 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
254 /* Describe the alignment of a vector. */
255 int rs6000_vector_align[NUM_MACHINE_MODES];
257 /* Map selected modes to types for builtins. */
258 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
260 /* What modes to automatically generate reciprocal divide estimate (fre) and
261 reciprocal sqrt (frsqrte) for. */
262 unsigned char rs6000_recip_bits[MAX_MACHINE_MODE];
264 /* Masks to determine which reciprocal esitmate instructions to generate
266 enum rs6000_recip_mask {
267 RECIP_SF_DIV = 0x001, /* Use divide estimate */
268 RECIP_DF_DIV = 0x002,
269 RECIP_V4SF_DIV = 0x004,
270 RECIP_V2DF_DIV = 0x008,
272 RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */
273 RECIP_DF_RSQRT = 0x020,
274 RECIP_V4SF_RSQRT = 0x040,
275 RECIP_V2DF_RSQRT = 0x080,
277 /* Various combination of flags for -mrecip=xxx. */
279 RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
280 | RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT
281 | RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT),
283 RECIP_HIGH_PRECISION = RECIP_ALL,
285 /* On low precision machines like the power5, don't enable double precision
286 reciprocal square root estimate, since it isn't accurate enough. */
287 RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT))
290 /* -mrecip options. */
293 const char *string; /* option name */
294 unsigned int mask; /* mask bits to set */
295 } recip_options[] = {
296 { "all", RECIP_ALL },
297 { "none", RECIP_NONE },
298 { "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
300 { "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) },
301 { "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) },
302 { "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT
303 | RECIP_V2DF_RSQRT) },
304 { "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) },
305 { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) },
308 /* 2 argument gen function typedef. */
309 typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx);
312 /* Target cpu costs. */
314 struct processor_costs {
315 const int mulsi; /* cost of SImode multiplication. */
316 const int mulsi_const; /* cost of SImode multiplication by constant. */
317 const int mulsi_const9; /* cost of SImode mult by short constant. */
318 const int muldi; /* cost of DImode multiplication. */
319 const int divsi; /* cost of SImode division. */
320 const int divdi; /* cost of DImode division. */
321 const int fp; /* cost of simple SFmode and DFmode insns. */
322 const int dmul; /* cost of DFmode multiplication (and fmadd). */
323 const int sdiv; /* cost of SFmode division (fdivs). */
324 const int ddiv; /* cost of DFmode division (fdiv). */
325 const int cache_line_size; /* cache line size in bytes. */
326 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
327 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
328 const int simultaneous_prefetches; /* number of parallel prefetch
332 const struct processor_costs *rs6000_cost;
334 /* Processor costs (relative to an add) */
336 /* Instruction size costs on 32bit processors. */
338 struct processor_costs size32_cost = {
339 COSTS_N_INSNS (1), /* mulsi */
340 COSTS_N_INSNS (1), /* mulsi_const */
341 COSTS_N_INSNS (1), /* mulsi_const9 */
342 COSTS_N_INSNS (1), /* muldi */
343 COSTS_N_INSNS (1), /* divsi */
344 COSTS_N_INSNS (1), /* divdi */
345 COSTS_N_INSNS (1), /* fp */
346 COSTS_N_INSNS (1), /* dmul */
347 COSTS_N_INSNS (1), /* sdiv */
348 COSTS_N_INSNS (1), /* ddiv */
355 /* Instruction size costs on 64bit processors. */
357 struct processor_costs size64_cost = {
358 COSTS_N_INSNS (1), /* mulsi */
359 COSTS_N_INSNS (1), /* mulsi_const */
360 COSTS_N_INSNS (1), /* mulsi_const9 */
361 COSTS_N_INSNS (1), /* muldi */
362 COSTS_N_INSNS (1), /* divsi */
363 COSTS_N_INSNS (1), /* divdi */
364 COSTS_N_INSNS (1), /* fp */
365 COSTS_N_INSNS (1), /* dmul */
366 COSTS_N_INSNS (1), /* sdiv */
367 COSTS_N_INSNS (1), /* ddiv */
374 /* Instruction costs on RIOS1 processors. */
376 struct processor_costs rios1_cost = {
377 COSTS_N_INSNS (5), /* mulsi */
378 COSTS_N_INSNS (4), /* mulsi_const */
379 COSTS_N_INSNS (3), /* mulsi_const9 */
380 COSTS_N_INSNS (5), /* muldi */
381 COSTS_N_INSNS (19), /* divsi */
382 COSTS_N_INSNS (19), /* divdi */
383 COSTS_N_INSNS (2), /* fp */
384 COSTS_N_INSNS (2), /* dmul */
385 COSTS_N_INSNS (19), /* sdiv */
386 COSTS_N_INSNS (19), /* ddiv */
387 128, /* cache line size */
393 /* Instruction costs on RIOS2 processors. */
395 struct processor_costs rios2_cost = {
396 COSTS_N_INSNS (2), /* mulsi */
397 COSTS_N_INSNS (2), /* mulsi_const */
398 COSTS_N_INSNS (2), /* mulsi_const9 */
399 COSTS_N_INSNS (2), /* muldi */
400 COSTS_N_INSNS (13), /* divsi */
401 COSTS_N_INSNS (13), /* divdi */
402 COSTS_N_INSNS (2), /* fp */
403 COSTS_N_INSNS (2), /* dmul */
404 COSTS_N_INSNS (17), /* sdiv */
405 COSTS_N_INSNS (17), /* ddiv */
406 256, /* cache line size */
412 /* Instruction costs on RS64A processors. */
414 struct processor_costs rs64a_cost = {
415 COSTS_N_INSNS (20), /* mulsi */
416 COSTS_N_INSNS (12), /* mulsi_const */
417 COSTS_N_INSNS (8), /* mulsi_const9 */
418 COSTS_N_INSNS (34), /* muldi */
419 COSTS_N_INSNS (65), /* divsi */
420 COSTS_N_INSNS (67), /* divdi */
421 COSTS_N_INSNS (4), /* fp */
422 COSTS_N_INSNS (4), /* dmul */
423 COSTS_N_INSNS (31), /* sdiv */
424 COSTS_N_INSNS (31), /* ddiv */
425 128, /* cache line size */
431 /* Instruction costs on MPCCORE processors. */
433 struct processor_costs mpccore_cost = {
434 COSTS_N_INSNS (2), /* mulsi */
435 COSTS_N_INSNS (2), /* mulsi_const */
436 COSTS_N_INSNS (2), /* mulsi_const9 */
437 COSTS_N_INSNS (2), /* muldi */
438 COSTS_N_INSNS (6), /* divsi */
439 COSTS_N_INSNS (6), /* divdi */
440 COSTS_N_INSNS (4), /* fp */
441 COSTS_N_INSNS (5), /* dmul */
442 COSTS_N_INSNS (10), /* sdiv */
443 COSTS_N_INSNS (17), /* ddiv */
444 32, /* cache line size */
450 /* Instruction costs on PPC403 processors. */
452 struct processor_costs ppc403_cost = {
453 COSTS_N_INSNS (4), /* mulsi */
454 COSTS_N_INSNS (4), /* mulsi_const */
455 COSTS_N_INSNS (4), /* mulsi_const9 */
456 COSTS_N_INSNS (4), /* muldi */
457 COSTS_N_INSNS (33), /* divsi */
458 COSTS_N_INSNS (33), /* divdi */
459 COSTS_N_INSNS (11), /* fp */
460 COSTS_N_INSNS (11), /* dmul */
461 COSTS_N_INSNS (11), /* sdiv */
462 COSTS_N_INSNS (11), /* ddiv */
463 32, /* cache line size */
469 /* Instruction costs on PPC405 processors. */
471 struct processor_costs ppc405_cost = {
472 COSTS_N_INSNS (5), /* mulsi */
473 COSTS_N_INSNS (4), /* mulsi_const */
474 COSTS_N_INSNS (3), /* mulsi_const9 */
475 COSTS_N_INSNS (5), /* muldi */
476 COSTS_N_INSNS (35), /* divsi */
477 COSTS_N_INSNS (35), /* divdi */
478 COSTS_N_INSNS (11), /* fp */
479 COSTS_N_INSNS (11), /* dmul */
480 COSTS_N_INSNS (11), /* sdiv */
481 COSTS_N_INSNS (11), /* ddiv */
482 32, /* cache line size */
488 /* Instruction costs on PPC440 processors. */
490 struct processor_costs ppc440_cost = {
491 COSTS_N_INSNS (3), /* mulsi */
492 COSTS_N_INSNS (2), /* mulsi_const */
493 COSTS_N_INSNS (2), /* mulsi_const9 */
494 COSTS_N_INSNS (3), /* muldi */
495 COSTS_N_INSNS (34), /* divsi */
496 COSTS_N_INSNS (34), /* divdi */
497 COSTS_N_INSNS (5), /* fp */
498 COSTS_N_INSNS (5), /* dmul */
499 COSTS_N_INSNS (19), /* sdiv */
500 COSTS_N_INSNS (33), /* ddiv */
501 32, /* cache line size */
507 /* Instruction costs on PPC476 processors. */
509 struct processor_costs ppc476_cost = {
510 COSTS_N_INSNS (4), /* mulsi */
511 COSTS_N_INSNS (4), /* mulsi_const */
512 COSTS_N_INSNS (4), /* mulsi_const9 */
513 COSTS_N_INSNS (4), /* muldi */
514 COSTS_N_INSNS (11), /* divsi */
515 COSTS_N_INSNS (11), /* divdi */
516 COSTS_N_INSNS (6), /* fp */
517 COSTS_N_INSNS (6), /* dmul */
518 COSTS_N_INSNS (19), /* sdiv */
519 COSTS_N_INSNS (33), /* ddiv */
520 32, /* l1 cache line size */
526 /* Instruction costs on PPC601 processors. */
528 struct processor_costs ppc601_cost = {
529 COSTS_N_INSNS (5), /* mulsi */
530 COSTS_N_INSNS (5), /* mulsi_const */
531 COSTS_N_INSNS (5), /* mulsi_const9 */
532 COSTS_N_INSNS (5), /* muldi */
533 COSTS_N_INSNS (36), /* divsi */
534 COSTS_N_INSNS (36), /* divdi */
535 COSTS_N_INSNS (4), /* fp */
536 COSTS_N_INSNS (5), /* dmul */
537 COSTS_N_INSNS (17), /* sdiv */
538 COSTS_N_INSNS (31), /* ddiv */
539 32, /* cache line size */
545 /* Instruction costs on PPC603 processors. */
547 struct processor_costs ppc603_cost = {
548 COSTS_N_INSNS (5), /* mulsi */
549 COSTS_N_INSNS (3), /* mulsi_const */
550 COSTS_N_INSNS (2), /* mulsi_const9 */
551 COSTS_N_INSNS (5), /* muldi */
552 COSTS_N_INSNS (37), /* divsi */
553 COSTS_N_INSNS (37), /* divdi */
554 COSTS_N_INSNS (3), /* fp */
555 COSTS_N_INSNS (4), /* dmul */
556 COSTS_N_INSNS (18), /* sdiv */
557 COSTS_N_INSNS (33), /* ddiv */
558 32, /* cache line size */
564 /* Instruction costs on PPC604 processors. */
566 struct processor_costs ppc604_cost = {
567 COSTS_N_INSNS (4), /* mulsi */
568 COSTS_N_INSNS (4), /* mulsi_const */
569 COSTS_N_INSNS (4), /* mulsi_const9 */
570 COSTS_N_INSNS (4), /* muldi */
571 COSTS_N_INSNS (20), /* divsi */
572 COSTS_N_INSNS (20), /* divdi */
573 COSTS_N_INSNS (3), /* fp */
574 COSTS_N_INSNS (3), /* dmul */
575 COSTS_N_INSNS (18), /* sdiv */
576 COSTS_N_INSNS (32), /* ddiv */
577 32, /* cache line size */
583 /* Instruction costs on PPC604e processors. */
585 struct processor_costs ppc604e_cost = {
586 COSTS_N_INSNS (2), /* mulsi */
587 COSTS_N_INSNS (2), /* mulsi_const */
588 COSTS_N_INSNS (2), /* mulsi_const9 */
589 COSTS_N_INSNS (2), /* muldi */
590 COSTS_N_INSNS (20), /* divsi */
591 COSTS_N_INSNS (20), /* divdi */
592 COSTS_N_INSNS (3), /* fp */
593 COSTS_N_INSNS (3), /* dmul */
594 COSTS_N_INSNS (18), /* sdiv */
595 COSTS_N_INSNS (32), /* ddiv */
596 32, /* cache line size */
602 /* Instruction costs on PPC620 processors. */
604 struct processor_costs ppc620_cost = {
605 COSTS_N_INSNS (5), /* mulsi */
606 COSTS_N_INSNS (4), /* mulsi_const */
607 COSTS_N_INSNS (3), /* mulsi_const9 */
608 COSTS_N_INSNS (7), /* muldi */
609 COSTS_N_INSNS (21), /* divsi */
610 COSTS_N_INSNS (37), /* divdi */
611 COSTS_N_INSNS (3), /* fp */
612 COSTS_N_INSNS (3), /* dmul */
613 COSTS_N_INSNS (18), /* sdiv */
614 COSTS_N_INSNS (32), /* ddiv */
615 128, /* cache line size */
621 /* Instruction costs on PPC630 processors. */
623 struct processor_costs ppc630_cost = {
624 COSTS_N_INSNS (5), /* mulsi */
625 COSTS_N_INSNS (4), /* mulsi_const */
626 COSTS_N_INSNS (3), /* mulsi_const9 */
627 COSTS_N_INSNS (7), /* muldi */
628 COSTS_N_INSNS (21), /* divsi */
629 COSTS_N_INSNS (37), /* divdi */
630 COSTS_N_INSNS (3), /* fp */
631 COSTS_N_INSNS (3), /* dmul */
632 COSTS_N_INSNS (17), /* sdiv */
633 COSTS_N_INSNS (21), /* ddiv */
634 128, /* cache line size */
640 /* Instruction costs on Cell processor. */
641 /* COSTS_N_INSNS (1) ~ one add. */
643 struct processor_costs ppccell_cost = {
644 COSTS_N_INSNS (9/2)+2, /* mulsi */
645 COSTS_N_INSNS (6/2), /* mulsi_const */
646 COSTS_N_INSNS (6/2), /* mulsi_const9 */
647 COSTS_N_INSNS (15/2)+2, /* muldi */
648 COSTS_N_INSNS (38/2), /* divsi */
649 COSTS_N_INSNS (70/2), /* divdi */
650 COSTS_N_INSNS (10/2), /* fp */
651 COSTS_N_INSNS (10/2), /* dmul */
652 COSTS_N_INSNS (74/2), /* sdiv */
653 COSTS_N_INSNS (74/2), /* ddiv */
654 128, /* cache line size */
660 /* Instruction costs on PPC750 and PPC7400 processors. */
662 struct processor_costs ppc750_cost = {
663 COSTS_N_INSNS (5), /* mulsi */
664 COSTS_N_INSNS (3), /* mulsi_const */
665 COSTS_N_INSNS (2), /* mulsi_const9 */
666 COSTS_N_INSNS (5), /* muldi */
667 COSTS_N_INSNS (17), /* divsi */
668 COSTS_N_INSNS (17), /* divdi */
669 COSTS_N_INSNS (3), /* fp */
670 COSTS_N_INSNS (3), /* dmul */
671 COSTS_N_INSNS (17), /* sdiv */
672 COSTS_N_INSNS (31), /* ddiv */
673 32, /* cache line size */
679 /* Instruction costs on PPC7450 processors. */
681 struct processor_costs ppc7450_cost = {
682 COSTS_N_INSNS (4), /* mulsi */
683 COSTS_N_INSNS (3), /* mulsi_const */
684 COSTS_N_INSNS (3), /* mulsi_const9 */
685 COSTS_N_INSNS (4), /* muldi */
686 COSTS_N_INSNS (23), /* divsi */
687 COSTS_N_INSNS (23), /* divdi */
688 COSTS_N_INSNS (5), /* fp */
689 COSTS_N_INSNS (5), /* dmul */
690 COSTS_N_INSNS (21), /* sdiv */
691 COSTS_N_INSNS (35), /* ddiv */
692 32, /* cache line size */
698 /* Instruction costs on PPC8540 processors. */
700 struct processor_costs ppc8540_cost = {
701 COSTS_N_INSNS (4), /* mulsi */
702 COSTS_N_INSNS (4), /* mulsi_const */
703 COSTS_N_INSNS (4), /* mulsi_const9 */
704 COSTS_N_INSNS (4), /* muldi */
705 COSTS_N_INSNS (19), /* divsi */
706 COSTS_N_INSNS (19), /* divdi */
707 COSTS_N_INSNS (4), /* fp */
708 COSTS_N_INSNS (4), /* dmul */
709 COSTS_N_INSNS (29), /* sdiv */
710 COSTS_N_INSNS (29), /* ddiv */
711 32, /* cache line size */
714 1, /* prefetch streams /*/
717 /* Instruction costs on E300C2 and E300C3 cores. */
719 struct processor_costs ppce300c2c3_cost = {
720 COSTS_N_INSNS (4), /* mulsi */
721 COSTS_N_INSNS (4), /* mulsi_const */
722 COSTS_N_INSNS (4), /* mulsi_const9 */
723 COSTS_N_INSNS (4), /* muldi */
724 COSTS_N_INSNS (19), /* divsi */
725 COSTS_N_INSNS (19), /* divdi */
726 COSTS_N_INSNS (3), /* fp */
727 COSTS_N_INSNS (4), /* dmul */
728 COSTS_N_INSNS (18), /* sdiv */
729 COSTS_N_INSNS (33), /* ddiv */
733 1, /* prefetch streams /*/
736 /* Instruction costs on PPCE500MC processors. */
738 struct processor_costs ppce500mc_cost = {
739 COSTS_N_INSNS (4), /* mulsi */
740 COSTS_N_INSNS (4), /* mulsi_const */
741 COSTS_N_INSNS (4), /* mulsi_const9 */
742 COSTS_N_INSNS (4), /* muldi */
743 COSTS_N_INSNS (14), /* divsi */
744 COSTS_N_INSNS (14), /* divdi */
745 COSTS_N_INSNS (8), /* fp */
746 COSTS_N_INSNS (10), /* dmul */
747 COSTS_N_INSNS (36), /* sdiv */
748 COSTS_N_INSNS (66), /* ddiv */
749 64, /* cache line size */
752 1, /* prefetch streams /*/
755 /* Instruction costs on PPCE500MC64 processors. */
757 struct processor_costs ppce500mc64_cost = {
758 COSTS_N_INSNS (4), /* mulsi */
759 COSTS_N_INSNS (4), /* mulsi_const */
760 COSTS_N_INSNS (4), /* mulsi_const9 */
761 COSTS_N_INSNS (4), /* muldi */
762 COSTS_N_INSNS (14), /* divsi */
763 COSTS_N_INSNS (14), /* divdi */
764 COSTS_N_INSNS (4), /* fp */
765 COSTS_N_INSNS (10), /* dmul */
766 COSTS_N_INSNS (36), /* sdiv */
767 COSTS_N_INSNS (66), /* ddiv */
768 64, /* cache line size */
771 1, /* prefetch streams /*/
774 /* Instruction costs on AppliedMicro Titan processors. */
776 struct processor_costs titan_cost = {
777 COSTS_N_INSNS (5), /* mulsi */
778 COSTS_N_INSNS (5), /* mulsi_const */
779 COSTS_N_INSNS (5), /* mulsi_const9 */
780 COSTS_N_INSNS (5), /* muldi */
781 COSTS_N_INSNS (18), /* divsi */
782 COSTS_N_INSNS (18), /* divdi */
783 COSTS_N_INSNS (10), /* fp */
784 COSTS_N_INSNS (10), /* dmul */
785 COSTS_N_INSNS (46), /* sdiv */
786 COSTS_N_INSNS (72), /* ddiv */
787 32, /* cache line size */
790 1, /* prefetch streams /*/
793 /* Instruction costs on POWER4 and POWER5 processors. */
795 struct processor_costs power4_cost = {
796 COSTS_N_INSNS (3), /* mulsi */
797 COSTS_N_INSNS (2), /* mulsi_const */
798 COSTS_N_INSNS (2), /* mulsi_const9 */
799 COSTS_N_INSNS (4), /* muldi */
800 COSTS_N_INSNS (18), /* divsi */
801 COSTS_N_INSNS (34), /* divdi */
802 COSTS_N_INSNS (3), /* fp */
803 COSTS_N_INSNS (3), /* dmul */
804 COSTS_N_INSNS (17), /* sdiv */
805 COSTS_N_INSNS (17), /* ddiv */
806 128, /* cache line size */
809 8, /* prefetch streams /*/
812 /* Instruction costs on POWER6 processors. */
814 struct processor_costs power6_cost = {
815 COSTS_N_INSNS (8), /* mulsi */
816 COSTS_N_INSNS (8), /* mulsi_const */
817 COSTS_N_INSNS (8), /* mulsi_const9 */
818 COSTS_N_INSNS (8), /* muldi */
819 COSTS_N_INSNS (22), /* divsi */
820 COSTS_N_INSNS (28), /* divdi */
821 COSTS_N_INSNS (3), /* fp */
822 COSTS_N_INSNS (3), /* dmul */
823 COSTS_N_INSNS (13), /* sdiv */
824 COSTS_N_INSNS (16), /* ddiv */
825 128, /* cache line size */
828 16, /* prefetch streams */
831 /* Instruction costs on POWER7 processors. */
833 struct processor_costs power7_cost = {
834 COSTS_N_INSNS (2), /* mulsi */
835 COSTS_N_INSNS (2), /* mulsi_const */
836 COSTS_N_INSNS (2), /* mulsi_const9 */
837 COSTS_N_INSNS (2), /* muldi */
838 COSTS_N_INSNS (18), /* divsi */
839 COSTS_N_INSNS (34), /* divdi */
840 COSTS_N_INSNS (3), /* fp */
841 COSTS_N_INSNS (3), /* dmul */
842 COSTS_N_INSNS (13), /* sdiv */
843 COSTS_N_INSNS (16), /* ddiv */
844 128, /* cache line size */
847 12, /* prefetch streams */
850 /* Instruction costs on POWER A2 processors. */
852 struct processor_costs ppca2_cost = {
853 COSTS_N_INSNS (16), /* mulsi */
854 COSTS_N_INSNS (16), /* mulsi_const */
855 COSTS_N_INSNS (16), /* mulsi_const9 */
856 COSTS_N_INSNS (16), /* muldi */
857 COSTS_N_INSNS (22), /* divsi */
858 COSTS_N_INSNS (28), /* divdi */
859 COSTS_N_INSNS (3), /* fp */
860 COSTS_N_INSNS (3), /* dmul */
861 COSTS_N_INSNS (59), /* sdiv */
862 COSTS_N_INSNS (72), /* ddiv */
866 16, /* prefetch streams */
870 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
871 #undef RS6000_BUILTIN
872 #undef RS6000_BUILTIN_EQUATE
873 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
874 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
876 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
878 #include "rs6000-builtin.def"
881 #undef RS6000_BUILTIN
882 #undef RS6000_BUILTIN_EQUATE
884 /* Support for -mveclibabi=<xxx> to control which vector library to use. */
885 static tree (*rs6000_veclib_handler) (tree, tree, tree);
888 static bool rs6000_function_ok_for_sibcall (tree, tree);
889 static const char *rs6000_invalid_within_doloop (const_rtx);
890 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
891 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
892 static rtx rs6000_generate_compare (rtx, enum machine_mode);
893 static void rs6000_emit_stack_tie (void);
894 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
895 static bool spe_func_has_64bit_regs_p (void);
896 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
898 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
899 static unsigned rs6000_hash_constant (rtx);
900 static unsigned toc_hash_function (const void *);
901 static int toc_hash_eq (const void *, const void *);
902 static bool reg_offset_addressing_ok_p (enum machine_mode);
903 static bool virtual_stack_registers_memory_p (rtx);
904 static bool constant_pool_expr_p (rtx);
905 static bool legitimate_small_data_p (enum machine_mode, rtx);
906 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
907 static struct machine_function * rs6000_init_machine_status (void);
908 static bool rs6000_assemble_integer (rtx, unsigned int, int);
909 static bool no_global_regs_above (int, bool);
910 #ifdef HAVE_GAS_HIDDEN
911 static void rs6000_assemble_visibility (tree, int);
913 static int rs6000_ra_ever_killed (void);
914 static bool rs6000_attribute_takes_identifier_p (const_tree);
915 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
916 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
917 static bool rs6000_ms_bitfield_layout_p (const_tree);
918 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
919 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
920 static const char *rs6000_mangle_type (const_tree);
921 static void rs6000_set_default_type_attributes (tree);
922 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
923 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
924 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
925 enum machine_mode, bool, bool, bool);
926 static bool rs6000_reg_live_or_pic_offset_p (int);
927 static tree rs6000_builtin_vectorized_libmass (tree, tree, tree);
928 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
929 static void rs6000_restore_saved_cr (rtx, int);
930 static bool rs6000_output_addr_const_extra (FILE *, rtx);
931 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
932 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
933 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
935 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
936 static bool rs6000_return_in_memory (const_tree, const_tree);
937 static rtx rs6000_function_value (const_tree, const_tree, bool);
938 static void rs6000_file_start (void);
940 static int rs6000_elf_reloc_rw_mask (void);
941 static void rs6000_elf_asm_out_constructor (rtx, int) ATTRIBUTE_UNUSED;
942 static void rs6000_elf_asm_out_destructor (rtx, int) ATTRIBUTE_UNUSED;
943 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
944 static void rs6000_elf_asm_init_sections (void);
945 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
946 unsigned HOST_WIDE_INT);
947 static void rs6000_elf_encode_section_info (tree, rtx, int)
950 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
951 static void rs6000_alloc_sdmode_stack_slot (void);
952 static void rs6000_instantiate_decls (void);
954 static void rs6000_xcoff_asm_output_anchor (rtx);
955 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
956 static void rs6000_xcoff_asm_init_sections (void);
957 static int rs6000_xcoff_reloc_rw_mask (void);
958 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
959 static section *rs6000_xcoff_select_section (tree, int,
960 unsigned HOST_WIDE_INT);
961 static void rs6000_xcoff_unique_section (tree, int);
962 static section *rs6000_xcoff_select_rtx_section
963 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
964 static const char * rs6000_xcoff_strip_name_encoding (const char *);
965 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
966 static void rs6000_xcoff_file_start (void);
967 static void rs6000_xcoff_file_end (void);
969 static int rs6000_variable_issue (FILE *, int, rtx, int);
970 static int rs6000_register_move_cost (enum machine_mode,
971 reg_class_t, reg_class_t);
972 static int rs6000_memory_move_cost (enum machine_mode, reg_class_t, bool);
973 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
974 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
975 static int rs6000_debug_address_cost (rtx, bool);
976 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
977 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
978 static void rs6000_sched_init (FILE *, int, int);
979 static bool is_microcoded_insn (rtx);
980 static bool is_nonpipeline_insn (rtx);
981 static bool is_cracked_insn (rtx);
982 static bool is_branch_slot_insn (rtx);
983 static bool is_load_insn (rtx);
984 static rtx get_store_dest (rtx pat);
985 static bool is_store_insn (rtx);
986 static bool set_to_load_agen (rtx,rtx);
987 static bool adjacent_mem_locations (rtx,rtx);
988 static int rs6000_adjust_priority (rtx, int);
989 static int rs6000_issue_rate (void);
990 static bool rs6000_is_costly_dependence (dep_t, int, int);
991 static rtx get_next_active_insn (rtx, rtx);
992 static bool insn_terminates_group_p (rtx , enum group_termination);
993 static bool insn_must_be_first_in_group (rtx);
994 static bool insn_must_be_last_in_group (rtx);
995 static bool is_costly_group (rtx *, rtx);
996 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
997 static int redefine_groups (FILE *, int, rtx, rtx);
998 static int pad_groups (FILE *, int, rtx, rtx);
999 static void rs6000_sched_finish (FILE *, int);
1000 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
1001 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
1002 static int rs6000_use_sched_lookahead (void);
1003 static int rs6000_use_sched_lookahead_guard (rtx);
1004 static void * rs6000_alloc_sched_context (void);
1005 static void rs6000_init_sched_context (void *, bool);
1006 static void rs6000_set_sched_context (void *);
1007 static void rs6000_free_sched_context (void *);
1008 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
1009 static tree rs6000_builtin_mask_for_load (void);
1010 static tree rs6000_builtin_mul_widen_even (tree);
1011 static tree rs6000_builtin_mul_widen_odd (tree);
1012 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
1013 static tree rs6000_builtin_vec_perm (tree, tree *);
1014 static bool rs6000_builtin_support_vector_misalignment (enum
1018 static int rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt,
1020 static enum machine_mode rs6000_preferred_simd_mode (enum machine_mode);
1022 static void def_builtin (int, const char *, tree, int);
1023 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1024 static void rs6000_init_builtins (void);
1025 static tree rs6000_builtin_decl (unsigned, bool);
1027 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1028 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1029 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1030 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1031 static void altivec_init_builtins (void);
1032 static unsigned builtin_hash_function (const void *);
1033 static int builtin_hash_eq (const void *, const void *);
1034 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1035 enum machine_mode, enum machine_mode,
1036 enum rs6000_builtins, const char *name);
1037 static void rs6000_common_init_builtins (void);
1038 static void rs6000_init_libfuncs (void);
1040 static void paired_init_builtins (void);
1041 static rtx paired_expand_builtin (tree, rtx, bool *);
1042 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1043 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1044 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1046 static void enable_mask_for_builtins (struct builtin_description *, int,
1047 enum rs6000_builtins,
1048 enum rs6000_builtins);
1049 static void spe_init_builtins (void);
1050 static rtx spe_expand_builtin (tree, rtx, bool *);
1051 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1052 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1053 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1054 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1055 static rs6000_stack_t *rs6000_stack_info (void);
1056 static void debug_stack_info (rs6000_stack_t *);
1058 static rtx altivec_expand_builtin (tree, rtx, bool *);
1059 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1060 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1061 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1062 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1063 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1064 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1065 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1066 static rtx altivec_expand_vec_set_builtin (tree);
1067 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1068 static int get_element_number (tree, tree);
1069 static void rs6000_option_override (void);
1070 static void rs6000_option_init_struct (struct gcc_options *);
1071 static void rs6000_option_default_params (void);
1072 static bool rs6000_handle_option (size_t, const char *, int);
1073 static int rs6000_loop_align_max_skip (rtx);
1074 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1075 static int first_altivec_reg_to_save (void);
1076 static unsigned int compute_vrsave_mask (void);
1077 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1078 static void is_altivec_return_reg (rtx, void *);
1079 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1080 int easy_vector_constant (rtx, enum machine_mode);
1081 static rtx rs6000_dwarf_register_span (rtx);
1082 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1083 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1084 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1085 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1086 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1087 static rtx rs6000_delegitimize_address (rtx);
1088 static rtx rs6000_tls_get_addr (void);
1089 static rtx rs6000_got_sym (void);
1090 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1091 static const char *rs6000_get_some_local_dynamic_name (void);
1092 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1093 static rtx rs6000_complex_function_value (enum machine_mode);
1094 static rtx rs6000_spe_function_arg (const CUMULATIVE_ARGS *,
1095 enum machine_mode, const_tree);
1096 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1097 HOST_WIDE_INT, int);
1098 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1101 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1104 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1105 const_tree, HOST_WIDE_INT,
1107 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, bool, bool);
1108 static rtx rs6000_mixed_function_arg (enum machine_mode, const_tree, int);
1109 static void rs6000_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
1111 static rtx rs6000_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
1113 static unsigned int rs6000_function_arg_boundary (enum machine_mode,
1115 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1116 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1117 enum machine_mode, tree,
1119 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1121 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1123 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1125 static void macho_branch_islands (void);
1126 static int no_previous_def (tree function_name);
1127 static tree get_prev_label (tree function_name);
1128 static void rs6000_darwin_file_start (void);
1131 static tree rs6000_build_builtin_va_list (void);
1132 static void rs6000_va_start (tree, rtx);
1133 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1134 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1135 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1136 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1137 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1138 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1140 static tree rs6000_stack_protect_fail (void);
1142 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1145 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1148 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1150 = rs6000_legitimize_reload_address;
1152 static bool rs6000_mode_dependent_address_p (const_rtx);
1153 static bool rs6000_mode_dependent_address (const_rtx);
1154 static bool rs6000_debug_mode_dependent_address (const_rtx);
1155 static bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1156 = rs6000_mode_dependent_address;
1158 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1159 enum machine_mode, rtx);
1160 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1163 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1164 enum machine_mode, rtx)
1165 = rs6000_secondary_reload_class;
1167 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1168 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1170 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1171 = rs6000_preferred_reload_class;
1173 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1176 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1180 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1182 = rs6000_secondary_memory_needed;
1184 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1187 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1191 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1194 = rs6000_cannot_change_mode_class;
1196 static reg_class_t rs6000_secondary_reload (bool, rtx, reg_class_t,
1198 struct secondary_reload_info *);
1200 static const reg_class_t *rs6000_ira_cover_classes (void);
1202 const int INSN_NOT_AVAILABLE = -1;
1203 static enum machine_mode rs6000_eh_return_filter_mode (void);
1204 static bool rs6000_can_eliminate (const int, const int);
1205 static void rs6000_conditional_register_usage (void);
1206 static void rs6000_trampoline_init (rtx, tree, rtx);
1208 /* Hash table stuff for keeping track of TOC entries. */
1210 struct GTY(()) toc_hash_struct
1212 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1213 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1215 enum machine_mode key_mode;
1219 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1221 /* Hash table to keep track of the argument types for builtin functions. */
1223 struct GTY(()) builtin_hash_struct
1226 enum machine_mode mode[4]; /* return value + 3 arguments. */
1227 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1230 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1232 static bool rs6000_valid_attribute_p (tree, tree, tree, int);
1233 static void rs6000_function_specific_save (struct cl_target_option *);
1234 static void rs6000_function_specific_restore (struct cl_target_option *);
1235 static void rs6000_function_specific_print (FILE *, int,
1236 struct cl_target_option *);
1237 static bool rs6000_can_inline_p (tree, tree);
1238 static void rs6000_set_current_function (tree);
1241 /* Default register names. */
1242 char rs6000_reg_names[][8] =
1244 "0", "1", "2", "3", "4", "5", "6", "7",
1245 "8", "9", "10", "11", "12", "13", "14", "15",
1246 "16", "17", "18", "19", "20", "21", "22", "23",
1247 "24", "25", "26", "27", "28", "29", "30", "31",
1248 "0", "1", "2", "3", "4", "5", "6", "7",
1249 "8", "9", "10", "11", "12", "13", "14", "15",
1250 "16", "17", "18", "19", "20", "21", "22", "23",
1251 "24", "25", "26", "27", "28", "29", "30", "31",
1252 "mq", "lr", "ctr","ap",
1253 "0", "1", "2", "3", "4", "5", "6", "7",
1255 /* AltiVec registers. */
1256 "0", "1", "2", "3", "4", "5", "6", "7",
1257 "8", "9", "10", "11", "12", "13", "14", "15",
1258 "16", "17", "18", "19", "20", "21", "22", "23",
1259 "24", "25", "26", "27", "28", "29", "30", "31",
1261 /* SPE registers. */
1262 "spe_acc", "spefscr",
1263 /* Soft frame pointer. */
1267 #ifdef TARGET_REGNAMES
1268 static const char alt_reg_names[][8] =
1270 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1271 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1272 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1273 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1274 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1275 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1276 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1277 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1278 "mq", "lr", "ctr", "ap",
1279 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1281 /* AltiVec registers. */
1282 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1283 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1284 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1285 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1287 /* SPE registers. */
1288 "spe_acc", "spefscr",
1289 /* Soft frame pointer. */
1294 /* Table of valid machine attributes. */
1296 static const struct attribute_spec rs6000_attribute_table[] =
1298 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1299 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute },
1300 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1301 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1302 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1303 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1304 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1305 SUBTARGET_ATTRIBUTE_TABLE,
1307 { NULL, 0, 0, false, false, false, NULL }
1310 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
1311 static const struct default_options rs6000_option_optimization_table[] =
1313 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
1314 { OPT_LEVELS_NONE, 0, NULL, 0 }
1317 #ifndef MASK_STRICT_ALIGN
1318 #define MASK_STRICT_ALIGN 0
1320 #ifndef TARGET_PROFILE_KERNEL
1321 #define TARGET_PROFILE_KERNEL 0
1324 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1325 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1327 /* Initialize the GCC target structure. */
1328 #undef TARGET_ATTRIBUTE_TABLE
1329 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1330 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1331 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1332 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1333 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1335 #undef TARGET_ASM_ALIGNED_DI_OP
1336 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1338 /* Default unaligned ops are only provided for ELF. Find the ops needed
1339 for non-ELF systems. */
1340 #ifndef OBJECT_FORMAT_ELF
1342 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1344 #undef TARGET_ASM_UNALIGNED_HI_OP
1345 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1346 #undef TARGET_ASM_UNALIGNED_SI_OP
1347 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1348 #undef TARGET_ASM_UNALIGNED_DI_OP
1349 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1352 #undef TARGET_ASM_UNALIGNED_HI_OP
1353 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1354 #undef TARGET_ASM_UNALIGNED_SI_OP
1355 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1356 #undef TARGET_ASM_UNALIGNED_DI_OP
1357 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1358 #undef TARGET_ASM_ALIGNED_DI_OP
1359 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1363 /* This hook deals with fixups for relocatable code and DI-mode objects
1365 #undef TARGET_ASM_INTEGER
1366 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1368 #ifdef HAVE_GAS_HIDDEN
1369 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1370 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1373 #undef TARGET_HAVE_TLS
1374 #define TARGET_HAVE_TLS HAVE_AS_TLS
1376 #undef TARGET_CANNOT_FORCE_CONST_MEM
1377 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1379 #undef TARGET_DELEGITIMIZE_ADDRESS
1380 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1382 #undef TARGET_ASM_FUNCTION_PROLOGUE
1383 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1384 #undef TARGET_ASM_FUNCTION_EPILOGUE
1385 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1387 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
1388 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA rs6000_output_addr_const_extra
1390 #undef TARGET_LEGITIMIZE_ADDRESS
1391 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1393 #undef TARGET_SCHED_VARIABLE_ISSUE
1394 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1396 #undef TARGET_SCHED_ISSUE_RATE
1397 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1398 #undef TARGET_SCHED_ADJUST_COST
1399 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1400 #undef TARGET_SCHED_ADJUST_PRIORITY
1401 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1402 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1403 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1404 #undef TARGET_SCHED_INIT
1405 #define TARGET_SCHED_INIT rs6000_sched_init
1406 #undef TARGET_SCHED_FINISH
1407 #define TARGET_SCHED_FINISH rs6000_sched_finish
1408 #undef TARGET_SCHED_REORDER
1409 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1410 #undef TARGET_SCHED_REORDER2
1411 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1413 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1414 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1416 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1417 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1419 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1420 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1421 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1422 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1423 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1424 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1425 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1426 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1428 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1429 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1430 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1431 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1432 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1433 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1434 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1435 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1436 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1437 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1438 #undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
1439 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
1440 rs6000_builtin_support_vector_misalignment
1441 #undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
1442 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1443 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
1444 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \
1445 rs6000_builtin_vectorization_cost
1446 #undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
1447 #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \
1448 rs6000_preferred_simd_mode
1450 #undef TARGET_INIT_BUILTINS
1451 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1452 #undef TARGET_BUILTIN_DECL
1453 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1455 #undef TARGET_EXPAND_BUILTIN
1456 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1458 #undef TARGET_MANGLE_TYPE
1459 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1461 #undef TARGET_INIT_LIBFUNCS
1462 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1465 #undef TARGET_BINDS_LOCAL_P
1466 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1469 #undef TARGET_MS_BITFIELD_LAYOUT_P
1470 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1472 #undef TARGET_ASM_OUTPUT_MI_THUNK
1473 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1475 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1476 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1478 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1479 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1481 #undef TARGET_INVALID_WITHIN_DOLOOP
1482 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1484 #undef TARGET_REGISTER_MOVE_COST
1485 #define TARGET_REGISTER_MOVE_COST rs6000_register_move_cost
1486 #undef TARGET_MEMORY_MOVE_COST
1487 #define TARGET_MEMORY_MOVE_COST rs6000_memory_move_cost
1488 #undef TARGET_RTX_COSTS
1489 #define TARGET_RTX_COSTS rs6000_rtx_costs
1490 #undef TARGET_ADDRESS_COST
1491 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1493 #undef TARGET_DWARF_REGISTER_SPAN
1494 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1496 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1497 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1499 /* On rs6000, function arguments are promoted, as are function return
1501 #undef TARGET_PROMOTE_FUNCTION_MODE
1502 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1504 #undef TARGET_RETURN_IN_MEMORY
1505 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1507 #undef TARGET_SETUP_INCOMING_VARARGS
1508 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1510 /* Always strict argument naming on rs6000. */
1511 #undef TARGET_STRICT_ARGUMENT_NAMING
1512 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1513 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1514 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1515 #undef TARGET_SPLIT_COMPLEX_ARG
1516 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1517 #undef TARGET_MUST_PASS_IN_STACK
1518 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1519 #undef TARGET_PASS_BY_REFERENCE
1520 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1521 #undef TARGET_ARG_PARTIAL_BYTES
1522 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1523 #undef TARGET_FUNCTION_ARG_ADVANCE
1524 #define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance
1525 #undef TARGET_FUNCTION_ARG
1526 #define TARGET_FUNCTION_ARG rs6000_function_arg
1527 #undef TARGET_FUNCTION_ARG_BOUNDARY
1528 #define TARGET_FUNCTION_ARG_BOUNDARY rs6000_function_arg_boundary
1530 #undef TARGET_BUILD_BUILTIN_VA_LIST
1531 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1533 #undef TARGET_EXPAND_BUILTIN_VA_START
1534 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1536 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1537 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1539 #undef TARGET_EH_RETURN_FILTER_MODE
1540 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1542 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1543 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1545 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1546 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1548 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1549 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1551 #undef TARGET_HANDLE_OPTION
1552 #define TARGET_HANDLE_OPTION rs6000_handle_option
1554 #undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP
1555 #define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rs6000_loop_align_max_skip
1557 #undef TARGET_OPTION_OVERRIDE
1558 #define TARGET_OPTION_OVERRIDE rs6000_option_override
1560 #undef TARGET_OPTION_INIT_STRUCT
1561 #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
1563 #undef TARGET_OPTION_DEFAULT_PARAMS
1564 #define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params
1566 #undef TARGET_OPTION_OPTIMIZATION_TABLE
1567 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
1569 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1570 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1571 rs6000_builtin_vectorized_function
1573 #undef TARGET_DEFAULT_TARGET_FLAGS
1574 #define TARGET_DEFAULT_TARGET_FLAGS \
1577 #undef TARGET_STACK_PROTECT_FAIL
1578 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1580 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1581 The PowerPC architecture requires only weak consistency among
1582 processors--that is, memory accesses between processors need not be
1583 sequentially consistent and memory accesses among processors can occur
1584 in any order. The ability to order memory accesses weakly provides
1585 opportunities for more efficient use of the system bus. Unless a
1586 dependency exists, the 604e allows read operations to precede store
1588 #undef TARGET_RELAXED_ORDERING
1589 #define TARGET_RELAXED_ORDERING true
1592 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1593 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1596 /* Use a 32-bit anchor range. This leads to sequences like:
1598 addis tmp,anchor,high
1601 where tmp itself acts as an anchor, and can be shared between
1602 accesses to the same 64k page. */
1603 #undef TARGET_MIN_ANCHOR_OFFSET
1604 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1605 #undef TARGET_MAX_ANCHOR_OFFSET
1606 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1607 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1608 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1610 #undef TARGET_BUILTIN_RECIPROCAL
1611 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1613 #undef TARGET_EXPAND_TO_RTL_HOOK
1614 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1616 #undef TARGET_INSTANTIATE_DECLS
1617 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1619 #undef TARGET_SECONDARY_RELOAD
1620 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1622 #undef TARGET_IRA_COVER_CLASSES
1623 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1625 #undef TARGET_LEGITIMATE_ADDRESS_P
1626 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1628 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
1629 #define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p
1631 #undef TARGET_CAN_ELIMINATE
1632 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1634 #undef TARGET_CONDITIONAL_REGISTER_USAGE
1635 #define TARGET_CONDITIONAL_REGISTER_USAGE rs6000_conditional_register_usage
1637 #undef TARGET_TRAMPOLINE_INIT
1638 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1640 #undef TARGET_FUNCTION_VALUE
1641 #define TARGET_FUNCTION_VALUE rs6000_function_value
1643 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
1644 #define TARGET_OPTION_VALID_ATTRIBUTE_P rs6000_valid_attribute_p
1646 #undef TARGET_OPTION_SAVE
1647 #define TARGET_OPTION_SAVE rs6000_function_specific_save
1649 #undef TARGET_OPTION_RESTORE
1650 #define TARGET_OPTION_RESTORE rs6000_function_specific_restore
1652 #undef TARGET_OPTION_PRINT
1653 #define TARGET_OPTION_PRINT rs6000_function_specific_print
1655 #undef TARGET_CAN_INLINE_P
1656 #define TARGET_CAN_INLINE_P rs6000_can_inline_p
1658 #undef TARGET_SET_CURRENT_FUNCTION
1659 #define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function
1661 struct gcc_target targetm = TARGET_INITIALIZER;
1664 /* Simplifications for entries below. */
1667 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1668 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1671 /* Some OSs don't support saving the high part of 64-bit registers on context
1672 switch. Other OSs don't support saving Altivec registers. On those OSs, we
1673 don't touch the MASK_POWERPC64 or MASK_ALTIVEC settings; if the user wants
1674 either, the user must explicitly specify them and we won't interfere with
1675 the user's specification. */
1678 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1679 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1680 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1681 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1682 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
1683 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE
1684 | MASK_RECIP_PRECISION)
1687 /* Masks for instructions set at various powerpc ISAs. */
1689 ISA_2_1_MASKS = MASK_MFCRF,
1690 ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB),
1691 ISA_2_4_MASKS = (ISA_2_2_MASKS | MASK_FPRND),
1693 /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't add
1694 ALTIVEC, since in general it isn't a win on power6. In ISA 2.04, fsel,
1695 fre, fsqrt, etc. were no longer documented as optional. Group masks by
1696 server and embedded. */
1697 ISA_2_5_MASKS_EMBEDDED = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION
1698 | MASK_PPC_GFXOPT | MASK_PPC_GPOPT),
1699 ISA_2_5_MASKS_SERVER = (ISA_2_5_MASKS_EMBEDDED | MASK_DFP),
1701 /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
1702 altivec is a win so enable it. */
1703 ISA_2_6_MASKS_EMBEDDED = (ISA_2_5_MASKS_EMBEDDED | MASK_POPCNTD),
1704 ISA_2_6_MASKS_SERVER = (ISA_2_5_MASKS_SERVER | MASK_POPCNTD | MASK_ALTIVEC
1708 /* This table occasionally claims that a processor does not support a
1709 particular feature even though it does, but the feature is slower than the
1710 alternative. Thus, it shouldn't be relied on as a complete description of
1711 the processor's support.
1713 Please keep this list in order, and don't forget to update the documentation
1714 in invoke.texi when adding a new processor or flag. */
1718 const char *const name; /* Canonical processor name. */
1719 const enum processor_type processor; /* Processor type enum value. */
1720 const int target_enable; /* Target flags to enable. */
1723 static struct rs6000_ptt const processor_target_table[] =
1725 {"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1726 {"403", PROCESSOR_PPC403,
1727 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1728 {"405", PROCESSOR_PPC405,
1729 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1730 {"405fp", PROCESSOR_PPC405,
1731 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1732 {"440", PROCESSOR_PPC440,
1733 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1734 {"440fp", PROCESSOR_PPC440,
1735 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1736 {"464", PROCESSOR_PPC440,
1737 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1738 {"464fp", PROCESSOR_PPC440,
1739 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1740 {"476", PROCESSOR_PPC476,
1741 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
1742 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
1743 {"476fp", PROCESSOR_PPC476,
1744 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
1745 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
1746 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1747 {"601", PROCESSOR_PPC601,
1748 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1749 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1750 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1751 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1752 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1753 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1754 {"620", PROCESSOR_PPC620,
1755 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1756 {"630", PROCESSOR_PPC630,
1757 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1758 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1759 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1760 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1761 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1762 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1763 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1764 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1765 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
1767 /* 8548 has a dummy entry for now. */
1768 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
1770 {"a2", PROCESSOR_PPCA2,
1771 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
1772 | MASK_CMPB | MASK_NO_UPDATE },
1773 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1774 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
1775 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
1777 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
1778 | MASK_PPC_GFXOPT | MASK_ISEL},
1779 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1780 {"970", PROCESSOR_POWER4,
1781 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1782 {"cell", PROCESSOR_CELL,
1783 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1784 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1785 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1786 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1787 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1788 {"G5", PROCESSOR_POWER4,
1789 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1790 {"titan", PROCESSOR_TITAN,
1791 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1792 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1793 {"power2", PROCESSOR_POWER,
1794 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1795 {"power3", PROCESSOR_PPC630,
1796 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1797 {"power4", PROCESSOR_POWER4,
1798 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1800 {"power5", PROCESSOR_POWER5,
1801 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1802 | MASK_MFCRF | MASK_POPCNTB},
1803 {"power5+", PROCESSOR_POWER5,
1804 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1805 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1806 {"power6", PROCESSOR_POWER6,
1807 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1808 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
1809 | MASK_RECIP_PRECISION},
1810 {"power6x", PROCESSOR_POWER6,
1811 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1812 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
1813 | MASK_MFPGPR | MASK_RECIP_PRECISION},
1814 {"power7", PROCESSOR_POWER7, /* Don't add MASK_ISEL by default */
1815 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
1816 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
1817 | MASK_VSX | MASK_RECIP_PRECISION},
1818 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1819 {"powerpc64", PROCESSOR_POWERPC64,
1820 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1821 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1822 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1823 {"rios2", PROCESSOR_RIOS2,
1824 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1825 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1826 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1827 {"rs64", PROCESSOR_RS64A,
1828 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1831 /* Look up a processor name for -mcpu=xxx and -mtune=xxx. Return -1 if the
1835 rs6000_cpu_name_lookup (const char *name)
1841 for (i = 0; i < ARRAY_SIZE (processor_target_table); i++)
1842 if (! strcmp (name, processor_target_table[i].name))
1850 /* Return number of consecutive hard regs needed starting at reg REGNO
1851 to hold something of mode MODE.
1852 This is ordinarily the length in words of a value of mode MODE
1853 but can be less for certain modes in special long registers.
1855 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1856 scalar instructions. The upper 32 bits are only available to the
1859 POWER and PowerPC GPRs hold 32 bits worth;
1860 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1863 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1865 unsigned HOST_WIDE_INT reg_size;
1867 if (FP_REGNO_P (regno))
1868 reg_size = (VECTOR_MEM_VSX_P (mode)
1869 ? UNITS_PER_VSX_WORD
1870 : UNITS_PER_FP_WORD);
1872 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1873 reg_size = UNITS_PER_SPE_WORD;
1875 else if (ALTIVEC_REGNO_P (regno))
1876 reg_size = UNITS_PER_ALTIVEC_WORD;
1878 /* The value returned for SCmode in the E500 double case is 2 for
1879 ABI compatibility; storing an SCmode value in a single register
1880 would require function_arg and rs6000_spe_function_arg to handle
1881 SCmode so as to pass the value correctly in a pair of
1883 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1884 && !DECIMAL_FLOAT_MODE_P (mode))
1885 reg_size = UNITS_PER_FP_WORD;
1888 reg_size = UNITS_PER_WORD;
1890 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1893 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1896 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1898 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1900 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1901 implementations. Don't allow an item to be split between a FP register
1902 and an Altivec register. */
1903 if (VECTOR_MEM_VSX_P (mode))
1905 if (FP_REGNO_P (regno))
1906 return FP_REGNO_P (last_regno);
1908 if (ALTIVEC_REGNO_P (regno))
1909 return ALTIVEC_REGNO_P (last_regno);
1912 /* The GPRs can hold any mode, but values bigger than one register
1913 cannot go past R31. */
1914 if (INT_REGNO_P (regno))
1915 return INT_REGNO_P (last_regno);
1917 /* The float registers (except for VSX vector modes) can only hold floating
1918 modes and DImode. This excludes the 32-bit decimal float mode for
1920 if (FP_REGNO_P (regno))
1922 if (SCALAR_FLOAT_MODE_P (mode)
1923 && (mode != TDmode || (regno % 2) == 0)
1924 && FP_REGNO_P (last_regno))
1927 if (GET_MODE_CLASS (mode) == MODE_INT
1928 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1931 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1932 && PAIRED_VECTOR_MODE (mode))
1938 /* The CR register can only hold CC modes. */
1939 if (CR_REGNO_P (regno))
1940 return GET_MODE_CLASS (mode) == MODE_CC;
1942 if (CA_REGNO_P (regno))
1943 return mode == BImode;
1945 /* AltiVec only in AldyVec registers. */
1946 if (ALTIVEC_REGNO_P (regno))
1947 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1949 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1950 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1953 /* We cannot put TImode anywhere except general register and it must be able
1954 to fit within the register set. In the future, allow TImode in the
1955 Altivec or VSX registers. */
1957 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1960 /* Print interesting facts about registers. */
1962 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1966 for (r = first_regno; r <= last_regno; ++r)
1968 const char *comma = "";
1971 if (first_regno == last_regno)
1972 fprintf (stderr, "%s:\t", reg_name);
1974 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1977 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1978 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1982 fprintf (stderr, ",\n\t");
1987 if (rs6000_hard_regno_nregs[m][r] > 1)
1988 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1989 rs6000_hard_regno_nregs[m][r]);
1991 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1996 if (call_used_regs[r])
2000 fprintf (stderr, ",\n\t");
2005 len += fprintf (stderr, "%s%s", comma, "call-used");
2013 fprintf (stderr, ",\n\t");
2018 len += fprintf (stderr, "%s%s", comma, "fixed");
2024 fprintf (stderr, ",\n\t");
2028 fprintf (stderr, "%sregno = %d\n", comma, r);
2032 #define DEBUG_FMT_D "%-32s= %d\n"
2033 #define DEBUG_FMT_S "%-32s= %s\n"
2035 /* Print various interesting information with -mdebug=reg. */
2037 rs6000_debug_reg_global (void)
2039 static const char *const tf[2] = { "false", "true" };
2040 const char *nl = (const char *)0;
2042 char costly_num[20];
2044 const char *costly_str;
2045 const char *nop_str;
2046 const char *trace_str;
2047 const char *abi_str;
2048 const char *cmodel_str;
2050 /* Map enum rs6000_vector to string. */
2051 static const char *rs6000_debug_vector_unit[] = {
2060 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
2061 LAST_VIRTUAL_REGISTER);
2062 rs6000_debug_reg_print (0, 31, "gr");
2063 rs6000_debug_reg_print (32, 63, "fp");
2064 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
2067 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
2068 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
2069 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
2070 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
2071 rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca");
2072 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
2073 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
2074 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
2075 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
2079 "d reg_class = %s\n"
2080 "f reg_class = %s\n"
2081 "v reg_class = %s\n"
2082 "wa reg_class = %s\n"
2083 "wd reg_class = %s\n"
2084 "wf reg_class = %s\n"
2085 "ws reg_class = %s\n\n",
2086 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
2087 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
2088 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
2089 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
2090 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
2091 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
2092 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
2094 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2095 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
2098 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
2100 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
2101 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
2107 if (rs6000_recip_control)
2109 fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control);
2111 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2112 if (rs6000_recip_bits[m])
2115 "Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n",
2117 (RS6000_RECIP_AUTO_RE_P (m)
2119 : (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")),
2120 (RS6000_RECIP_AUTO_RSQRTE_P (m)
2122 : (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none")));
2125 fputs ("\n", stderr);
2128 if (rs6000_cpu_index >= 0)
2129 fprintf (stderr, DEBUG_FMT_S, "cpu",
2130 processor_target_table[rs6000_cpu_index].name);
2132 if (rs6000_tune_index >= 0)
2133 fprintf (stderr, DEBUG_FMT_S, "tune",
2134 processor_target_table[rs6000_tune_index].name);
2136 switch (rs6000_sched_costly_dep)
2138 case max_dep_latency:
2139 costly_str = "max_dep_latency";
2143 costly_str = "no_dep_costly";
2146 case all_deps_costly:
2147 costly_str = "all_deps_costly";
2150 case true_store_to_load_dep_costly:
2151 costly_str = "true_store_to_load_dep_costly";
2154 case store_to_load_dep_costly:
2155 costly_str = "store_to_load_dep_costly";
2159 costly_str = costly_num;
2160 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
2164 fprintf (stderr, DEBUG_FMT_S, "sched_costly_dep", costly_str);
2166 switch (rs6000_sched_insert_nops)
2168 case sched_finish_regroup_exact:
2169 nop_str = "sched_finish_regroup_exact";
2172 case sched_finish_pad_groups:
2173 nop_str = "sched_finish_pad_groups";
2176 case sched_finish_none:
2177 nop_str = "sched_finish_none";
2182 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
2186 fprintf (stderr, DEBUG_FMT_S, "sched_insert_nops", nop_str);
2188 switch (rs6000_sdata)
2195 fprintf (stderr, DEBUG_FMT_S, "sdata", "data");
2199 fprintf (stderr, DEBUG_FMT_S, "sdata", "sysv");
2203 fprintf (stderr, DEBUG_FMT_S, "sdata", "eabi");
2208 switch (rs6000_traceback)
2210 case traceback_default: trace_str = "default"; break;
2211 case traceback_none: trace_str = "none"; break;
2212 case traceback_part: trace_str = "part"; break;
2213 case traceback_full: trace_str = "full"; break;
2214 default: trace_str = "unknown"; break;
2217 fprintf (stderr, DEBUG_FMT_S, "traceback", trace_str);
2219 switch (rs6000_current_cmodel)
2221 case CMODEL_SMALL: cmodel_str = "small"; break;
2222 case CMODEL_MEDIUM: cmodel_str = "medium"; break;
2223 case CMODEL_LARGE: cmodel_str = "large"; break;
2224 default: cmodel_str = "unknown"; break;
2227 fprintf (stderr, DEBUG_FMT_S, "cmodel", cmodel_str);
2229 switch (rs6000_current_abi)
2231 case ABI_NONE: abi_str = "none"; break;
2232 case ABI_AIX: abi_str = "aix"; break;
2233 case ABI_V4: abi_str = "V4"; break;
2234 case ABI_DARWIN: abi_str = "darwin"; break;
2235 default: abi_str = "unknown"; break;
2238 fprintf (stderr, DEBUG_FMT_S, "abi", abi_str);
2240 if (rs6000_altivec_abi)
2241 fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true");
2244 fprintf (stderr, DEBUG_FMT_S, "spe_abi", "true");
2246 if (rs6000_darwin64_abi)
2247 fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true");
2249 if (rs6000_float_gprs)
2250 fprintf (stderr, DEBUG_FMT_S, "float_gprs", "true");
2252 fprintf (stderr, DEBUG_FMT_S, "always_hint", tf[!!rs6000_always_hint]);
2253 fprintf (stderr, DEBUG_FMT_S, "align_branch",
2254 tf[!!rs6000_align_branch_targets]);
2255 fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size);
2256 fprintf (stderr, DEBUG_FMT_D, "long_double_size",
2257 rs6000_long_double_type_size);
2258 fprintf (stderr, DEBUG_FMT_D, "sched_restricted_insns_priority",
2259 (int)rs6000_sched_restricted_insns_priority);
2262 /* Initialize the various global tables that are based on register size. */
2264 rs6000_init_hard_regno_mode_ok (bool global_init_p)
2270 /* Precalculate REGNO_REG_CLASS. */
2271 rs6000_regno_regclass[0] = GENERAL_REGS;
2272 for (r = 1; r < 32; ++r)
2273 rs6000_regno_regclass[r] = BASE_REGS;
2275 for (r = 32; r < 64; ++r)
2276 rs6000_regno_regclass[r] = FLOAT_REGS;
2278 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
2279 rs6000_regno_regclass[r] = NO_REGS;
2281 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
2282 rs6000_regno_regclass[r] = ALTIVEC_REGS;
2284 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
2285 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
2286 rs6000_regno_regclass[r] = CR_REGS;
2288 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
2289 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
2290 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
2291 rs6000_regno_regclass[CA_REGNO] = CA_REGS;
2292 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
2293 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
2294 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
2295 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
2296 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
2297 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
2299 /* Precalculate vector information, this must be set up before the
2300 rs6000_hard_regno_nregs_internal below. */
2301 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2303 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
2304 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
2305 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
2308 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
2309 rs6000_constraints[c] = NO_REGS;
2311 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
2312 believes it can use native alignment or still uses 128-bit alignment. */
2313 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
2324 /* V2DF mode, VSX only. */
2327 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
2328 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
2329 rs6000_vector_align[V2DFmode] = align64;
2332 /* V4SF mode, either VSX or Altivec. */
2335 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
2336 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
2337 rs6000_vector_align[V4SFmode] = align32;
2339 else if (TARGET_ALTIVEC)
2341 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
2342 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
2343 rs6000_vector_align[V4SFmode] = align32;
2346 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
2350 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
2351 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
2352 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
2353 rs6000_vector_align[V4SImode] = align32;
2354 rs6000_vector_align[V8HImode] = align32;
2355 rs6000_vector_align[V16QImode] = align32;
2359 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
2360 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
2361 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
2365 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
2366 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
2367 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
2371 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
2372 Altivec doesn't have 64-bit support. */
2375 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
2376 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
2377 rs6000_vector_align[V2DImode] = align64;
2380 /* DFmode, see if we want to use the VSX unit. */
2381 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
2383 rs6000_vector_unit[DFmode] = VECTOR_VSX;
2384 rs6000_vector_mem[DFmode]
2385 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
2386 rs6000_vector_align[DFmode] = align64;
2389 /* TODO add SPE and paired floating point vector support. */
2391 /* Register class constaints for the constraints that depend on compile
2393 if (TARGET_HARD_FLOAT && TARGET_FPRS)
2394 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2396 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2397 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2401 /* At present, we just use VSX_REGS, but we have different constraints
2402 based on the use, in case we want to fine tune the default register
2403 class used. wa = any VSX register, wf = register class to use for
2404 V4SF, wd = register class to use for V2DF, and ws = register classs to
2405 use for DF scalars. */
2406 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2407 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2408 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2409 rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
2415 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2417 /* Set up the reload helper functions. */
2418 if (TARGET_VSX || TARGET_ALTIVEC)
2422 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2423 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2424 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2425 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2426 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2427 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2428 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2429 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2430 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2431 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2432 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2433 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2437 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2438 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2439 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2440 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2441 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2442 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2443 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2444 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2445 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2446 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2447 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2448 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2452 /* Precalculate HARD_REGNO_NREGS. */
2453 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2454 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2455 rs6000_hard_regno_nregs[m][r]
2456 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2458 /* Precalculate HARD_REGNO_MODE_OK. */
2459 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2460 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2461 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2462 rs6000_hard_regno_mode_ok_p[m][r] = true;
2464 /* Precalculate CLASS_MAX_NREGS sizes. */
2465 for (c = 0; c < LIM_REG_CLASSES; ++c)
2469 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2470 reg_size = UNITS_PER_VSX_WORD;
2472 else if (c == ALTIVEC_REGS)
2473 reg_size = UNITS_PER_ALTIVEC_WORD;
2475 else if (c == FLOAT_REGS)
2476 reg_size = UNITS_PER_FP_WORD;
2479 reg_size = UNITS_PER_WORD;
2481 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2482 rs6000_class_max_nregs[m][c]
2483 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2486 if (TARGET_E500_DOUBLE)
2487 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2489 /* Calculate which modes to automatically generate code to use a the
2490 reciprocal divide and square root instructions. In the future, possibly
2491 automatically generate the instructions even if the user did not specify
2492 -mrecip. The older machines double precision reciprocal sqrt estimate is
2493 not accurate enough. */
2494 memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits));
2496 rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2498 rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2499 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2500 rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2501 if (VECTOR_UNIT_VSX_P (V2DFmode))
2502 rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2504 if (TARGET_FRSQRTES)
2505 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2507 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2508 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2509 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2510 if (VECTOR_UNIT_VSX_P (V2DFmode))
2511 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2513 if (rs6000_recip_control)
2515 if (!flag_finite_math_only)
2516 warning (0, "-mrecip requires -ffinite-math or -ffast-math");
2517 if (flag_trapping_math)
2518 warning (0, "-mrecip requires -fno-trapping-math or -ffast-math");
2519 if (!flag_reciprocal_math)
2520 warning (0, "-mrecip requires -freciprocal-math or -ffast-math");
2521 if (flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math)
2523 if (RS6000_RECIP_HAVE_RE_P (SFmode)
2524 && (rs6000_recip_control & RECIP_SF_DIV) != 0)
2525 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2527 if (RS6000_RECIP_HAVE_RE_P (DFmode)
2528 && (rs6000_recip_control & RECIP_DF_DIV) != 0)
2529 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2531 if (RS6000_RECIP_HAVE_RE_P (V4SFmode)
2532 && (rs6000_recip_control & RECIP_V4SF_DIV) != 0)
2533 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2535 if (RS6000_RECIP_HAVE_RE_P (V2DFmode)
2536 && (rs6000_recip_control & RECIP_V2DF_DIV) != 0)
2537 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2539 if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode)
2540 && (rs6000_recip_control & RECIP_SF_RSQRT) != 0)
2541 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2543 if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode)
2544 && (rs6000_recip_control & RECIP_DF_RSQRT) != 0)
2545 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2547 if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode)
2548 && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0)
2549 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2551 if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode)
2552 && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0)
2553 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2557 if (global_init_p || TARGET_DEBUG_TARGET)
2559 if (TARGET_DEBUG_REG)
2560 rs6000_debug_reg_global ();
2562 if (TARGET_DEBUG_COST || TARGET_DEBUG_REG)
2564 "SImode variable mult cost = %d\n"
2565 "SImode constant mult cost = %d\n"
2566 "SImode short constant mult cost = %d\n"
2567 "DImode multipliciation cost = %d\n"
2568 "SImode division cost = %d\n"
2569 "DImode division cost = %d\n"
2570 "Simple fp operation cost = %d\n"
2571 "DFmode multiplication cost = %d\n"
2572 "SFmode division cost = %d\n"
2573 "DFmode division cost = %d\n"
2574 "cache line size = %d\n"
2575 "l1 cache size = %d\n"
2576 "l2 cache size = %d\n"
2577 "simultaneous prefetches = %d\n"
2580 rs6000_cost->mulsi_const,
2581 rs6000_cost->mulsi_const9,
2589 rs6000_cost->cache_line_size,
2590 rs6000_cost->l1_cache_size,
2591 rs6000_cost->l2_cache_size,
2592 rs6000_cost->simultaneous_prefetches);
2597 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2600 darwin_rs6000_override_options (void)
2602 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2604 rs6000_altivec_abi = 1;
2605 TARGET_ALTIVEC_VRSAVE = 1;
2607 if (DEFAULT_ABI == ABI_DARWIN
2609 darwin_one_byte_bool = 1;
2611 if (TARGET_64BIT && ! TARGET_POWERPC64)
2613 target_flags |= MASK_POWERPC64;
2614 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2618 rs6000_default_long_calls = 1;
2619 target_flags |= MASK_SOFT_FLOAT;
2622 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2624 if (!flag_mkernel && !flag_apple_kext
2626 && ! (target_flags_explicit & MASK_ALTIVEC))
2627 target_flags |= MASK_ALTIVEC;
2629 /* Unless the user (not the configurer) has explicitly overridden
2630 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2631 G4 unless targetting the kernel. */
2634 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2635 && ! (target_flags_explicit & MASK_ALTIVEC)
2636 && ! rs6000_select[1].string)
2638 target_flags |= MASK_ALTIVEC;
2643 /* If not otherwise specified by a target, make 'long double' equivalent to
2646 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2647 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2650 /* Override command line options. Mostly we process the processor type and
2651 sometimes adjust other TARGET_ options. */
2654 rs6000_option_override_internal (bool global_init_p)
2657 const char *default_cpu = OPTION_TARGET_CPU_DEFAULT;
2661 struct cl_target_option *main_target_opt
2662 = ((global_init_p || target_option_default_node == NULL)
2663 ? NULL : TREE_TARGET_OPTION (target_option_default_node));
2665 /* Numerous experiment shows that IRA based loop pressure
2666 calculation works better for RTL loop invariant motion on targets
2667 with enough (>= 32) registers. It is an expensive optimization.
2668 So it is on only for peak performance. */
2669 if (optimize >= 3 && global_init_p)
2670 flag_ira_loop_pressure = 1;
2672 /* Set the pointer size. */
2675 rs6000_pmode = (int)DImode;
2676 rs6000_pointer_size = 64;
2680 rs6000_pmode = (int)SImode;
2681 rs6000_pointer_size = 32;
2684 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2685 #ifdef OS_MISSING_POWERPC64
2686 if (OS_MISSING_POWERPC64)
2687 set_masks &= ~MASK_POWERPC64;
2689 #ifdef OS_MISSING_ALTIVEC
2690 if (OS_MISSING_ALTIVEC)
2691 set_masks &= ~MASK_ALTIVEC;
2694 /* Don't override by the processor default if given explicitly. */
2695 set_masks &= ~target_flags_explicit;
2697 /* Identify the processor type. */
2700 if (TARGET_POWERPC64)
2701 default_cpu = "powerpc64";
2702 else if (TARGET_POWERPC)
2703 default_cpu = "powerpc";
2706 /* Process the -mcpu=<xxx> and -mtune=<xxx> argument. If the user changed
2707 the cpu in a target attribute or pragma, but did not specify a tuning
2708 option, use the cpu for the tuning option rather than the option specified
2709 with -mtune on the command line. */
2710 if (rs6000_cpu_index > 0)
2711 cpu_index = rs6000_cpu_index;
2712 else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index > 0)
2713 rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index;
2715 rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (default_cpu);
2717 if (rs6000_tune_index > 0)
2718 tune_index = rs6000_tune_index;
2720 rs6000_tune_index = tune_index = cpu_index;
2724 target_flags &= ~set_masks;
2725 target_flags |= (processor_target_table[cpu_index].target_enable
2729 rs6000_cpu = ((tune_index >= 0)
2730 ? processor_target_table[tune_index].processor
2732 ? PROCESSOR_DEFAULT64
2733 : PROCESSOR_DEFAULT));
2735 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2736 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2739 error ("AltiVec not supported in this target");
2741 error ("SPE not supported in this target");
2744 /* Disable Cell microcode if we are optimizing for the Cell
2745 and not optimizing for size. */
2746 if (rs6000_gen_cell_microcode == -1)
2747 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2750 /* If we are optimizing big endian systems for space and it's OK to
2751 use instructions that would be microcoded on the Cell, use the
2752 load/store multiple and string instructions. */
2753 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2754 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2756 /* Don't allow -mmultiple or -mstring on little endian systems
2757 unless the cpu is a 750, because the hardware doesn't support the
2758 instructions used in little endian mode, and causes an alignment
2759 trap. The 750 does not cause an alignment trap (except when the
2760 target is unaligned). */
2762 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2764 if (TARGET_MULTIPLE)
2766 target_flags &= ~MASK_MULTIPLE;
2767 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2768 warning (0, "-mmultiple is not supported on little endian systems");
2773 target_flags &= ~MASK_STRING;
2774 if ((target_flags_explicit & MASK_STRING) != 0)
2775 warning (0, "-mstring is not supported on little endian systems");
2779 /* Add some warnings for VSX. */
2782 const char *msg = NULL;
2783 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2784 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2786 if (target_flags_explicit & MASK_VSX)
2787 msg = N_("-mvsx requires hardware floating point");
2789 target_flags &= ~ MASK_VSX;
2791 else if (TARGET_PAIRED_FLOAT)
2792 msg = N_("-mvsx and -mpaired are incompatible");
2793 /* The hardware will allow VSX and little endian, but until we make sure
2794 things like vector select, etc. work don't allow VSX on little endian
2795 systems at this point. */
2796 else if (!BYTES_BIG_ENDIAN)
2797 msg = N_("-mvsx used with little endian code");
2798 else if (TARGET_AVOID_XFORM > 0)
2799 msg = N_("-mvsx needs indexed addressing");
2800 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2802 if (target_flags_explicit & MASK_VSX)
2803 msg = N_("-mvsx and -mno-altivec are incompatible");
2805 msg = N_("-mno-altivec disables vsx");
2811 target_flags &= ~ MASK_VSX;
2812 target_flags_explicit |= MASK_VSX;
2816 /* For the newer switches (vsx, dfp, etc.) set some of the older options,
2817 unless the user explicitly used the -mno-<option> to disable the code. */
2819 target_flags |= (ISA_2_6_MASKS_SERVER & ~target_flags_explicit);
2820 else if (TARGET_POPCNTD)
2821 target_flags |= (ISA_2_6_MASKS_EMBEDDED & ~target_flags_explicit);
2822 else if (TARGET_DFP)
2823 target_flags |= (ISA_2_5_MASKS_SERVER & ~target_flags_explicit);
2824 else if (TARGET_CMPB)
2825 target_flags |= (ISA_2_5_MASKS_EMBEDDED & ~target_flags_explicit);
2826 else if (TARGET_FPRND)
2827 target_flags |= (ISA_2_4_MASKS & ~target_flags_explicit);
2828 else if (TARGET_POPCNTB)
2829 target_flags |= (ISA_2_2_MASKS & ~target_flags_explicit);
2830 else if (TARGET_ALTIVEC)
2831 target_flags |= (MASK_PPC_GFXOPT & ~target_flags_explicit);
2833 /* E500mc does "better" if we inline more aggressively. Respect the
2834 user's opinion, though. */
2835 if (rs6000_block_move_inline_limit == 0
2836 && (rs6000_cpu == PROCESSOR_PPCE500MC
2837 || rs6000_cpu == PROCESSOR_PPCE500MC64))
2838 rs6000_block_move_inline_limit = 128;
2840 /* store_one_arg depends on expand_block_move to handle at least the
2841 size of reg_parm_stack_space. */
2842 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32))
2843 rs6000_block_move_inline_limit = (TARGET_POWERPC64 ? 64 : 32);
2847 /* If the appropriate debug option is enabled, replace the target hooks
2848 with debug versions that call the real version and then prints
2849 debugging information. */
2850 if (TARGET_DEBUG_COST)
2852 targetm.rtx_costs = rs6000_debug_rtx_costs;
2853 targetm.address_cost = rs6000_debug_address_cost;
2854 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2857 if (TARGET_DEBUG_ADDR)
2859 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2860 targetm.legitimize_address = rs6000_debug_legitimize_address;
2861 rs6000_secondary_reload_class_ptr
2862 = rs6000_debug_secondary_reload_class;
2863 rs6000_secondary_memory_needed_ptr
2864 = rs6000_debug_secondary_memory_needed;
2865 rs6000_cannot_change_mode_class_ptr
2866 = rs6000_debug_cannot_change_mode_class;
2867 rs6000_preferred_reload_class_ptr
2868 = rs6000_debug_preferred_reload_class;
2869 rs6000_legitimize_reload_address_ptr
2870 = rs6000_debug_legitimize_reload_address;
2871 rs6000_mode_dependent_address_ptr
2872 = rs6000_debug_mode_dependent_address;
2875 if (rs6000_veclibabi_name)
2877 if (strcmp (rs6000_veclibabi_name, "mass") == 0)
2878 rs6000_veclib_handler = rs6000_builtin_vectorized_libmass;
2881 error ("unknown vectorization library ABI type (%s) for "
2882 "-mveclibabi= switch", rs6000_veclibabi_name);
2888 if (!rs6000_explicit_options.long_double)
2890 if (main_target_opt != NULL
2891 && (main_target_opt->x_rs6000_long_double_type_size
2892 != RS6000_DEFAULT_LONG_DOUBLE_SIZE))
2893 error ("target attribute or pragma changes long double size");
2895 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2898 #ifndef POWERPC_LINUX
2899 if (!rs6000_explicit_options.ieee)
2900 rs6000_ieeequad = 1;
2903 /* Disable VSX and Altivec silently if the user switched cpus to power7 in a
2904 target attribute or pragma which automatically enables both options,
2905 unless the altivec ABI was set. This is set by default for 64-bit, but
2907 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2908 target_flags &= ~((MASK_VSX | MASK_ALTIVEC) & ~target_flags_explicit);
2910 /* Enable Altivec ABI for AIX -maltivec. */
2911 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2913 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2914 error ("target attribute or pragma changes AltiVec ABI");
2916 rs6000_altivec_abi = 1;
2919 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2920 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2921 be explicitly overridden in either case. */
2924 if (!rs6000_explicit_options.altivec_abi
2925 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2927 if (main_target_opt != NULL &&
2928 !main_target_opt->x_rs6000_altivec_abi)
2929 error ("target attribute or pragma changes AltiVec ABI");
2931 rs6000_altivec_abi = 1;
2934 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2935 if (!rs6000_explicit_options.vrsave)
2936 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2939 /* Set the Darwin64 ABI as default for 64-bit Darwin.
2940 So far, the only darwin64 targets are also MACH-O. */
2942 && DEFAULT_ABI == ABI_DARWIN
2945 if (main_target_opt != NULL && !main_target_opt->x_rs6000_darwin64_abi)
2946 error ("target attribute or pragma changes darwin64 ABI");
2949 rs6000_darwin64_abi = 1;
2950 /* Default to natural alignment, for better performance. */
2951 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2955 /* Place FP constants in the constant pool instead of TOC
2956 if section anchors enabled. */
2957 if (flag_section_anchors)
2958 TARGET_NO_FP_IN_TOC = 1;
2960 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2961 SUBTARGET_OVERRIDE_OPTIONS;
2963 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2964 SUBSUBTARGET_OVERRIDE_OPTIONS;
2966 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2967 SUB3TARGET_OVERRIDE_OPTIONS;
2970 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2971 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2973 /* The e500 and e500mc do not have string instructions, and we set
2974 MASK_STRING above when optimizing for size. */
2975 if ((target_flags & MASK_STRING) != 0)
2976 target_flags = target_flags & ~MASK_STRING;
2978 else if (rs6000_select[1].string != NULL)
2980 /* For the powerpc-eabispe configuration, we set all these by
2981 default, so let's unset them if we manually set another
2982 CPU that is not the E500. */
2983 if (main_target_opt != NULL
2984 && ((main_target_opt->x_rs6000_spe_abi != rs6000_spe_abi)
2985 || (main_target_opt->x_rs6000_spe != rs6000_spe)
2986 || (main_target_opt->x_rs6000_float_gprs != rs6000_float_gprs)))
2987 error ("target attribute or pragma changes SPE ABI");
2990 if (!rs6000_explicit_options.spe_abi)
2992 if (!rs6000_explicit_options.spe)
2994 if (!rs6000_explicit_options.float_gprs)
2995 rs6000_float_gprs = 0;
2997 if (!(target_flags_explicit & MASK_ISEL))
2998 target_flags &= ~MASK_ISEL;
3001 /* Detect invalid option combinations with E500. */
3004 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
3005 && rs6000_cpu != PROCESSOR_POWER5
3006 && rs6000_cpu != PROCESSOR_POWER6
3007 && rs6000_cpu != PROCESSOR_POWER7
3008 && rs6000_cpu != PROCESSOR_PPCA2
3009 && rs6000_cpu != PROCESSOR_CELL);
3010 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
3011 || rs6000_cpu == PROCESSOR_POWER5
3012 || rs6000_cpu == PROCESSOR_POWER7);
3013 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
3014 || rs6000_cpu == PROCESSOR_POWER5
3015 || rs6000_cpu == PROCESSOR_POWER6
3016 || rs6000_cpu == PROCESSOR_POWER7
3017 || rs6000_cpu == PROCESSOR_PPCE500MC
3018 || rs6000_cpu == PROCESSOR_PPCE500MC64);
3020 /* Allow debug switches to override the above settings. These are set to -1
3021 in rs6000.opt to indicate the user hasn't directly set the switch. */
3022 if (TARGET_ALWAYS_HINT >= 0)
3023 rs6000_always_hint = TARGET_ALWAYS_HINT;
3025 if (TARGET_SCHED_GROUPS >= 0)
3026 rs6000_sched_groups = TARGET_SCHED_GROUPS;
3028 if (TARGET_ALIGN_BRANCH_TARGETS >= 0)
3029 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
3031 rs6000_sched_restricted_insns_priority
3032 = (rs6000_sched_groups ? 1 : 0);
3034 /* Handle -msched-costly-dep option. */
3035 rs6000_sched_costly_dep
3036 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
3038 if (rs6000_sched_costly_dep_str)
3040 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
3041 rs6000_sched_costly_dep = no_dep_costly;
3042 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
3043 rs6000_sched_costly_dep = all_deps_costly;
3044 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
3045 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
3046 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
3047 rs6000_sched_costly_dep = store_to_load_dep_costly;
3049 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
3050 atoi (rs6000_sched_costly_dep_str));
3053 /* Handle -minsert-sched-nops option. */
3054 rs6000_sched_insert_nops
3055 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
3057 if (rs6000_sched_insert_nops_str)
3059 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
3060 rs6000_sched_insert_nops = sched_finish_none;
3061 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
3062 rs6000_sched_insert_nops = sched_finish_pad_groups;
3063 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
3064 rs6000_sched_insert_nops = sched_finish_regroup_exact;
3066 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
3067 atoi (rs6000_sched_insert_nops_str));
3072 #ifdef TARGET_REGNAMES
3073 /* If the user desires alternate register names, copy in the
3074 alternate names now. */
3075 if (TARGET_REGNAMES)
3076 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
3079 /* Set aix_struct_return last, after the ABI is determined.
3080 If -maix-struct-return or -msvr4-struct-return was explicitly
3081 used, don't override with the ABI default. */
3082 if (!rs6000_explicit_options.aix_struct_ret)
3083 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
3086 /* IBM XL compiler defaults to unsigned bitfields. */
3087 if (TARGET_XL_COMPAT)
3088 flag_signed_bitfields = 0;
3091 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
3092 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
3095 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
3097 /* We can only guarantee the availability of DI pseudo-ops when
3098 assembling for 64-bit targets. */
3101 targetm.asm_out.aligned_op.di = NULL;
3102 targetm.asm_out.unaligned_op.di = NULL;
3106 /* Set branch target alignment, if not optimizing for size. */
3109 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be
3110 aligned 8byte to avoid misprediction by the branch predictor. */
3111 if (rs6000_cpu == PROCESSOR_TITAN
3112 || rs6000_cpu == PROCESSOR_CELL)
3114 if (align_functions <= 0)
3115 align_functions = 8;
3116 if (align_jumps <= 0)
3118 if (align_loops <= 0)
3121 if (rs6000_align_branch_targets)
3123 if (align_functions <= 0)
3124 align_functions = 16;
3125 if (align_jumps <= 0)
3127 if (align_loops <= 0)
3129 can_override_loop_align = 1;
3133 if (align_jumps_max_skip <= 0)
3134 align_jumps_max_skip = 15;
3135 if (align_loops_max_skip <= 0)
3136 align_loops_max_skip = 15;
3139 /* Arrange to save and restore machine status around nested functions. */
3140 init_machine_status = rs6000_init_machine_status;
3142 /* We should always be splitting complex arguments, but we can't break
3143 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
3144 if (DEFAULT_ABI != ABI_AIX)
3145 targetm.calls.split_complex_arg = NULL;
3148 /* Initialize rs6000_cost with the appropriate target costs. */
3150 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
3154 case PROCESSOR_RIOS1:
3155 rs6000_cost = &rios1_cost;
3158 case PROCESSOR_RIOS2:
3159 rs6000_cost = &rios2_cost;
3162 case PROCESSOR_RS64A:
3163 rs6000_cost = &rs64a_cost;
3166 case PROCESSOR_MPCCORE:
3167 rs6000_cost = &mpccore_cost;
3170 case PROCESSOR_PPC403:
3171 rs6000_cost = &ppc403_cost;
3174 case PROCESSOR_PPC405:
3175 rs6000_cost = &ppc405_cost;
3178 case PROCESSOR_PPC440:
3179 rs6000_cost = &ppc440_cost;
3182 case PROCESSOR_PPC476:
3183 rs6000_cost = &ppc476_cost;
3186 case PROCESSOR_PPC601:
3187 rs6000_cost = &ppc601_cost;
3190 case PROCESSOR_PPC603:
3191 rs6000_cost = &ppc603_cost;
3194 case PROCESSOR_PPC604:
3195 rs6000_cost = &ppc604_cost;
3198 case PROCESSOR_PPC604e:
3199 rs6000_cost = &ppc604e_cost;
3202 case PROCESSOR_PPC620:
3203 rs6000_cost = &ppc620_cost;
3206 case PROCESSOR_PPC630:
3207 rs6000_cost = &ppc630_cost;
3210 case PROCESSOR_CELL:
3211 rs6000_cost = &ppccell_cost;
3214 case PROCESSOR_PPC750:
3215 case PROCESSOR_PPC7400:
3216 rs6000_cost = &ppc750_cost;
3219 case PROCESSOR_PPC7450:
3220 rs6000_cost = &ppc7450_cost;
3223 case PROCESSOR_PPC8540:
3224 rs6000_cost = &ppc8540_cost;
3227 case PROCESSOR_PPCE300C2:
3228 case PROCESSOR_PPCE300C3:
3229 rs6000_cost = &ppce300c2c3_cost;
3232 case PROCESSOR_PPCE500MC:
3233 rs6000_cost = &ppce500mc_cost;
3236 case PROCESSOR_PPCE500MC64:
3237 rs6000_cost = &ppce500mc64_cost;
3240 case PROCESSOR_TITAN:
3241 rs6000_cost = &titan_cost;
3244 case PROCESSOR_POWER4:
3245 case PROCESSOR_POWER5:
3246 rs6000_cost = &power4_cost;
3249 case PROCESSOR_POWER6:
3250 rs6000_cost = &power6_cost;
3253 case PROCESSOR_POWER7:
3254 rs6000_cost = &power7_cost;
3257 case PROCESSOR_PPCA2:
3258 rs6000_cost = &ppca2_cost;
3267 maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
3268 rs6000_cost->simultaneous_prefetches,
3269 global_options.x_param_values,
3270 global_options_set.x_param_values);
3271 maybe_set_param_value (PARAM_L1_CACHE_SIZE, rs6000_cost->l1_cache_size,
3272 global_options.x_param_values,
3273 global_options_set.x_param_values);
3274 maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
3275 rs6000_cost->cache_line_size,
3276 global_options.x_param_values,
3277 global_options_set.x_param_values);
3278 maybe_set_param_value (PARAM_L2_CACHE_SIZE, rs6000_cost->l2_cache_size,
3279 global_options.x_param_values,
3280 global_options_set.x_param_values);
3282 /* If using typedef char *va_list, signal that
3283 __builtin_va_start (&ap, 0) can be optimized to
3284 ap = __builtin_next_arg (0). */
3285 if (DEFAULT_ABI != ABI_V4)
3286 targetm.expand_builtin_va_start = NULL;
3289 /* Set up single/double float flags.
3290 If TARGET_HARD_FLOAT is set, but neither single or double is set,
3291 then set both flags. */
3292 if (TARGET_HARD_FLOAT && TARGET_FPRS
3293 && rs6000_single_float == 0 && rs6000_double_float == 0)
3294 rs6000_single_float = rs6000_double_float = 1;
3296 /* Reset single and double FP flags if target is E500. */
3299 rs6000_single_float = rs6000_double_float = 0;
3300 if (TARGET_E500_SINGLE)
3301 rs6000_single_float = 1;
3302 if (TARGET_E500_DOUBLE)
3303 rs6000_single_float = rs6000_double_float = 1;
3306 if (main_target_opt)
3308 if (main_target_opt->x_rs6000_single_float != rs6000_single_float)
3309 error ("target attribute or pragma changes single precision floating "
3311 if (main_target_opt->x_rs6000_double_float != rs6000_double_float)
3312 error ("target attribute or pragma changes double precision floating "
3316 /* If not explicitly specified via option, decide whether to generate indexed
3317 load/store instructions. */
3318 if (TARGET_AVOID_XFORM == -1)
3319 /* Avoid indexed addressing when targeting Power6 in order to avoid the
3320 DERAT mispredict penalty. However the LVE and STVE altivec instructions
3321 need indexed accesses and the type used is the scalar type of the element
3322 being loaded or stored. */
3323 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB
3324 && !TARGET_ALTIVEC);
3326 /* Set the -mrecip options. */
3327 if (rs6000_recip_name)
3329 char *p = ASTRDUP (rs6000_recip_name);
3331 unsigned int mask, i;
3334 while ((q = strtok (p, ",")) != NULL)
3345 if (!strcmp (q, "default"))
3346 mask = ((TARGET_RECIP_PRECISION)
3347 ? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION);
3350 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
3351 if (!strcmp (q, recip_options[i].string))
3353 mask = recip_options[i].mask;
3357 if (i == ARRAY_SIZE (recip_options))
3359 error ("unknown option for -mrecip=%s", q);
3367 rs6000_recip_control &= ~mask;
3369 rs6000_recip_control |= mask;
3373 rs6000_init_hard_regno_mode_ok (global_init_p);
3375 /* Save the initial options in case the user does function specific options */
3377 target_option_default_node = target_option_current_node
3378 = build_target_option_node ();
3383 /* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to
3384 define the target cpu type. */
3387 rs6000_option_override (void)
3389 (void) rs6000_option_override_internal (true);
3393 /* Implement targetm.vectorize.builtin_mask_for_load. */
3395 rs6000_builtin_mask_for_load (void)
3397 if (TARGET_ALTIVEC || TARGET_VSX)
3398 return altivec_builtin_mask_for_load;
3403 /* Implement LOOP_ALIGN. */
3405 rs6000_loop_align (rtx label)
3410 /* Don't override loop alignment if -falign-loops was specified. */
3411 if (!can_override_loop_align)
3412 return align_loops_log;
3414 bb = BLOCK_FOR_INSN (label);
3415 ninsns = num_loop_insns(bb->loop_father);
3417 /* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */
3418 if (ninsns > 4 && ninsns <= 8
3419 && (rs6000_cpu == PROCESSOR_POWER4
3420 || rs6000_cpu == PROCESSOR_POWER5
3421 || rs6000_cpu == PROCESSOR_POWER6
3422 || rs6000_cpu == PROCESSOR_POWER7))
3425 return align_loops_log;
3428 /* Implement TARGET_LOOP_ALIGN_MAX_SKIP. */
3430 rs6000_loop_align_max_skip (rtx label)
3432 return (1 << rs6000_loop_align (label)) - 1;
3435 /* Implement targetm.vectorize.builtin_conversion.
3436 Returns a decl of a function that implements conversion of an integer vector
3437 into a floating-point vector, or vice-versa. DEST_TYPE is the
3438 destination type and SRC_TYPE the source type of the conversion.
3439 Return NULL_TREE if it is not available. */
3441 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
3443 enum tree_code code = (enum tree_code) tcode;
3447 case FIX_TRUNC_EXPR:
3448 switch (TYPE_MODE (dest_type))
3451 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3454 return TYPE_UNSIGNED (dest_type)
3455 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
3456 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
3459 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3462 return TYPE_UNSIGNED (dest_type)
3463 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
3464 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
3471 switch (TYPE_MODE (src_type))
3474 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3477 return TYPE_UNSIGNED (src_type)
3478 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
3479 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
3482 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3485 return TYPE_UNSIGNED (src_type)
3486 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
3487 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
3498 /* Implement targetm.vectorize.builtin_mul_widen_even. */
3500 rs6000_builtin_mul_widen_even (tree type)
3502 if (!TARGET_ALTIVEC)
3505 switch (TYPE_MODE (type))
3508 return TYPE_UNSIGNED (type)
3509 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
3510 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
3513 return TYPE_UNSIGNED (type)
3514 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
3515 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
3521 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
3523 rs6000_builtin_mul_widen_odd (tree type)
3525 if (!TARGET_ALTIVEC)
3528 switch (TYPE_MODE (type))
3531 return TYPE_UNSIGNED (type)
3532 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
3533 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
3536 return TYPE_UNSIGNED (type)
3537 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
3538 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
3545 /* Return true iff, data reference of TYPE can reach vector alignment (16)
3546 after applying N number of iterations. This routine does not determine
3547 how may iterations are required to reach desired alignment. */
3550 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3557 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3560 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3570 /* Assuming that all other types are naturally aligned. CHECKME! */
3575 /* Return true if the vector misalignment factor is supported by the
3578 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3585 /* Return if movmisalign pattern is not supported for this mode. */
3586 if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing)
3589 if (misalignment == -1)
3591 /* Misalignment factor is unknown at compile time but we know
3592 it's word aligned. */
3593 if (rs6000_vector_alignment_reachable (type, is_packed))
3595 int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type));
3597 if (element_size == 64 || element_size == 32)
3604 /* VSX supports word-aligned vector. */
3605 if (misalignment % 4 == 0)
3611 /* Implement targetm.vectorize.builtin_vec_perm. */
3613 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
3615 tree inner_type = TREE_TYPE (type);
3616 bool uns_p = TYPE_UNSIGNED (inner_type);
3619 *mask_element_type = unsigned_char_type_node;
3621 switch (TYPE_MODE (type))
3625 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI_UNS]
3626 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI]);
3631 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI_UNS]
3632 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI]);
3637 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI_UNS]
3638 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI]);
3642 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
3646 if (!TARGET_ALLOW_DF_PERMUTE)
3649 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DF];
3653 if (!TARGET_ALLOW_DF_PERMUTE)
3657 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI_UNS]
3658 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI]);
3670 /* Implement targetm.vectorize.builtin_vectorization_cost. */
3672 rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
3673 tree vectype, int misalign)
3677 switch (type_of_cost)
3687 case cond_branch_not_taken:
3691 case cond_branch_taken:
3694 case unaligned_load:
3695 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3697 elements = TYPE_VECTOR_SUBPARTS (vectype);
3699 /* Double word aligned. */
3707 /* Double word aligned. */
3711 /* Unknown misalignment. */
3724 /* Misaligned loads are not supported. */
3729 case unaligned_store:
3730 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3732 elements = TYPE_VECTOR_SUBPARTS (vectype);
3734 /* Double word aligned. */
3742 /* Double word aligned. */
3746 /* Unknown misalignment. */
3759 /* Misaligned stores are not supported. */
3769 /* Implement targetm.vectorize.preferred_simd_mode. */
3771 static enum machine_mode
3772 rs6000_preferred_simd_mode (enum machine_mode mode)
3781 if (TARGET_ALTIVEC || TARGET_VSX)
3805 if (TARGET_PAIRED_FLOAT
3811 /* Handle generic options of the form -mfoo=yes/no.
3812 NAME is the option name.
3813 VALUE is the option value.
3814 FLAG is the pointer to the flag where to store a 1 or 0, depending on
3815 whether the option value is 'yes' or 'no' respectively. */
3817 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
3821 else if (!strcmp (value, "yes"))
3823 else if (!strcmp (value, "no"))
3826 error ("unknown -m%s= option specified: '%s'", name, value);
3829 /* Implement TARGET_OPTION_INIT_STRUCT. */
3832 rs6000_option_init_struct (struct gcc_options *opts)
3834 if (DEFAULT_ABI == ABI_DARWIN)
3835 /* The Darwin libraries never set errno, so we might as well
3836 avoid calling them when that's the only reason we would. */
3837 opts->x_flag_errno_math = 0;
3839 /* Enable section anchors by default. */
3841 opts->x_flag_section_anchors = 1;
3844 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */
3847 rs6000_option_default_params (void)
3849 /* Double growth factor to counter reduced min jump length. */
3850 set_default_param_value (PARAM_MAX_GROW_COPY_BB_INSNS, 16);
3853 static enum fpu_type_t
3854 rs6000_parse_fpu_option (const char *option)
3856 if (!strcmp("none", option)) return FPU_NONE;
3857 if (!strcmp("sp_lite", option)) return FPU_SF_LITE;
3858 if (!strcmp("dp_lite", option)) return FPU_DF_LITE;
3859 if (!strcmp("sp_full", option)) return FPU_SF_FULL;
3860 if (!strcmp("dp_full", option)) return FPU_DF_FULL;
3861 error("unknown value %s for -mfpu", option);
3866 /* Handler for the Mathematical Acceleration Subsystem (mass) interface to a
3867 library with vectorized intrinsics. */
3870 rs6000_builtin_vectorized_libmass (tree fndecl, tree type_out, tree type_in)
3873 const char *suffix = NULL;
3874 tree fntype, new_fndecl, bdecl = NULL_TREE;
3877 enum machine_mode el_mode, in_mode;
3880 /* Libmass is suitable for unsafe math only as it does not correctly support
3881 parts of IEEE with the required precision such as denormals. Only support
3882 it if we have VSX to use the simd d2 or f4 functions.
3883 XXX: Add variable length support. */
3884 if (!flag_unsafe_math_optimizations || !TARGET_VSX)
3887 el_mode = TYPE_MODE (TREE_TYPE (type_out));
3888 n = TYPE_VECTOR_SUBPARTS (type_out);
3889 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3890 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3891 if (el_mode != in_mode
3895 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
3897 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3900 case BUILT_IN_ATAN2:
3901 case BUILT_IN_HYPOT:
3907 case BUILT_IN_ACOSH:
3909 case BUILT_IN_ASINH:
3911 case BUILT_IN_ATANH:
3919 case BUILT_IN_EXPM1:
3920 case BUILT_IN_LGAMMA:
3921 case BUILT_IN_LOG10:
3922 case BUILT_IN_LOG1P:
3930 bdecl = implicit_built_in_decls[fn];
3931 suffix = "d2"; /* pow -> powd2 */
3932 if (el_mode != DFmode
3937 case BUILT_IN_ATAN2F:
3938 case BUILT_IN_HYPOTF:
3943 case BUILT_IN_ACOSF:
3944 case BUILT_IN_ACOSHF:
3945 case BUILT_IN_ASINF:
3946 case BUILT_IN_ASINHF:
3947 case BUILT_IN_ATANF:
3948 case BUILT_IN_ATANHF:
3949 case BUILT_IN_CBRTF:
3951 case BUILT_IN_COSHF:
3953 case BUILT_IN_ERFCF:
3954 case BUILT_IN_EXP2F:
3956 case BUILT_IN_EXPM1F:
3957 case BUILT_IN_LGAMMAF:
3958 case BUILT_IN_LOG10F:
3959 case BUILT_IN_LOG1PF:
3960 case BUILT_IN_LOG2F:
3963 case BUILT_IN_SINHF: