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"
63 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
66 #include "gstab.h" /* for N_SLINE */
69 #ifndef TARGET_NO_PROTOTYPE
70 #define TARGET_NO_PROTOTYPE 0
73 #define min(A,B) ((A) < (B) ? (A) : (B))
74 #define max(A,B) ((A) > (B) ? (A) : (B))
76 /* Structure used to define the rs6000 stack */
77 typedef struct rs6000_stack {
78 int reload_completed; /* stack info won't change from here on */
79 int first_gp_reg_save; /* first callee saved GP register used */
80 int first_fp_reg_save; /* first callee saved FP register used */
81 int first_altivec_reg_save; /* first callee saved AltiVec register used */
82 int lr_save_p; /* true if the link reg needs to be saved */
83 int cr_save_p; /* true if the CR reg needs to be saved */
84 unsigned int vrsave_mask; /* mask of vec registers to save */
85 int push_p; /* true if we need to allocate stack space */
86 int calls_p; /* true if the function makes any calls */
87 int world_save_p; /* true if we're saving *everything*:
88 r13-r31, cr, f14-f31, vrsave, v20-v31 */
89 enum rs6000_abi abi; /* which ABI to use */
90 int gp_save_offset; /* offset to save GP regs from initial SP */
91 int fp_save_offset; /* offset to save FP regs from initial SP */
92 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
93 int lr_save_offset; /* offset to save LR from initial SP */
94 int cr_save_offset; /* offset to save CR from initial SP */
95 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
96 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
97 int varargs_save_offset; /* offset to save the varargs registers */
98 int ehrd_offset; /* offset to EH return data */
99 int reg_size; /* register size (4 or 8) */
100 HOST_WIDE_INT vars_size; /* variable save area size */
101 int parm_size; /* outgoing parameter size */
102 int save_size; /* save area size */
103 int fixed_size; /* fixed size of stack frame */
104 int gp_size; /* size of saved GP registers */
105 int fp_size; /* size of saved FP registers */
106 int altivec_size; /* size of saved AltiVec registers */
107 int cr_size; /* size to hold CR if not in save_size */
108 int vrsave_size; /* size to hold VRSAVE if not in save_size */
109 int altivec_padding_size; /* size of altivec alignment padding if
111 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
112 int spe_padding_size;
113 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
114 int spe_64bit_regs_used;
118 /* A C structure for machine-specific, per-function data.
119 This is added to the cfun structure. */
120 typedef struct GTY(()) machine_function
122 /* Some local-dynamic symbol. */
123 const char *some_ld_name;
124 /* Whether the instruction chain has been scanned already. */
125 int insn_chain_scanned_p;
126 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
127 int ra_needs_full_frame;
128 /* Flags if __builtin_return_address (0) was used. */
130 /* Cache lr_save_p after expansion of builtin_eh_return. */
132 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
133 varargs save area. */
134 HOST_WIDE_INT varargs_save_offset;
135 /* Temporary stack slot to use for SDmode copies. This slot is
136 64-bits wide and is allocated early enough so that the offset
137 does not overflow the 16-bit load/store offset field. */
138 rtx sdmode_stack_slot;
141 /* Target cpu type */
143 struct rs6000_cpu_select rs6000_select[3] =
145 /* switch name, tune arch */
146 { (const char *)0, "--with-cpu=", 1, 1 },
147 { (const char *)0, "-mcpu=", 1, 1 },
148 { (const char *)0, "-mtune=", 1, 0 },
151 /* String variables to hold the various options. */
152 static const char *rs6000_sched_insert_nops_str;
153 static const char *rs6000_sched_costly_dep_str;
154 static const char *rs6000_recip_name;
157 static const char *rs6000_abi_name;
158 static const char *rs6000_sdata_name;
161 /* Support targetm.vectorize.builtin_mask_for_load. */
162 static GTY(()) tree altivec_builtin_mask_for_load;
164 /* Set to nonzero once AIX common-mode calls have been defined. */
165 static GTY(()) int common_mode_defined;
167 /* Label number of label created for -mrelocatable, to call to so we can
168 get the address of the GOT section */
169 static int rs6000_pic_labelno;
172 /* Counter for labels which are to be placed in .fixup. */
173 int fixuplabelno = 0;
176 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
179 /* Specify the machine mode that pointers have. After generation of rtl, the
180 compiler makes no further distinction between pointers and any other objects
181 of this machine mode. The type is unsigned since not all things that
182 include rs6000.h also include machmode.h. */
183 unsigned rs6000_pmode;
185 /* Width in bits of a pointer. */
186 unsigned rs6000_pointer_size;
188 #ifdef HAVE_AS_GNU_ATTRIBUTE
189 /* Flag whether floating point values have been passed/returned. */
190 static bool rs6000_passes_float;
191 /* Flag whether vector values have been passed/returned. */
192 static bool rs6000_passes_vector;
193 /* Flag whether small (<= 8 byte) structures have been returned. */
194 static bool rs6000_returns_struct;
197 /* Value is TRUE if register/mode pair is acceptable. */
198 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
200 /* Maximum number of registers needed for a given register class and mode. */
201 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
203 /* How many registers are needed for a given register and mode. */
204 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
206 /* Map register number to register class. */
207 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
209 /* Reload functions based on the type and the vector unit. */
210 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
212 /* Built in types. */
213 tree rs6000_builtin_types[RS6000_BTI_MAX];
214 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
216 /* Flag to say the TOC is initialized */
218 char toc_label_name[10];
220 /* Cached value of rs6000_variable_issue. This is cached in
221 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
222 static short cached_can_issue_more;
224 static GTY(()) section *read_only_data_section;
225 static GTY(()) section *private_data_section;
226 static GTY(()) section *read_only_private_data_section;
227 static GTY(()) section *sdata2_section;
228 static GTY(()) section *toc_section;
230 /* True for any options that were explicitly set. */
232 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
233 bool alignment; /* True if -malign- was used. */
234 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
235 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
236 bool spe; /* True if -mspe= was used. */
237 bool float_gprs; /* True if -mfloat-gprs= was used. */
238 bool long_double; /* True if -mlong-double- was used. */
239 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
240 bool vrsave; /* True if -mvrsave was used. */
241 bool cmodel; /* True if -mcmodel was used. */
242 } rs6000_explicit_options;
244 struct builtin_description
246 /* mask is not const because we're going to alter it below. This
247 nonsense will go away when we rewrite the -march infrastructure
248 to give us more target flag bits. */
250 const enum insn_code icode;
251 const char *const name;
252 const enum rs6000_builtins code;
255 /* Describe the vector unit used for modes. */
256 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
257 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
259 /* Register classes for various constraints that are based on the target
261 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
263 /* Describe the alignment of a vector. */
264 int rs6000_vector_align[NUM_MACHINE_MODES];
266 /* Map selected modes to types for builtins. */
267 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
269 /* What modes to automatically generate reciprocal divide estimate (fre) and
270 reciprocal sqrt (frsqrte) for. */
271 unsigned char rs6000_recip_bits[MAX_MACHINE_MODE];
273 /* Masks to determine which reciprocal esitmate instructions to generate
275 enum rs6000_recip_mask {
276 RECIP_SF_DIV = 0x001, /* Use divide estimate */
277 RECIP_DF_DIV = 0x002,
278 RECIP_V4SF_DIV = 0x004,
279 RECIP_V2DF_DIV = 0x008,
281 RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */
282 RECIP_DF_RSQRT = 0x020,
283 RECIP_V4SF_RSQRT = 0x040,
284 RECIP_V2DF_RSQRT = 0x080,
286 /* Various combination of flags for -mrecip=xxx. */
288 RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
289 | RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT
290 | RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT),
292 RECIP_HIGH_PRECISION = RECIP_ALL,
294 /* On low precision machines like the power5, don't enable double precision
295 reciprocal square root estimate, since it isn't accurate enough. */
296 RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT))
299 /* -mrecip options. */
302 const char *string; /* option name */
303 unsigned int mask; /* mask bits to set */
304 } recip_options[] = {
305 { "all", RECIP_ALL },
306 { "none", RECIP_NONE },
307 { "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
309 { "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) },
310 { "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) },
311 { "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT
312 | RECIP_V2DF_RSQRT) },
313 { "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) },
314 { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) },
317 /* 2 argument gen function typedef. */
318 typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx);
321 /* Target cpu costs. */
323 struct processor_costs {
324 const int mulsi; /* cost of SImode multiplication. */
325 const int mulsi_const; /* cost of SImode multiplication by constant. */
326 const int mulsi_const9; /* cost of SImode mult by short constant. */
327 const int muldi; /* cost of DImode multiplication. */
328 const int divsi; /* cost of SImode division. */
329 const int divdi; /* cost of DImode division. */
330 const int fp; /* cost of simple SFmode and DFmode insns. */
331 const int dmul; /* cost of DFmode multiplication (and fmadd). */
332 const int sdiv; /* cost of SFmode division (fdivs). */
333 const int ddiv; /* cost of DFmode division (fdiv). */
334 const int cache_line_size; /* cache line size in bytes. */
335 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
336 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
337 const int simultaneous_prefetches; /* number of parallel prefetch
341 const struct processor_costs *rs6000_cost;
343 /* Processor costs (relative to an add) */
345 /* Instruction size costs on 32bit processors. */
347 struct processor_costs size32_cost = {
348 COSTS_N_INSNS (1), /* mulsi */
349 COSTS_N_INSNS (1), /* mulsi_const */
350 COSTS_N_INSNS (1), /* mulsi_const9 */
351 COSTS_N_INSNS (1), /* muldi */
352 COSTS_N_INSNS (1), /* divsi */
353 COSTS_N_INSNS (1), /* divdi */
354 COSTS_N_INSNS (1), /* fp */
355 COSTS_N_INSNS (1), /* dmul */
356 COSTS_N_INSNS (1), /* sdiv */
357 COSTS_N_INSNS (1), /* ddiv */
364 /* Instruction size costs on 64bit processors. */
366 struct processor_costs size64_cost = {
367 COSTS_N_INSNS (1), /* mulsi */
368 COSTS_N_INSNS (1), /* mulsi_const */
369 COSTS_N_INSNS (1), /* mulsi_const9 */
370 COSTS_N_INSNS (1), /* muldi */
371 COSTS_N_INSNS (1), /* divsi */
372 COSTS_N_INSNS (1), /* divdi */
373 COSTS_N_INSNS (1), /* fp */
374 COSTS_N_INSNS (1), /* dmul */
375 COSTS_N_INSNS (1), /* sdiv */
376 COSTS_N_INSNS (1), /* ddiv */
383 /* Instruction costs on RIOS1 processors. */
385 struct processor_costs rios1_cost = {
386 COSTS_N_INSNS (5), /* mulsi */
387 COSTS_N_INSNS (4), /* mulsi_const */
388 COSTS_N_INSNS (3), /* mulsi_const9 */
389 COSTS_N_INSNS (5), /* muldi */
390 COSTS_N_INSNS (19), /* divsi */
391 COSTS_N_INSNS (19), /* divdi */
392 COSTS_N_INSNS (2), /* fp */
393 COSTS_N_INSNS (2), /* dmul */
394 COSTS_N_INSNS (19), /* sdiv */
395 COSTS_N_INSNS (19), /* ddiv */
396 128, /* cache line size */
402 /* Instruction costs on RIOS2 processors. */
404 struct processor_costs rios2_cost = {
405 COSTS_N_INSNS (2), /* mulsi */
406 COSTS_N_INSNS (2), /* mulsi_const */
407 COSTS_N_INSNS (2), /* mulsi_const9 */
408 COSTS_N_INSNS (2), /* muldi */
409 COSTS_N_INSNS (13), /* divsi */
410 COSTS_N_INSNS (13), /* divdi */
411 COSTS_N_INSNS (2), /* fp */
412 COSTS_N_INSNS (2), /* dmul */
413 COSTS_N_INSNS (17), /* sdiv */
414 COSTS_N_INSNS (17), /* ddiv */
415 256, /* cache line size */
421 /* Instruction costs on RS64A processors. */
423 struct processor_costs rs64a_cost = {
424 COSTS_N_INSNS (20), /* mulsi */
425 COSTS_N_INSNS (12), /* mulsi_const */
426 COSTS_N_INSNS (8), /* mulsi_const9 */
427 COSTS_N_INSNS (34), /* muldi */
428 COSTS_N_INSNS (65), /* divsi */
429 COSTS_N_INSNS (67), /* divdi */
430 COSTS_N_INSNS (4), /* fp */
431 COSTS_N_INSNS (4), /* dmul */
432 COSTS_N_INSNS (31), /* sdiv */
433 COSTS_N_INSNS (31), /* ddiv */
434 128, /* cache line size */
440 /* Instruction costs on MPCCORE processors. */
442 struct processor_costs mpccore_cost = {
443 COSTS_N_INSNS (2), /* mulsi */
444 COSTS_N_INSNS (2), /* mulsi_const */
445 COSTS_N_INSNS (2), /* mulsi_const9 */
446 COSTS_N_INSNS (2), /* muldi */
447 COSTS_N_INSNS (6), /* divsi */
448 COSTS_N_INSNS (6), /* divdi */
449 COSTS_N_INSNS (4), /* fp */
450 COSTS_N_INSNS (5), /* dmul */
451 COSTS_N_INSNS (10), /* sdiv */
452 COSTS_N_INSNS (17), /* ddiv */
453 32, /* cache line size */
459 /* Instruction costs on PPC403 processors. */
461 struct processor_costs ppc403_cost = {
462 COSTS_N_INSNS (4), /* mulsi */
463 COSTS_N_INSNS (4), /* mulsi_const */
464 COSTS_N_INSNS (4), /* mulsi_const9 */
465 COSTS_N_INSNS (4), /* muldi */
466 COSTS_N_INSNS (33), /* divsi */
467 COSTS_N_INSNS (33), /* divdi */
468 COSTS_N_INSNS (11), /* fp */
469 COSTS_N_INSNS (11), /* dmul */
470 COSTS_N_INSNS (11), /* sdiv */
471 COSTS_N_INSNS (11), /* ddiv */
472 32, /* cache line size */
478 /* Instruction costs on PPC405 processors. */
480 struct processor_costs ppc405_cost = {
481 COSTS_N_INSNS (5), /* mulsi */
482 COSTS_N_INSNS (4), /* mulsi_const */
483 COSTS_N_INSNS (3), /* mulsi_const9 */
484 COSTS_N_INSNS (5), /* muldi */
485 COSTS_N_INSNS (35), /* divsi */
486 COSTS_N_INSNS (35), /* divdi */
487 COSTS_N_INSNS (11), /* fp */
488 COSTS_N_INSNS (11), /* dmul */
489 COSTS_N_INSNS (11), /* sdiv */
490 COSTS_N_INSNS (11), /* ddiv */
491 32, /* cache line size */
497 /* Instruction costs on PPC440 processors. */
499 struct processor_costs ppc440_cost = {
500 COSTS_N_INSNS (3), /* mulsi */
501 COSTS_N_INSNS (2), /* mulsi_const */
502 COSTS_N_INSNS (2), /* mulsi_const9 */
503 COSTS_N_INSNS (3), /* muldi */
504 COSTS_N_INSNS (34), /* divsi */
505 COSTS_N_INSNS (34), /* divdi */
506 COSTS_N_INSNS (5), /* fp */
507 COSTS_N_INSNS (5), /* dmul */
508 COSTS_N_INSNS (19), /* sdiv */
509 COSTS_N_INSNS (33), /* ddiv */
510 32, /* cache line size */
516 /* Instruction costs on PPC476 processors. */
518 struct processor_costs ppc476_cost = {
519 COSTS_N_INSNS (4), /* mulsi */
520 COSTS_N_INSNS (4), /* mulsi_const */
521 COSTS_N_INSNS (4), /* mulsi_const9 */
522 COSTS_N_INSNS (4), /* muldi */
523 COSTS_N_INSNS (11), /* divsi */
524 COSTS_N_INSNS (11), /* divdi */
525 COSTS_N_INSNS (6), /* fp */
526 COSTS_N_INSNS (6), /* dmul */
527 COSTS_N_INSNS (19), /* sdiv */
528 COSTS_N_INSNS (33), /* ddiv */
529 32, /* l1 cache line size */
535 /* Instruction costs on PPC601 processors. */
537 struct processor_costs ppc601_cost = {
538 COSTS_N_INSNS (5), /* mulsi */
539 COSTS_N_INSNS (5), /* mulsi_const */
540 COSTS_N_INSNS (5), /* mulsi_const9 */
541 COSTS_N_INSNS (5), /* muldi */
542 COSTS_N_INSNS (36), /* divsi */
543 COSTS_N_INSNS (36), /* divdi */
544 COSTS_N_INSNS (4), /* fp */
545 COSTS_N_INSNS (5), /* dmul */
546 COSTS_N_INSNS (17), /* sdiv */
547 COSTS_N_INSNS (31), /* ddiv */
548 32, /* cache line size */
554 /* Instruction costs on PPC603 processors. */
556 struct processor_costs ppc603_cost = {
557 COSTS_N_INSNS (5), /* mulsi */
558 COSTS_N_INSNS (3), /* mulsi_const */
559 COSTS_N_INSNS (2), /* mulsi_const9 */
560 COSTS_N_INSNS (5), /* muldi */
561 COSTS_N_INSNS (37), /* divsi */
562 COSTS_N_INSNS (37), /* divdi */
563 COSTS_N_INSNS (3), /* fp */
564 COSTS_N_INSNS (4), /* dmul */
565 COSTS_N_INSNS (18), /* sdiv */
566 COSTS_N_INSNS (33), /* ddiv */
567 32, /* cache line size */
573 /* Instruction costs on PPC604 processors. */
575 struct processor_costs ppc604_cost = {
576 COSTS_N_INSNS (4), /* mulsi */
577 COSTS_N_INSNS (4), /* mulsi_const */
578 COSTS_N_INSNS (4), /* mulsi_const9 */
579 COSTS_N_INSNS (4), /* muldi */
580 COSTS_N_INSNS (20), /* divsi */
581 COSTS_N_INSNS (20), /* divdi */
582 COSTS_N_INSNS (3), /* fp */
583 COSTS_N_INSNS (3), /* dmul */
584 COSTS_N_INSNS (18), /* sdiv */
585 COSTS_N_INSNS (32), /* ddiv */
586 32, /* cache line size */
592 /* Instruction costs on PPC604e processors. */
594 struct processor_costs ppc604e_cost = {
595 COSTS_N_INSNS (2), /* mulsi */
596 COSTS_N_INSNS (2), /* mulsi_const */
597 COSTS_N_INSNS (2), /* mulsi_const9 */
598 COSTS_N_INSNS (2), /* muldi */
599 COSTS_N_INSNS (20), /* divsi */
600 COSTS_N_INSNS (20), /* divdi */
601 COSTS_N_INSNS (3), /* fp */
602 COSTS_N_INSNS (3), /* dmul */
603 COSTS_N_INSNS (18), /* sdiv */
604 COSTS_N_INSNS (32), /* ddiv */
605 32, /* cache line size */
611 /* Instruction costs on PPC620 processors. */
613 struct processor_costs ppc620_cost = {
614 COSTS_N_INSNS (5), /* mulsi */
615 COSTS_N_INSNS (4), /* mulsi_const */
616 COSTS_N_INSNS (3), /* mulsi_const9 */
617 COSTS_N_INSNS (7), /* muldi */
618 COSTS_N_INSNS (21), /* divsi */
619 COSTS_N_INSNS (37), /* divdi */
620 COSTS_N_INSNS (3), /* fp */
621 COSTS_N_INSNS (3), /* dmul */
622 COSTS_N_INSNS (18), /* sdiv */
623 COSTS_N_INSNS (32), /* ddiv */
624 128, /* cache line size */
630 /* Instruction costs on PPC630 processors. */
632 struct processor_costs ppc630_cost = {
633 COSTS_N_INSNS (5), /* mulsi */
634 COSTS_N_INSNS (4), /* mulsi_const */
635 COSTS_N_INSNS (3), /* mulsi_const9 */
636 COSTS_N_INSNS (7), /* muldi */
637 COSTS_N_INSNS (21), /* divsi */
638 COSTS_N_INSNS (37), /* divdi */
639 COSTS_N_INSNS (3), /* fp */
640 COSTS_N_INSNS (3), /* dmul */
641 COSTS_N_INSNS (17), /* sdiv */
642 COSTS_N_INSNS (21), /* ddiv */
643 128, /* cache line size */
649 /* Instruction costs on Cell processor. */
650 /* COSTS_N_INSNS (1) ~ one add. */
652 struct processor_costs ppccell_cost = {
653 COSTS_N_INSNS (9/2)+2, /* mulsi */
654 COSTS_N_INSNS (6/2), /* mulsi_const */
655 COSTS_N_INSNS (6/2), /* mulsi_const9 */
656 COSTS_N_INSNS (15/2)+2, /* muldi */
657 COSTS_N_INSNS (38/2), /* divsi */
658 COSTS_N_INSNS (70/2), /* divdi */
659 COSTS_N_INSNS (10/2), /* fp */
660 COSTS_N_INSNS (10/2), /* dmul */
661 COSTS_N_INSNS (74/2), /* sdiv */
662 COSTS_N_INSNS (74/2), /* ddiv */
663 128, /* cache line size */
669 /* Instruction costs on PPC750 and PPC7400 processors. */
671 struct processor_costs ppc750_cost = {
672 COSTS_N_INSNS (5), /* mulsi */
673 COSTS_N_INSNS (3), /* mulsi_const */
674 COSTS_N_INSNS (2), /* mulsi_const9 */
675 COSTS_N_INSNS (5), /* muldi */
676 COSTS_N_INSNS (17), /* divsi */
677 COSTS_N_INSNS (17), /* divdi */
678 COSTS_N_INSNS (3), /* fp */
679 COSTS_N_INSNS (3), /* dmul */
680 COSTS_N_INSNS (17), /* sdiv */
681 COSTS_N_INSNS (31), /* ddiv */
682 32, /* cache line size */
688 /* Instruction costs on PPC7450 processors. */
690 struct processor_costs ppc7450_cost = {
691 COSTS_N_INSNS (4), /* mulsi */
692 COSTS_N_INSNS (3), /* mulsi_const */
693 COSTS_N_INSNS (3), /* mulsi_const9 */
694 COSTS_N_INSNS (4), /* muldi */
695 COSTS_N_INSNS (23), /* divsi */
696 COSTS_N_INSNS (23), /* divdi */
697 COSTS_N_INSNS (5), /* fp */
698 COSTS_N_INSNS (5), /* dmul */
699 COSTS_N_INSNS (21), /* sdiv */
700 COSTS_N_INSNS (35), /* ddiv */
701 32, /* cache line size */
707 /* Instruction costs on PPC8540 processors. */
709 struct processor_costs ppc8540_cost = {
710 COSTS_N_INSNS (4), /* mulsi */
711 COSTS_N_INSNS (4), /* mulsi_const */
712 COSTS_N_INSNS (4), /* mulsi_const9 */
713 COSTS_N_INSNS (4), /* muldi */
714 COSTS_N_INSNS (19), /* divsi */
715 COSTS_N_INSNS (19), /* divdi */
716 COSTS_N_INSNS (4), /* fp */
717 COSTS_N_INSNS (4), /* dmul */
718 COSTS_N_INSNS (29), /* sdiv */
719 COSTS_N_INSNS (29), /* ddiv */
720 32, /* cache line size */
723 1, /* prefetch streams /*/
726 /* Instruction costs on E300C2 and E300C3 cores. */
728 struct processor_costs ppce300c2c3_cost = {
729 COSTS_N_INSNS (4), /* mulsi */
730 COSTS_N_INSNS (4), /* mulsi_const */
731 COSTS_N_INSNS (4), /* mulsi_const9 */
732 COSTS_N_INSNS (4), /* muldi */
733 COSTS_N_INSNS (19), /* divsi */
734 COSTS_N_INSNS (19), /* divdi */
735 COSTS_N_INSNS (3), /* fp */
736 COSTS_N_INSNS (4), /* dmul */
737 COSTS_N_INSNS (18), /* sdiv */
738 COSTS_N_INSNS (33), /* ddiv */
742 1, /* prefetch streams /*/
745 /* Instruction costs on PPCE500MC processors. */
747 struct processor_costs ppce500mc_cost = {
748 COSTS_N_INSNS (4), /* mulsi */
749 COSTS_N_INSNS (4), /* mulsi_const */
750 COSTS_N_INSNS (4), /* mulsi_const9 */
751 COSTS_N_INSNS (4), /* muldi */
752 COSTS_N_INSNS (14), /* divsi */
753 COSTS_N_INSNS (14), /* divdi */
754 COSTS_N_INSNS (8), /* fp */
755 COSTS_N_INSNS (10), /* dmul */
756 COSTS_N_INSNS (36), /* sdiv */
757 COSTS_N_INSNS (66), /* ddiv */
758 64, /* cache line size */
761 1, /* prefetch streams /*/
764 /* Instruction costs on PPCE500MC64 processors. */
766 struct processor_costs ppce500mc64_cost = {
767 COSTS_N_INSNS (4), /* mulsi */
768 COSTS_N_INSNS (4), /* mulsi_const */
769 COSTS_N_INSNS (4), /* mulsi_const9 */
770 COSTS_N_INSNS (4), /* muldi */
771 COSTS_N_INSNS (14), /* divsi */
772 COSTS_N_INSNS (14), /* divdi */
773 COSTS_N_INSNS (4), /* fp */
774 COSTS_N_INSNS (10), /* dmul */
775 COSTS_N_INSNS (36), /* sdiv */
776 COSTS_N_INSNS (66), /* ddiv */
777 64, /* cache line size */
780 1, /* prefetch streams /*/
783 /* Instruction costs on AppliedMicro Titan processors. */
785 struct processor_costs titan_cost = {
786 COSTS_N_INSNS (5), /* mulsi */
787 COSTS_N_INSNS (5), /* mulsi_const */
788 COSTS_N_INSNS (5), /* mulsi_const9 */
789 COSTS_N_INSNS (5), /* muldi */
790 COSTS_N_INSNS (18), /* divsi */
791 COSTS_N_INSNS (18), /* divdi */
792 COSTS_N_INSNS (10), /* fp */
793 COSTS_N_INSNS (10), /* dmul */
794 COSTS_N_INSNS (46), /* sdiv */
795 COSTS_N_INSNS (72), /* ddiv */
796 32, /* cache line size */
799 1, /* prefetch streams /*/
802 /* Instruction costs on POWER4 and POWER5 processors. */
804 struct processor_costs power4_cost = {
805 COSTS_N_INSNS (3), /* mulsi */
806 COSTS_N_INSNS (2), /* mulsi_const */
807 COSTS_N_INSNS (2), /* mulsi_const9 */
808 COSTS_N_INSNS (4), /* muldi */
809 COSTS_N_INSNS (18), /* divsi */
810 COSTS_N_INSNS (34), /* divdi */
811 COSTS_N_INSNS (3), /* fp */
812 COSTS_N_INSNS (3), /* dmul */
813 COSTS_N_INSNS (17), /* sdiv */
814 COSTS_N_INSNS (17), /* ddiv */
815 128, /* cache line size */
818 8, /* prefetch streams /*/
821 /* Instruction costs on POWER6 processors. */
823 struct processor_costs power6_cost = {
824 COSTS_N_INSNS (8), /* mulsi */
825 COSTS_N_INSNS (8), /* mulsi_const */
826 COSTS_N_INSNS (8), /* mulsi_const9 */
827 COSTS_N_INSNS (8), /* muldi */
828 COSTS_N_INSNS (22), /* divsi */
829 COSTS_N_INSNS (28), /* divdi */
830 COSTS_N_INSNS (3), /* fp */
831 COSTS_N_INSNS (3), /* dmul */
832 COSTS_N_INSNS (13), /* sdiv */
833 COSTS_N_INSNS (16), /* ddiv */
834 128, /* cache line size */
837 16, /* prefetch streams */
840 /* Instruction costs on POWER7 processors. */
842 struct processor_costs power7_cost = {
843 COSTS_N_INSNS (2), /* mulsi */
844 COSTS_N_INSNS (2), /* mulsi_const */
845 COSTS_N_INSNS (2), /* mulsi_const9 */
846 COSTS_N_INSNS (2), /* muldi */
847 COSTS_N_INSNS (18), /* divsi */
848 COSTS_N_INSNS (34), /* divdi */
849 COSTS_N_INSNS (3), /* fp */
850 COSTS_N_INSNS (3), /* dmul */
851 COSTS_N_INSNS (13), /* sdiv */
852 COSTS_N_INSNS (16), /* ddiv */
853 128, /* cache line size */
856 12, /* prefetch streams */
859 /* Instruction costs on POWER A2 processors. */
861 struct processor_costs ppca2_cost = {
862 COSTS_N_INSNS (16), /* mulsi */
863 COSTS_N_INSNS (16), /* mulsi_const */
864 COSTS_N_INSNS (16), /* mulsi_const9 */
865 COSTS_N_INSNS (16), /* muldi */
866 COSTS_N_INSNS (22), /* divsi */
867 COSTS_N_INSNS (28), /* divdi */
868 COSTS_N_INSNS (3), /* fp */
869 COSTS_N_INSNS (3), /* dmul */
870 COSTS_N_INSNS (59), /* sdiv */
871 COSTS_N_INSNS (72), /* ddiv */
875 16, /* prefetch streams */
879 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
880 #undef RS6000_BUILTIN
881 #undef RS6000_BUILTIN_EQUATE
882 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
883 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
885 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
887 #include "rs6000-builtin.def"
890 #undef RS6000_BUILTIN
891 #undef RS6000_BUILTIN_EQUATE
893 /* Support for -mveclibabi=<xxx> to control which vector library to use. */
894 static tree (*rs6000_veclib_handler) (tree, tree, tree);
897 static bool rs6000_function_ok_for_sibcall (tree, tree);
898 static const char *rs6000_invalid_within_doloop (const_rtx);
899 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
900 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
901 static rtx rs6000_generate_compare (rtx, enum machine_mode);
902 static void rs6000_emit_stack_tie (void);
903 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
904 static bool spe_func_has_64bit_regs_p (void);
905 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
907 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
908 static unsigned rs6000_hash_constant (rtx);
909 static unsigned toc_hash_function (const void *);
910 static int toc_hash_eq (const void *, const void *);
911 static bool reg_offset_addressing_ok_p (enum machine_mode);
912 static bool virtual_stack_registers_memory_p (rtx);
913 static bool constant_pool_expr_p (rtx);
914 static bool legitimate_small_data_p (enum machine_mode, rtx);
915 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
916 static struct machine_function * rs6000_init_machine_status (void);
917 static bool rs6000_assemble_integer (rtx, unsigned int, int);
918 static bool no_global_regs_above (int, bool);
919 #ifdef HAVE_GAS_HIDDEN
920 static void rs6000_assemble_visibility (tree, int);
922 static int rs6000_ra_ever_killed (void);
923 static bool rs6000_attribute_takes_identifier_p (const_tree);
924 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
925 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
926 static bool rs6000_ms_bitfield_layout_p (const_tree);
927 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
928 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
929 static const char *rs6000_mangle_type (const_tree);
930 static void rs6000_set_default_type_attributes (tree);
931 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
932 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
933 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
934 enum machine_mode, bool, bool, bool);
935 static bool rs6000_reg_live_or_pic_offset_p (int);
936 static tree rs6000_builtin_vectorized_libmass (tree, tree, tree);
937 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
938 static void rs6000_restore_saved_cr (rtx, int);
939 static bool rs6000_output_addr_const_extra (FILE *, rtx);
940 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
941 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
942 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
944 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
945 static bool rs6000_return_in_memory (const_tree, const_tree);
946 static rtx rs6000_function_value (const_tree, const_tree, bool);
947 static void rs6000_file_start (void);
949 static int rs6000_elf_reloc_rw_mask (void);
950 static void rs6000_elf_asm_out_constructor (rtx, int) ATTRIBUTE_UNUSED;
951 static void rs6000_elf_asm_out_destructor (rtx, int) ATTRIBUTE_UNUSED;
952 static void rs6000_elf_file_end (void) ATTRIBUTE_UNUSED;
953 static void rs6000_elf_asm_init_sections (void);
954 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
955 unsigned HOST_WIDE_INT);
956 static void rs6000_elf_encode_section_info (tree, rtx, int)
959 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
960 static void rs6000_alloc_sdmode_stack_slot (void);
961 static void rs6000_instantiate_decls (void);
963 static void rs6000_xcoff_asm_output_anchor (rtx);
964 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
965 static void rs6000_xcoff_asm_init_sections (void);
966 static int rs6000_xcoff_reloc_rw_mask (void);
967 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
968 static section *rs6000_xcoff_select_section (tree, int,
969 unsigned HOST_WIDE_INT);
970 static void rs6000_xcoff_unique_section (tree, int);
971 static section *rs6000_xcoff_select_rtx_section
972 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
973 static const char * rs6000_xcoff_strip_name_encoding (const char *);
974 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
975 static void rs6000_xcoff_file_start (void);
976 static void rs6000_xcoff_file_end (void);
978 static int rs6000_variable_issue (FILE *, int, rtx, int);
979 static int rs6000_register_move_cost (enum machine_mode,
980 reg_class_t, reg_class_t);
981 static int rs6000_memory_move_cost (enum machine_mode, reg_class_t, bool);
982 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
983 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
984 static int rs6000_debug_address_cost (rtx, bool);
985 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
986 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
987 static void rs6000_sched_init (FILE *, int, int);
988 static bool is_microcoded_insn (rtx);
989 static bool is_nonpipeline_insn (rtx);
990 static bool is_cracked_insn (rtx);
991 static bool is_branch_slot_insn (rtx);
992 static bool is_load_insn (rtx);
993 static rtx get_store_dest (rtx pat);
994 static bool is_store_insn (rtx);
995 static bool set_to_load_agen (rtx,rtx);
996 static bool adjacent_mem_locations (rtx,rtx);
997 static int rs6000_adjust_priority (rtx, int);
998 static int rs6000_issue_rate (void);
999 static bool rs6000_is_costly_dependence (dep_t, int, int);
1000 static rtx get_next_active_insn (rtx, rtx);
1001 static bool insn_terminates_group_p (rtx , enum group_termination);
1002 static bool insn_must_be_first_in_group (rtx);
1003 static bool insn_must_be_last_in_group (rtx);
1004 static bool is_costly_group (rtx *, rtx);
1005 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
1006 static int redefine_groups (FILE *, int, rtx, rtx);
1007 static int pad_groups (FILE *, int, rtx, rtx);
1008 static void rs6000_sched_finish (FILE *, int);
1009 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
1010 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
1011 static int rs6000_use_sched_lookahead (void);
1012 static int rs6000_use_sched_lookahead_guard (rtx);
1013 static void * rs6000_alloc_sched_context (void);
1014 static void rs6000_init_sched_context (void *, bool);
1015 static void rs6000_set_sched_context (void *);
1016 static void rs6000_free_sched_context (void *);
1017 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
1018 static tree rs6000_builtin_mask_for_load (void);
1019 static tree rs6000_builtin_mul_widen_even (tree);
1020 static tree rs6000_builtin_mul_widen_odd (tree);
1021 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
1022 static tree rs6000_builtin_vec_perm (tree, tree *);
1023 static bool rs6000_builtin_support_vector_misalignment (enum
1027 static int rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt,
1029 static enum machine_mode rs6000_preferred_simd_mode (enum machine_mode);
1031 static void def_builtin (int, const char *, tree, int);
1032 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1033 static void rs6000_init_builtins (void);
1034 static tree rs6000_builtin_decl (unsigned, bool);
1036 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1037 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1038 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1039 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1040 static void altivec_init_builtins (void);
1041 static unsigned builtin_hash_function (const void *);
1042 static int builtin_hash_eq (const void *, const void *);
1043 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1044 enum machine_mode, enum machine_mode,
1045 enum rs6000_builtins, const char *name);
1046 static void rs6000_common_init_builtins (void);
1047 static void rs6000_init_libfuncs (void);
1049 static void paired_init_builtins (void);
1050 static rtx paired_expand_builtin (tree, rtx, bool *);
1051 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1052 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1053 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1055 static void enable_mask_for_builtins (struct builtin_description *, int,
1056 enum rs6000_builtins,
1057 enum rs6000_builtins);
1058 static void spe_init_builtins (void);
1059 static rtx spe_expand_builtin (tree, rtx, bool *);
1060 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1061 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1062 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1063 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1064 static rs6000_stack_t *rs6000_stack_info (void);
1065 static void debug_stack_info (rs6000_stack_t *);
1067 static rtx altivec_expand_builtin (tree, rtx, bool *);
1068 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1069 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1070 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1071 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1072 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1073 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1074 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1075 static rtx altivec_expand_vec_set_builtin (tree);
1076 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1077 static int get_element_number (tree, tree);
1078 static void rs6000_option_override (void);
1079 static void rs6000_option_init_struct (struct gcc_options *);
1080 static void rs6000_option_default_params (void);
1081 static bool rs6000_handle_option (struct gcc_options *, struct gcc_options *,
1082 const struct cl_decoded_option *,
1084 static int rs6000_loop_align_max_skip (rtx);
1085 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1086 static int first_altivec_reg_to_save (void);
1087 static unsigned int compute_vrsave_mask (void);
1088 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1089 static void is_altivec_return_reg (rtx, void *);
1090 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1091 int easy_vector_constant (rtx, enum machine_mode);
1092 static rtx rs6000_dwarf_register_span (rtx);
1093 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1094 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1095 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1096 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1097 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1098 static rtx rs6000_delegitimize_address (rtx);
1099 static rtx rs6000_tls_get_addr (void);
1100 static rtx rs6000_got_sym (void);
1101 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1102 static const char *rs6000_get_some_local_dynamic_name (void);
1103 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1104 static rtx rs6000_complex_function_value (enum machine_mode);
1105 static rtx rs6000_spe_function_arg (const CUMULATIVE_ARGS *,
1106 enum machine_mode, const_tree);
1107 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1108 HOST_WIDE_INT, int);
1109 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1112 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1115 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1116 const_tree, HOST_WIDE_INT,
1118 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, bool, bool);
1119 static rtx rs6000_mixed_function_arg (enum machine_mode, const_tree, int);
1120 static void rs6000_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
1122 static rtx rs6000_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
1124 static unsigned int rs6000_function_arg_boundary (enum machine_mode,
1126 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1127 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1128 enum machine_mode, tree,
1130 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1132 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1134 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1136 static void macho_branch_islands (void);
1137 static int no_previous_def (tree function_name);
1138 static tree get_prev_label (tree function_name);
1139 static void rs6000_darwin_file_start (void);
1142 static tree rs6000_build_builtin_va_list (void);
1143 static void rs6000_va_start (tree, rtx);
1144 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1145 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1146 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1147 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1148 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1149 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1151 static tree rs6000_stack_protect_fail (void);
1153 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1156 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1159 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1161 = rs6000_legitimize_reload_address;
1163 static bool rs6000_mode_dependent_address_p (const_rtx);
1164 static bool rs6000_mode_dependent_address (const_rtx);
1165 static bool rs6000_debug_mode_dependent_address (const_rtx);
1166 static bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1167 = rs6000_mode_dependent_address;
1169 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1170 enum machine_mode, rtx);
1171 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1174 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1175 enum machine_mode, rtx)
1176 = rs6000_secondary_reload_class;
1178 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1179 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1181 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1182 = rs6000_preferred_reload_class;
1184 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1187 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1191 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1193 = rs6000_secondary_memory_needed;
1195 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1198 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1202 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1205 = rs6000_cannot_change_mode_class;
1207 static reg_class_t rs6000_secondary_reload (bool, rtx, reg_class_t,
1209 struct secondary_reload_info *);
1211 static const reg_class_t *rs6000_ira_cover_classes (void);
1213 const int INSN_NOT_AVAILABLE = -1;
1214 static enum machine_mode rs6000_eh_return_filter_mode (void);
1215 static bool rs6000_can_eliminate (const int, const int);
1216 static void rs6000_conditional_register_usage (void);
1217 static void rs6000_trampoline_init (rtx, tree, rtx);
1219 /* Hash table stuff for keeping track of TOC entries. */
1221 struct GTY(()) toc_hash_struct
1223 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1224 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1226 enum machine_mode key_mode;
1230 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1232 /* Hash table to keep track of the argument types for builtin functions. */
1234 struct GTY(()) builtin_hash_struct
1237 enum machine_mode mode[4]; /* return value + 3 arguments. */
1238 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1241 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1243 static bool rs6000_valid_attribute_p (tree, tree, tree, int);
1244 static void rs6000_function_specific_save (struct cl_target_option *);
1245 static void rs6000_function_specific_restore (struct cl_target_option *);
1246 static void rs6000_function_specific_print (FILE *, int,
1247 struct cl_target_option *);
1248 static bool rs6000_can_inline_p (tree, tree);
1249 static void rs6000_set_current_function (tree);
1252 /* Default register names. */
1253 char rs6000_reg_names[][8] =
1255 "0", "1", "2", "3", "4", "5", "6", "7",
1256 "8", "9", "10", "11", "12", "13", "14", "15",
1257 "16", "17", "18", "19", "20", "21", "22", "23",
1258 "24", "25", "26", "27", "28", "29", "30", "31",
1259 "0", "1", "2", "3", "4", "5", "6", "7",
1260 "8", "9", "10", "11", "12", "13", "14", "15",
1261 "16", "17", "18", "19", "20", "21", "22", "23",
1262 "24", "25", "26", "27", "28", "29", "30", "31",
1263 "mq", "lr", "ctr","ap",
1264 "0", "1", "2", "3", "4", "5", "6", "7",
1266 /* AltiVec registers. */
1267 "0", "1", "2", "3", "4", "5", "6", "7",
1268 "8", "9", "10", "11", "12", "13", "14", "15",
1269 "16", "17", "18", "19", "20", "21", "22", "23",
1270 "24", "25", "26", "27", "28", "29", "30", "31",
1272 /* SPE registers. */
1273 "spe_acc", "spefscr",
1274 /* Soft frame pointer. */
1278 #ifdef TARGET_REGNAMES
1279 static const char alt_reg_names[][8] =
1281 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1282 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1283 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1284 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1285 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1286 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1287 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1288 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1289 "mq", "lr", "ctr", "ap",
1290 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1292 /* AltiVec registers. */
1293 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1294 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1295 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1296 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1298 /* SPE registers. */
1299 "spe_acc", "spefscr",
1300 /* Soft frame pointer. */
1305 /* Table of valid machine attributes. */
1307 static const struct attribute_spec rs6000_attribute_table[] =
1309 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
1310 affects_type_identity } */
1311 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute,
1313 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute,
1315 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute,
1317 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute,
1319 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute,
1321 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1322 SUBTARGET_ATTRIBUTE_TABLE,
1324 { NULL, 0, 0, false, false, false, NULL, false }
1327 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
1328 static const struct default_options rs6000_option_optimization_table[] =
1330 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
1331 { OPT_LEVELS_NONE, 0, NULL, 0 }
1334 #ifndef MASK_STRICT_ALIGN
1335 #define MASK_STRICT_ALIGN 0
1337 #ifndef TARGET_PROFILE_KERNEL
1338 #define TARGET_PROFILE_KERNEL 0
1341 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1342 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1344 /* Initialize the GCC target structure. */
1345 #undef TARGET_ATTRIBUTE_TABLE
1346 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1347 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1348 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1349 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1350 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1352 #undef TARGET_ASM_ALIGNED_DI_OP
1353 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1355 /* Default unaligned ops are only provided for ELF. Find the ops needed
1356 for non-ELF systems. */
1357 #ifndef OBJECT_FORMAT_ELF
1359 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1361 #undef TARGET_ASM_UNALIGNED_HI_OP
1362 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1363 #undef TARGET_ASM_UNALIGNED_SI_OP
1364 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1365 #undef TARGET_ASM_UNALIGNED_DI_OP
1366 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1369 #undef TARGET_ASM_UNALIGNED_HI_OP
1370 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1371 #undef TARGET_ASM_UNALIGNED_SI_OP
1372 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1373 #undef TARGET_ASM_UNALIGNED_DI_OP
1374 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1375 #undef TARGET_ASM_ALIGNED_DI_OP
1376 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1380 /* This hook deals with fixups for relocatable code and DI-mode objects
1382 #undef TARGET_ASM_INTEGER
1383 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1385 #ifdef HAVE_GAS_HIDDEN
1386 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1387 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1390 #undef TARGET_HAVE_TLS
1391 #define TARGET_HAVE_TLS HAVE_AS_TLS
1393 #undef TARGET_CANNOT_FORCE_CONST_MEM
1394 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1396 #undef TARGET_DELEGITIMIZE_ADDRESS
1397 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1399 #undef TARGET_ASM_FUNCTION_PROLOGUE
1400 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1401 #undef TARGET_ASM_FUNCTION_EPILOGUE
1402 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1404 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
1405 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA rs6000_output_addr_const_extra
1407 #undef TARGET_LEGITIMIZE_ADDRESS
1408 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1410 #undef TARGET_SCHED_VARIABLE_ISSUE
1411 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1413 #undef TARGET_SCHED_ISSUE_RATE
1414 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1415 #undef TARGET_SCHED_ADJUST_COST
1416 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1417 #undef TARGET_SCHED_ADJUST_PRIORITY
1418 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1419 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1420 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1421 #undef TARGET_SCHED_INIT
1422 #define TARGET_SCHED_INIT rs6000_sched_init
1423 #undef TARGET_SCHED_FINISH
1424 #define TARGET_SCHED_FINISH rs6000_sched_finish
1425 #undef TARGET_SCHED_REORDER
1426 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1427 #undef TARGET_SCHED_REORDER2
1428 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1430 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1431 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1433 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1434 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1436 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1437 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1438 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1439 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1440 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1441 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1442 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1443 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1445 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1446 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1447 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1448 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1449 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1450 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1451 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1452 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1453 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1454 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1455 #undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
1456 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
1457 rs6000_builtin_support_vector_misalignment
1458 #undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
1459 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1460 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
1461 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \
1462 rs6000_builtin_vectorization_cost
1463 #undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
1464 #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \
1465 rs6000_preferred_simd_mode
1467 #undef TARGET_INIT_BUILTINS
1468 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1469 #undef TARGET_BUILTIN_DECL
1470 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1472 #undef TARGET_EXPAND_BUILTIN
1473 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1475 #undef TARGET_MANGLE_TYPE
1476 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1478 #undef TARGET_INIT_LIBFUNCS
1479 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1482 #undef TARGET_BINDS_LOCAL_P
1483 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1486 #undef TARGET_MS_BITFIELD_LAYOUT_P
1487 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1489 #undef TARGET_ASM_OUTPUT_MI_THUNK
1490 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1492 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1493 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1495 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1496 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1498 #undef TARGET_INVALID_WITHIN_DOLOOP
1499 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1501 #undef TARGET_REGISTER_MOVE_COST
1502 #define TARGET_REGISTER_MOVE_COST rs6000_register_move_cost
1503 #undef TARGET_MEMORY_MOVE_COST
1504 #define TARGET_MEMORY_MOVE_COST rs6000_memory_move_cost
1505 #undef TARGET_RTX_COSTS
1506 #define TARGET_RTX_COSTS rs6000_rtx_costs
1507 #undef TARGET_ADDRESS_COST
1508 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1510 #undef TARGET_DWARF_REGISTER_SPAN
1511 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1513 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1514 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1516 /* On rs6000, function arguments are promoted, as are function return
1518 #undef TARGET_PROMOTE_FUNCTION_MODE
1519 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1521 #undef TARGET_RETURN_IN_MEMORY
1522 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1524 #undef TARGET_SETUP_INCOMING_VARARGS
1525 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1527 /* Always strict argument naming on rs6000. */
1528 #undef TARGET_STRICT_ARGUMENT_NAMING
1529 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1530 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1531 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1532 #undef TARGET_SPLIT_COMPLEX_ARG
1533 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1534 #undef TARGET_MUST_PASS_IN_STACK
1535 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1536 #undef TARGET_PASS_BY_REFERENCE
1537 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1538 #undef TARGET_ARG_PARTIAL_BYTES
1539 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1540 #undef TARGET_FUNCTION_ARG_ADVANCE
1541 #define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance
1542 #undef TARGET_FUNCTION_ARG
1543 #define TARGET_FUNCTION_ARG rs6000_function_arg
1544 #undef TARGET_FUNCTION_ARG_BOUNDARY
1545 #define TARGET_FUNCTION_ARG_BOUNDARY rs6000_function_arg_boundary
1547 #undef TARGET_BUILD_BUILTIN_VA_LIST
1548 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1550 #undef TARGET_EXPAND_BUILTIN_VA_START
1551 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1553 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1554 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1556 #undef TARGET_EH_RETURN_FILTER_MODE
1557 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1559 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1560 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1562 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1563 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1565 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1566 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1568 #undef TARGET_HANDLE_OPTION
1569 #define TARGET_HANDLE_OPTION rs6000_handle_option
1571 #undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP
1572 #define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rs6000_loop_align_max_skip
1574 #undef TARGET_OPTION_OVERRIDE
1575 #define TARGET_OPTION_OVERRIDE rs6000_option_override
1577 #undef TARGET_OPTION_INIT_STRUCT
1578 #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
1580 #undef TARGET_OPTION_DEFAULT_PARAMS
1581 #define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params
1583 #undef TARGET_OPTION_OPTIMIZATION_TABLE
1584 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
1586 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1587 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1588 rs6000_builtin_vectorized_function
1590 #undef TARGET_DEFAULT_TARGET_FLAGS
1591 #define TARGET_DEFAULT_TARGET_FLAGS \
1594 #undef TARGET_STACK_PROTECT_FAIL
1595 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1597 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1598 The PowerPC architecture requires only weak consistency among
1599 processors--that is, memory accesses between processors need not be
1600 sequentially consistent and memory accesses among processors can occur
1601 in any order. The ability to order memory accesses weakly provides
1602 opportunities for more efficient use of the system bus. Unless a
1603 dependency exists, the 604e allows read operations to precede store
1605 #undef TARGET_RELAXED_ORDERING
1606 #define TARGET_RELAXED_ORDERING true
1609 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1610 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1613 /* Use a 32-bit anchor range. This leads to sequences like:
1615 addis tmp,anchor,high
1618 where tmp itself acts as an anchor, and can be shared between
1619 accesses to the same 64k page. */
1620 #undef TARGET_MIN_ANCHOR_OFFSET
1621 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1622 #undef TARGET_MAX_ANCHOR_OFFSET
1623 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1624 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1625 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1627 #undef TARGET_BUILTIN_RECIPROCAL
1628 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1630 #undef TARGET_EXPAND_TO_RTL_HOOK
1631 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1633 #undef TARGET_INSTANTIATE_DECLS
1634 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1636 #undef TARGET_SECONDARY_RELOAD
1637 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1639 #undef TARGET_IRA_COVER_CLASSES
1640 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1642 #undef TARGET_LEGITIMATE_ADDRESS_P
1643 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1645 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
1646 #define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p
1648 #undef TARGET_CAN_ELIMINATE
1649 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1651 #undef TARGET_CONDITIONAL_REGISTER_USAGE
1652 #define TARGET_CONDITIONAL_REGISTER_USAGE rs6000_conditional_register_usage
1654 #undef TARGET_TRAMPOLINE_INIT
1655 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1657 #undef TARGET_FUNCTION_VALUE
1658 #define TARGET_FUNCTION_VALUE rs6000_function_value
1660 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
1661 #define TARGET_OPTION_VALID_ATTRIBUTE_P rs6000_valid_attribute_p
1663 #undef TARGET_OPTION_SAVE
1664 #define TARGET_OPTION_SAVE rs6000_function_specific_save
1666 #undef TARGET_OPTION_RESTORE
1667 #define TARGET_OPTION_RESTORE rs6000_function_specific_restore
1669 #undef TARGET_OPTION_PRINT
1670 #define TARGET_OPTION_PRINT rs6000_function_specific_print
1672 #undef TARGET_CAN_INLINE_P
1673 #define TARGET_CAN_INLINE_P rs6000_can_inline_p
1675 #undef TARGET_SET_CURRENT_FUNCTION
1676 #define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function
1678 struct gcc_target targetm = TARGET_INITIALIZER;
1681 /* Simplifications for entries below. */
1684 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1685 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1688 /* Some OSs don't support saving the high part of 64-bit registers on context
1689 switch. Other OSs don't support saving Altivec registers. On those OSs, we
1690 don't touch the MASK_POWERPC64 or MASK_ALTIVEC settings; if the user wants
1691 either, the user must explicitly specify them and we won't interfere with
1692 the user's specification. */
1695 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1696 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1697 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1698 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1699 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
1700 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE
1701 | MASK_RECIP_PRECISION)
1704 /* Masks for instructions set at various powerpc ISAs. */
1706 ISA_2_1_MASKS = MASK_MFCRF,
1707 ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB),
1708 ISA_2_4_MASKS = (ISA_2_2_MASKS | MASK_FPRND),
1710 /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't add
1711 ALTIVEC, since in general it isn't a win on power6. In ISA 2.04, fsel,
1712 fre, fsqrt, etc. were no longer documented as optional. Group masks by
1713 server and embedded. */
1714 ISA_2_5_MASKS_EMBEDDED = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION
1715 | MASK_PPC_GFXOPT | MASK_PPC_GPOPT),
1716 ISA_2_5_MASKS_SERVER = (ISA_2_5_MASKS_EMBEDDED | MASK_DFP),
1718 /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
1719 altivec is a win so enable it. */
1720 ISA_2_6_MASKS_EMBEDDED = (ISA_2_5_MASKS_EMBEDDED | MASK_POPCNTD),
1721 ISA_2_6_MASKS_SERVER = (ISA_2_5_MASKS_SERVER | MASK_POPCNTD | MASK_ALTIVEC
1725 /* This table occasionally claims that a processor does not support a
1726 particular feature even though it does, but the feature is slower than the
1727 alternative. Thus, it shouldn't be relied on as a complete description of
1728 the processor's support.
1730 Please keep this list in order, and don't forget to update the documentation
1731 in invoke.texi when adding a new processor or flag. */
1735 const char *const name; /* Canonical processor name. */
1736 const enum processor_type processor; /* Processor type enum value. */
1737 const int target_enable; /* Target flags to enable. */
1740 static struct rs6000_ptt const processor_target_table[] =
1742 {"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1743 {"403", PROCESSOR_PPC403,
1744 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1745 {"405", PROCESSOR_PPC405,
1746 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1747 {"405fp", PROCESSOR_PPC405,
1748 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1749 {"440", PROCESSOR_PPC440,
1750 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1751 {"440fp", PROCESSOR_PPC440,
1752 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1753 {"464", PROCESSOR_PPC440,
1754 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1755 {"464fp", PROCESSOR_PPC440,
1756 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1757 {"476", PROCESSOR_PPC476,
1758 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
1759 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
1760 {"476fp", PROCESSOR_PPC476,
1761 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
1762 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
1763 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1764 {"601", PROCESSOR_PPC601,
1765 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1766 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1767 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1768 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1769 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1770 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1771 {"620", PROCESSOR_PPC620,
1772 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1773 {"630", PROCESSOR_PPC630,
1774 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1775 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1776 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1777 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1778 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1779 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1780 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1781 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1782 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
1784 /* 8548 has a dummy entry for now. */
1785 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
1787 {"a2", PROCESSOR_PPCA2,
1788 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
1789 | MASK_CMPB | MASK_NO_UPDATE },
1790 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1791 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
1792 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
1794 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
1795 | MASK_PPC_GFXOPT | MASK_ISEL},
1796 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1797 {"970", PROCESSOR_POWER4,
1798 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1799 {"cell", PROCESSOR_CELL,
1800 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1801 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1802 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1803 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1804 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1805 {"G5", PROCESSOR_POWER4,
1806 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1807 {"titan", PROCESSOR_TITAN,
1808 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1809 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1810 {"power2", PROCESSOR_POWER,
1811 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1812 {"power3", PROCESSOR_PPC630,
1813 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1814 {"power4", PROCESSOR_POWER4,
1815 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1817 {"power5", PROCESSOR_POWER5,
1818 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1819 | MASK_MFCRF | MASK_POPCNTB},
1820 {"power5+", PROCESSOR_POWER5,
1821 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1822 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1823 {"power6", PROCESSOR_POWER6,
1824 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1825 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
1826 | MASK_RECIP_PRECISION},
1827 {"power6x", PROCESSOR_POWER6,
1828 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1829 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
1830 | MASK_MFPGPR | MASK_RECIP_PRECISION},
1831 {"power7", PROCESSOR_POWER7, /* Don't add MASK_ISEL by default */
1832 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
1833 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
1834 | MASK_VSX | MASK_RECIP_PRECISION},
1835 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1836 {"powerpc64", PROCESSOR_POWERPC64,
1837 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1838 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1839 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1840 {"rios2", PROCESSOR_RIOS2,
1841 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1842 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1843 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1844 {"rs64", PROCESSOR_RS64A,
1845 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1848 /* Look up a processor name for -mcpu=xxx and -mtune=xxx. Return -1 if the
1852 rs6000_cpu_name_lookup (const char *name)
1858 for (i = 0; i < ARRAY_SIZE (processor_target_table); i++)
1859 if (! strcmp (name, processor_target_table[i].name))
1867 /* Return number of consecutive hard regs needed starting at reg REGNO
1868 to hold something of mode MODE.
1869 This is ordinarily the length in words of a value of mode MODE
1870 but can be less for certain modes in special long registers.
1872 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1873 scalar instructions. The upper 32 bits are only available to the
1876 POWER and PowerPC GPRs hold 32 bits worth;
1877 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1880 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1882 unsigned HOST_WIDE_INT reg_size;
1884 if (FP_REGNO_P (regno))
1885 reg_size = (VECTOR_MEM_VSX_P (mode)
1886 ? UNITS_PER_VSX_WORD
1887 : UNITS_PER_FP_WORD);
1889 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1890 reg_size = UNITS_PER_SPE_WORD;
1892 else if (ALTIVEC_REGNO_P (regno))
1893 reg_size = UNITS_PER_ALTIVEC_WORD;
1895 /* The value returned for SCmode in the E500 double case is 2 for
1896 ABI compatibility; storing an SCmode value in a single register
1897 would require function_arg and rs6000_spe_function_arg to handle
1898 SCmode so as to pass the value correctly in a pair of
1900 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1901 && !DECIMAL_FLOAT_MODE_P (mode))
1902 reg_size = UNITS_PER_FP_WORD;
1905 reg_size = UNITS_PER_WORD;
1907 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1910 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1913 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1915 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1917 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1918 implementations. Don't allow an item to be split between a FP register
1919 and an Altivec register. */
1920 if (VECTOR_MEM_VSX_P (mode))
1922 if (FP_REGNO_P (regno))
1923 return FP_REGNO_P (last_regno);
1925 if (ALTIVEC_REGNO_P (regno))
1926 return ALTIVEC_REGNO_P (last_regno);
1929 /* The GPRs can hold any mode, but values bigger than one register
1930 cannot go past R31. */
1931 if (INT_REGNO_P (regno))
1932 return INT_REGNO_P (last_regno);
1934 /* The float registers (except for VSX vector modes) can only hold floating
1935 modes and DImode. This excludes the 32-bit decimal float mode for
1937 if (FP_REGNO_P (regno))
1939 if (SCALAR_FLOAT_MODE_P (mode)
1940 && (mode != TDmode || (regno % 2) == 0)
1941 && FP_REGNO_P (last_regno))
1944 if (GET_MODE_CLASS (mode) == MODE_INT
1945 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1948 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1949 && PAIRED_VECTOR_MODE (mode))
1955 /* The CR register can only hold CC modes. */
1956 if (CR_REGNO_P (regno))
1957 return GET_MODE_CLASS (mode) == MODE_CC;
1959 if (CA_REGNO_P (regno))
1960 return mode == BImode;
1962 /* AltiVec only in AldyVec registers. */
1963 if (ALTIVEC_REGNO_P (regno))
1964 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1966 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1967 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1970 /* We cannot put TImode anywhere except general register and it must be able
1971 to fit within the register set. In the future, allow TImode in the
1972 Altivec or VSX registers. */
1974 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1977 /* Print interesting facts about registers. */
1979 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1983 for (r = first_regno; r <= last_regno; ++r)
1985 const char *comma = "";
1988 if (first_regno == last_regno)
1989 fprintf (stderr, "%s:\t", reg_name);
1991 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1994 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1995 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1999 fprintf (stderr, ",\n\t");
2004 if (rs6000_hard_regno_nregs[m][r] > 1)
2005 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
2006 rs6000_hard_regno_nregs[m][r]);
2008 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
2013 if (call_used_regs[r])
2017 fprintf (stderr, ",\n\t");
2022 len += fprintf (stderr, "%s%s", comma, "call-used");
2030 fprintf (stderr, ",\n\t");
2035 len += fprintf (stderr, "%s%s", comma, "fixed");
2041 fprintf (stderr, ",\n\t");
2045 fprintf (stderr, "%sregno = %d\n", comma, r);
2049 #define DEBUG_FMT_D "%-32s= %d\n"
2050 #define DEBUG_FMT_S "%-32s= %s\n"
2052 /* Print various interesting information with -mdebug=reg. */
2054 rs6000_debug_reg_global (void)
2056 static const char *const tf[2] = { "false", "true" };
2057 const char *nl = (const char *)0;
2059 char costly_num[20];
2061 const char *costly_str;
2062 const char *nop_str;
2063 const char *trace_str;
2064 const char *abi_str;
2065 const char *cmodel_str;
2067 /* Map enum rs6000_vector to string. */
2068 static const char *rs6000_debug_vector_unit[] = {
2077 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
2078 LAST_VIRTUAL_REGISTER);
2079 rs6000_debug_reg_print (0, 31, "gr");
2080 rs6000_debug_reg_print (32, 63, "fp");
2081 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
2084 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
2085 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
2086 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
2087 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
2088 rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca");
2089 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
2090 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
2091 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
2092 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
2096 "d reg_class = %s\n"
2097 "f reg_class = %s\n"
2098 "v reg_class = %s\n"
2099 "wa reg_class = %s\n"
2100 "wd reg_class = %s\n"
2101 "wf reg_class = %s\n"
2102 "ws reg_class = %s\n\n",
2103 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
2104 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
2105 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
2106 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
2107 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
2108 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
2109 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
2111 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2112 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
2115 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
2117 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
2118 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
2124 if (rs6000_recip_control)
2126 fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control);
2128 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2129 if (rs6000_recip_bits[m])
2132 "Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n",
2134 (RS6000_RECIP_AUTO_RE_P (m)
2136 : (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")),
2137 (RS6000_RECIP_AUTO_RSQRTE_P (m)
2139 : (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none")));
2142 fputs ("\n", stderr);
2145 if (rs6000_cpu_index >= 0)
2146 fprintf (stderr, DEBUG_FMT_S, "cpu",
2147 processor_target_table[rs6000_cpu_index].name);
2149 if (rs6000_tune_index >= 0)
2150 fprintf (stderr, DEBUG_FMT_S, "tune",
2151 processor_target_table[rs6000_tune_index].name);
2153 switch (rs6000_sched_costly_dep)
2155 case max_dep_latency:
2156 costly_str = "max_dep_latency";
2160 costly_str = "no_dep_costly";
2163 case all_deps_costly:
2164 costly_str = "all_deps_costly";
2167 case true_store_to_load_dep_costly:
2168 costly_str = "true_store_to_load_dep_costly";
2171 case store_to_load_dep_costly:
2172 costly_str = "store_to_load_dep_costly";
2176 costly_str = costly_num;
2177 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
2181 fprintf (stderr, DEBUG_FMT_S, "sched_costly_dep", costly_str);
2183 switch (rs6000_sched_insert_nops)
2185 case sched_finish_regroup_exact:
2186 nop_str = "sched_finish_regroup_exact";
2189 case sched_finish_pad_groups:
2190 nop_str = "sched_finish_pad_groups";
2193 case sched_finish_none:
2194 nop_str = "sched_finish_none";
2199 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
2203 fprintf (stderr, DEBUG_FMT_S, "sched_insert_nops", nop_str);
2205 switch (rs6000_sdata)
2212 fprintf (stderr, DEBUG_FMT_S, "sdata", "data");
2216 fprintf (stderr, DEBUG_FMT_S, "sdata", "sysv");
2220 fprintf (stderr, DEBUG_FMT_S, "sdata", "eabi");
2225 switch (rs6000_traceback)
2227 case traceback_default: trace_str = "default"; break;
2228 case traceback_none: trace_str = "none"; break;
2229 case traceback_part: trace_str = "part"; break;
2230 case traceback_full: trace_str = "full"; break;
2231 default: trace_str = "unknown"; break;
2234 fprintf (stderr, DEBUG_FMT_S, "traceback", trace_str);
2236 switch (rs6000_current_cmodel)
2238 case CMODEL_SMALL: cmodel_str = "small"; break;
2239 case CMODEL_MEDIUM: cmodel_str = "medium"; break;
2240 case CMODEL_LARGE: cmodel_str = "large"; break;
2241 default: cmodel_str = "unknown"; break;
2244 fprintf (stderr, DEBUG_FMT_S, "cmodel", cmodel_str);
2246 switch (rs6000_current_abi)
2248 case ABI_NONE: abi_str = "none"; break;
2249 case ABI_AIX: abi_str = "aix"; break;
2250 case ABI_V4: abi_str = "V4"; break;
2251 case ABI_DARWIN: abi_str = "darwin"; break;
2252 default: abi_str = "unknown"; break;
2255 fprintf (stderr, DEBUG_FMT_S, "abi", abi_str);
2257 if (rs6000_altivec_abi)
2258 fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true");
2261 fprintf (stderr, DEBUG_FMT_S, "spe_abi", "true");
2263 if (rs6000_darwin64_abi)
2264 fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true");
2266 if (rs6000_float_gprs)
2267 fprintf (stderr, DEBUG_FMT_S, "float_gprs", "true");
2269 fprintf (stderr, DEBUG_FMT_S, "always_hint", tf[!!rs6000_always_hint]);
2270 fprintf (stderr, DEBUG_FMT_S, "align_branch",
2271 tf[!!rs6000_align_branch_targets]);
2272 fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size);
2273 fprintf (stderr, DEBUG_FMT_D, "long_double_size",
2274 rs6000_long_double_type_size);
2275 fprintf (stderr, DEBUG_FMT_D, "sched_restricted_insns_priority",
2276 (int)rs6000_sched_restricted_insns_priority);
2279 /* Initialize the various global tables that are based on register size. */
2281 rs6000_init_hard_regno_mode_ok (bool global_init_p)
2287 /* Precalculate REGNO_REG_CLASS. */
2288 rs6000_regno_regclass[0] = GENERAL_REGS;
2289 for (r = 1; r < 32; ++r)
2290 rs6000_regno_regclass[r] = BASE_REGS;
2292 for (r = 32; r < 64; ++r)
2293 rs6000_regno_regclass[r] = FLOAT_REGS;
2295 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
2296 rs6000_regno_regclass[r] = NO_REGS;
2298 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
2299 rs6000_regno_regclass[r] = ALTIVEC_REGS;
2301 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
2302 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
2303 rs6000_regno_regclass[r] = CR_REGS;
2305 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
2306 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
2307 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
2308 rs6000_regno_regclass[CA_REGNO] = CA_REGS;
2309 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
2310 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
2311 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
2312 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
2313 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
2314 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
2316 /* Precalculate vector information, this must be set up before the
2317 rs6000_hard_regno_nregs_internal below. */
2318 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2320 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
2321 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
2322 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
2325 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
2326 rs6000_constraints[c] = NO_REGS;
2328 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
2329 believes it can use native alignment or still uses 128-bit alignment. */
2330 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
2341 /* V2DF mode, VSX only. */
2344 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
2345 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
2346 rs6000_vector_align[V2DFmode] = align64;
2349 /* V4SF mode, either VSX or Altivec. */
2352 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
2353 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
2354 rs6000_vector_align[V4SFmode] = align32;
2356 else if (TARGET_ALTIVEC)
2358 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
2359 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
2360 rs6000_vector_align[V4SFmode] = align32;
2363 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
2367 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
2368 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
2369 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
2370 rs6000_vector_align[V4SImode] = align32;
2371 rs6000_vector_align[V8HImode] = align32;
2372 rs6000_vector_align[V16QImode] = align32;
2376 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
2377 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
2378 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
2382 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
2383 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
2384 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
2388 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
2389 Altivec doesn't have 64-bit support. */
2392 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
2393 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
2394 rs6000_vector_align[V2DImode] = align64;
2397 /* DFmode, see if we want to use the VSX unit. */
2398 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
2400 rs6000_vector_unit[DFmode] = VECTOR_VSX;
2401 rs6000_vector_mem[DFmode]
2402 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
2403 rs6000_vector_align[DFmode] = align64;
2406 /* TODO add SPE and paired floating point vector support. */
2408 /* Register class constaints for the constraints that depend on compile
2410 if (TARGET_HARD_FLOAT && TARGET_FPRS)
2411 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2413 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2414 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2418 /* At present, we just use VSX_REGS, but we have different constraints
2419 based on the use, in case we want to fine tune the default register
2420 class used. wa = any VSX register, wf = register class to use for
2421 V4SF, wd = register class to use for V2DF, and ws = register classs to
2422 use for DF scalars. */
2423 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2424 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2425 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2426 rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
2432 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2434 /* Set up the reload helper functions. */
2435 if (TARGET_VSX || TARGET_ALTIVEC)
2439 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2440 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2441 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2442 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2443 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2444 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2445 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2446 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2447 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2448 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2449 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2450 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2454 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2455 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2456 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2457 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2458 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2459 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2460 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2461 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2462 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2463 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2464 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2465 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2469 /* Precalculate HARD_REGNO_NREGS. */
2470 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2471 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2472 rs6000_hard_regno_nregs[m][r]
2473 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2475 /* Precalculate HARD_REGNO_MODE_OK. */
2476 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2477 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2478 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2479 rs6000_hard_regno_mode_ok_p[m][r] = true;
2481 /* Precalculate CLASS_MAX_NREGS sizes. */
2482 for (c = 0; c < LIM_REG_CLASSES; ++c)
2486 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2487 reg_size = UNITS_PER_VSX_WORD;
2489 else if (c == ALTIVEC_REGS)
2490 reg_size = UNITS_PER_ALTIVEC_WORD;
2492 else if (c == FLOAT_REGS)
2493 reg_size = UNITS_PER_FP_WORD;
2496 reg_size = UNITS_PER_WORD;
2498 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2499 rs6000_class_max_nregs[m][c]
2500 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2503 if (TARGET_E500_DOUBLE)
2504 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2506 /* Calculate which modes to automatically generate code to use a the
2507 reciprocal divide and square root instructions. In the future, possibly
2508 automatically generate the instructions even if the user did not specify
2509 -mrecip. The older machines double precision reciprocal sqrt estimate is
2510 not accurate enough. */
2511 memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits));
2513 rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2515 rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2516 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2517 rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2518 if (VECTOR_UNIT_VSX_P (V2DFmode))
2519 rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2521 if (TARGET_FRSQRTES)
2522 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2524 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2525 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2526 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2527 if (VECTOR_UNIT_VSX_P (V2DFmode))
2528 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2530 if (rs6000_recip_control)
2532 if (!flag_finite_math_only)
2533 warning (0, "-mrecip requires -ffinite-math or -ffast-math");
2534 if (flag_trapping_math)
2535 warning (0, "-mrecip requires -fno-trapping-math or -ffast-math");
2536 if (!flag_reciprocal_math)
2537 warning (0, "-mrecip requires -freciprocal-math or -ffast-math");
2538 if (flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math)
2540 if (RS6000_RECIP_HAVE_RE_P (SFmode)
2541 && (rs6000_recip_control & RECIP_SF_DIV) != 0)
2542 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2544 if (RS6000_RECIP_HAVE_RE_P (DFmode)
2545 && (rs6000_recip_control & RECIP_DF_DIV) != 0)
2546 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2548 if (RS6000_RECIP_HAVE_RE_P (V4SFmode)
2549 && (rs6000_recip_control & RECIP_V4SF_DIV) != 0)
2550 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2552 if (RS6000_RECIP_HAVE_RE_P (V2DFmode)
2553 && (rs6000_recip_control & RECIP_V2DF_DIV) != 0)
2554 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2556 if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode)
2557 && (rs6000_recip_control & RECIP_SF_RSQRT) != 0)
2558 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2560 if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode)
2561 && (rs6000_recip_control & RECIP_DF_RSQRT) != 0)
2562 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2564 if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode)
2565 && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0)
2566 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2568 if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode)
2569 && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0)
2570 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2574 if (global_init_p || TARGET_DEBUG_TARGET)
2576 if (TARGET_DEBUG_REG)
2577 rs6000_debug_reg_global ();
2579 if (TARGET_DEBUG_COST || TARGET_DEBUG_REG)
2581 "SImode variable mult cost = %d\n"
2582 "SImode constant mult cost = %d\n"
2583 "SImode short constant mult cost = %d\n"
2584 "DImode multipliciation cost = %d\n"
2585 "SImode division cost = %d\n"
2586 "DImode division cost = %d\n"
2587 "Simple fp operation cost = %d\n"
2588 "DFmode multiplication cost = %d\n"
2589 "SFmode division cost = %d\n"
2590 "DFmode division cost = %d\n"
2591 "cache line size = %d\n"
2592 "l1 cache size = %d\n"
2593 "l2 cache size = %d\n"
2594 "simultaneous prefetches = %d\n"
2597 rs6000_cost->mulsi_const,
2598 rs6000_cost->mulsi_const9,
2606 rs6000_cost->cache_line_size,
2607 rs6000_cost->l1_cache_size,
2608 rs6000_cost->l2_cache_size,
2609 rs6000_cost->simultaneous_prefetches);
2614 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2617 darwin_rs6000_override_options (void)
2619 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2621 rs6000_altivec_abi = 1;
2622 TARGET_ALTIVEC_VRSAVE = 1;
2624 if (DEFAULT_ABI == ABI_DARWIN
2626 darwin_one_byte_bool = 1;
2628 if (TARGET_64BIT && ! TARGET_POWERPC64)
2630 target_flags |= MASK_POWERPC64;
2631 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2635 rs6000_default_long_calls = 1;
2636 target_flags |= MASK_SOFT_FLOAT;
2639 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2641 if (!flag_mkernel && !flag_apple_kext
2643 && ! (target_flags_explicit & MASK_ALTIVEC))
2644 target_flags |= MASK_ALTIVEC;
2646 /* Unless the user (not the configurer) has explicitly overridden
2647 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2648 G4 unless targetting the kernel. */
2651 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2652 && ! (target_flags_explicit & MASK_ALTIVEC)
2653 && ! rs6000_select[1].string)
2655 target_flags |= MASK_ALTIVEC;
2660 /* If not otherwise specified by a target, make 'long double' equivalent to
2663 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2664 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2667 /* Override command line options. Mostly we process the processor type and
2668 sometimes adjust other TARGET_ options. */
2671 rs6000_option_override_internal (bool global_init_p)
2674 const char *default_cpu = OPTION_TARGET_CPU_DEFAULT;
2678 struct cl_target_option *main_target_opt
2679 = ((global_init_p || target_option_default_node == NULL)
2680 ? NULL : TREE_TARGET_OPTION (target_option_default_node));
2682 /* Numerous experiment shows that IRA based loop pressure
2683 calculation works better for RTL loop invariant motion on targets
2684 with enough (>= 32) registers. It is an expensive optimization.
2685 So it is on only for peak performance. */
2686 if (optimize >= 3 && global_init_p)
2687 flag_ira_loop_pressure = 1;
2689 /* Set the pointer size. */
2692 rs6000_pmode = (int)DImode;
2693 rs6000_pointer_size = 64;
2697 rs6000_pmode = (int)SImode;
2698 rs6000_pointer_size = 32;
2701 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2702 #ifdef OS_MISSING_POWERPC64
2703 if (OS_MISSING_POWERPC64)
2704 set_masks &= ~MASK_POWERPC64;
2706 #ifdef OS_MISSING_ALTIVEC
2707 if (OS_MISSING_ALTIVEC)
2708 set_masks &= ~MASK_ALTIVEC;
2711 /* Don't override by the processor default if given explicitly. */
2712 set_masks &= ~target_flags_explicit;
2714 /* Identify the processor type. */
2717 if (TARGET_POWERPC64)
2718 default_cpu = "powerpc64";
2719 else if (TARGET_POWERPC)
2720 default_cpu = "powerpc";
2723 /* Process the -mcpu=<xxx> and -mtune=<xxx> argument. If the user changed
2724 the cpu in a target attribute or pragma, but did not specify a tuning
2725 option, use the cpu for the tuning option rather than the option specified
2726 with -mtune on the command line. */
2727 if (rs6000_cpu_index > 0)
2728 cpu_index = rs6000_cpu_index;
2729 else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index > 0)
2730 rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index;
2732 rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (default_cpu);
2734 if (rs6000_tune_index > 0)
2735 tune_index = rs6000_tune_index;
2737 rs6000_tune_index = tune_index = cpu_index;
2741 target_flags &= ~set_masks;
2742 target_flags |= (processor_target_table[cpu_index].target_enable
2746 rs6000_cpu = ((tune_index >= 0)
2747 ? processor_target_table[tune_index].processor
2749 ? PROCESSOR_DEFAULT64
2750 : PROCESSOR_DEFAULT));
2752 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2753 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2756 error ("AltiVec not supported in this target");
2758 error ("SPE not supported in this target");
2761 /* Disable Cell microcode if we are optimizing for the Cell
2762 and not optimizing for size. */
2763 if (rs6000_gen_cell_microcode == -1)
2764 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2767 /* If we are optimizing big endian systems for space and it's OK to
2768 use instructions that would be microcoded on the Cell, use the
2769 load/store multiple and string instructions. */
2770 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2771 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2773 /* Don't allow -mmultiple or -mstring on little endian systems
2774 unless the cpu is a 750, because the hardware doesn't support the
2775 instructions used in little endian mode, and causes an alignment
2776 trap. The 750 does not cause an alignment trap (except when the
2777 target is unaligned). */
2779 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2781 if (TARGET_MULTIPLE)
2783 target_flags &= ~MASK_MULTIPLE;
2784 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2785 warning (0, "-mmultiple is not supported on little endian systems");
2790 target_flags &= ~MASK_STRING;
2791 if ((target_flags_explicit & MASK_STRING) != 0)
2792 warning (0, "-mstring is not supported on little endian systems");
2796 /* Add some warnings for VSX. */
2799 const char *msg = NULL;
2800 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2801 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2803 if (target_flags_explicit & MASK_VSX)
2804 msg = N_("-mvsx requires hardware floating point");
2806 target_flags &= ~ MASK_VSX;
2808 else if (TARGET_PAIRED_FLOAT)
2809 msg = N_("-mvsx and -mpaired are incompatible");
2810 /* The hardware will allow VSX and little endian, but until we make sure
2811 things like vector select, etc. work don't allow VSX on little endian
2812 systems at this point. */
2813 else if (!BYTES_BIG_ENDIAN)
2814 msg = N_("-mvsx used with little endian code");
2815 else if (TARGET_AVOID_XFORM > 0)
2816 msg = N_("-mvsx needs indexed addressing");
2817 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2819 if (target_flags_explicit & MASK_VSX)
2820 msg = N_("-mvsx and -mno-altivec are incompatible");
2822 msg = N_("-mno-altivec disables vsx");
2828 target_flags &= ~ MASK_VSX;
2829 target_flags_explicit |= MASK_VSX;
2833 /* For the newer switches (vsx, dfp, etc.) set some of the older options,
2834 unless the user explicitly used the -mno-<option> to disable the code. */
2836 target_flags |= (ISA_2_6_MASKS_SERVER & ~target_flags_explicit);
2837 else if (TARGET_POPCNTD)
2838 target_flags |= (ISA_2_6_MASKS_EMBEDDED & ~target_flags_explicit);
2839 else if (TARGET_DFP)
2840 target_flags |= (ISA_2_5_MASKS_SERVER & ~target_flags_explicit);
2841 else if (TARGET_CMPB)
2842 target_flags |= (ISA_2_5_MASKS_EMBEDDED & ~target_flags_explicit);
2843 else if (TARGET_FPRND)
2844 target_flags |= (ISA_2_4_MASKS & ~target_flags_explicit);
2845 else if (TARGET_POPCNTB)
2846 target_flags |= (ISA_2_2_MASKS & ~target_flags_explicit);
2847 else if (TARGET_ALTIVEC)
2848 target_flags |= (MASK_PPC_GFXOPT & ~target_flags_explicit);
2850 /* E500mc does "better" if we inline more aggressively. Respect the
2851 user's opinion, though. */
2852 if (rs6000_block_move_inline_limit == 0
2853 && (rs6000_cpu == PROCESSOR_PPCE500MC
2854 || rs6000_cpu == PROCESSOR_PPCE500MC64))
2855 rs6000_block_move_inline_limit = 128;
2857 /* store_one_arg depends on expand_block_move to handle at least the
2858 size of reg_parm_stack_space. */
2859 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32))
2860 rs6000_block_move_inline_limit = (TARGET_POWERPC64 ? 64 : 32);
2864 /* If the appropriate debug option is enabled, replace the target hooks
2865 with debug versions that call the real version and then prints
2866 debugging information. */
2867 if (TARGET_DEBUG_COST)
2869 targetm.rtx_costs = rs6000_debug_rtx_costs;
2870 targetm.address_cost = rs6000_debug_address_cost;
2871 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2874 if (TARGET_DEBUG_ADDR)
2876 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2877 targetm.legitimize_address = rs6000_debug_legitimize_address;
2878 rs6000_secondary_reload_class_ptr
2879 = rs6000_debug_secondary_reload_class;
2880 rs6000_secondary_memory_needed_ptr
2881 = rs6000_debug_secondary_memory_needed;
2882 rs6000_cannot_change_mode_class_ptr
2883 = rs6000_debug_cannot_change_mode_class;
2884 rs6000_preferred_reload_class_ptr
2885 = rs6000_debug_preferred_reload_class;
2886 rs6000_legitimize_reload_address_ptr
2887 = rs6000_debug_legitimize_reload_address;
2888 rs6000_mode_dependent_address_ptr
2889 = rs6000_debug_mode_dependent_address;
2892 if (rs6000_veclibabi_name)
2894 if (strcmp (rs6000_veclibabi_name, "mass") == 0)
2895 rs6000_veclib_handler = rs6000_builtin_vectorized_libmass;
2898 error ("unknown vectorization library ABI type (%s) for "
2899 "-mveclibabi= switch", rs6000_veclibabi_name);
2905 if (!rs6000_explicit_options.long_double)
2907 if (main_target_opt != NULL
2908 && (main_target_opt->x_rs6000_long_double_type_size
2909 != RS6000_DEFAULT_LONG_DOUBLE_SIZE))
2910 error ("target attribute or pragma changes long double size");
2912 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2915 #ifndef POWERPC_LINUX
2916 if (!rs6000_explicit_options.ieee)
2917 rs6000_ieeequad = 1;
2920 /* Disable VSX and Altivec silently if the user switched cpus to power7 in a
2921 target attribute or pragma which automatically enables both options,
2922 unless the altivec ABI was set. This is set by default for 64-bit, but
2924 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2925 target_flags &= ~((MASK_VSX | MASK_ALTIVEC) & ~target_flags_explicit);
2927 /* Enable Altivec ABI for AIX -maltivec. */
2928 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2930 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2931 error ("target attribute or pragma changes AltiVec ABI");
2933 rs6000_altivec_abi = 1;
2936 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2937 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2938 be explicitly overridden in either case. */
2941 if (!rs6000_explicit_options.altivec_abi
2942 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2944 if (main_target_opt != NULL &&
2945 !main_target_opt->x_rs6000_altivec_abi)
2946 error ("target attribute or pragma changes AltiVec ABI");
2948 rs6000_altivec_abi = 1;
2951 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2952 if (!rs6000_explicit_options.vrsave)
2953 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2956 /* Set the Darwin64 ABI as default for 64-bit Darwin.
2957 So far, the only darwin64 targets are also MACH-O. */
2959 && DEFAULT_ABI == ABI_DARWIN
2962 if (main_target_opt != NULL && !main_target_opt->x_rs6000_darwin64_abi)
2963 error ("target attribute or pragma changes darwin64 ABI");
2966 rs6000_darwin64_abi = 1;
2967 /* Default to natural alignment, for better performance. */
2968 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2972 /* Place FP constants in the constant pool instead of TOC
2973 if section anchors enabled. */
2974 if (flag_section_anchors)
2975 TARGET_NO_FP_IN_TOC = 1;
2977 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2978 SUBTARGET_OVERRIDE_OPTIONS;
2980 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2981 SUBSUBTARGET_OVERRIDE_OPTIONS;
2983 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2984 SUB3TARGET_OVERRIDE_OPTIONS;
2987 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2988 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2990 /* The e500 and e500mc do not have string instructions, and we set
2991 MASK_STRING above when optimizing for size. */
2992 if ((target_flags & MASK_STRING) != 0)
2993 target_flags = target_flags & ~MASK_STRING;
2995 else if (rs6000_select[1].string != NULL)
2997 /* For the powerpc-eabispe configuration, we set all these by
2998 default, so let's unset them if we manually set another
2999 CPU that is not the E500. */
3000 if (main_target_opt != NULL
3001 && ((main_target_opt->x_rs6000_spe_abi != rs6000_spe_abi)
3002 || (main_target_opt->x_rs6000_spe != rs6000_spe)
3003 || (main_target_opt->x_rs6000_float_gprs != rs6000_float_gprs)))
3004 error ("target attribute or pragma changes SPE ABI");
3007 if (!rs6000_explicit_options.spe_abi)
3009 if (!rs6000_explicit_options.spe)
3011 if (!rs6000_explicit_options.float_gprs)
3012 rs6000_float_gprs = 0;
3014 if (!(target_flags_explicit & MASK_ISEL))
3015 target_flags &= ~MASK_ISEL;
3018 /* Detect invalid option combinations with E500. */
3021 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
3022 && rs6000_cpu != PROCESSOR_POWER5
3023 && rs6000_cpu != PROCESSOR_POWER6
3024 && rs6000_cpu != PROCESSOR_POWER7
3025 && rs6000_cpu != PROCESSOR_PPCA2
3026 && rs6000_cpu != PROCESSOR_CELL);
3027 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
3028 || rs6000_cpu == PROCESSOR_POWER5
3029 || rs6000_cpu == PROCESSOR_POWER7);
3030 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
3031 || rs6000_cpu == PROCESSOR_POWER5
3032 || rs6000_cpu == PROCESSOR_POWER6
3033 || rs6000_cpu == PROCESSOR_POWER7
3034 || rs6000_cpu == PROCESSOR_PPCE500MC
3035 || rs6000_cpu == PROCESSOR_PPCE500MC64);
3037 /* Allow debug switches to override the above settings. These are set to -1
3038 in rs6000.opt to indicate the user hasn't directly set the switch. */
3039 if (TARGET_ALWAYS_HINT >= 0)
3040 rs6000_always_hint = TARGET_ALWAYS_HINT;
3042 if (TARGET_SCHED_GROUPS >= 0)
3043 rs6000_sched_groups = TARGET_SCHED_GROUPS;
3045 if (TARGET_ALIGN_BRANCH_TARGETS >= 0)
3046 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
3048 rs6000_sched_restricted_insns_priority
3049 = (rs6000_sched_groups ? 1 : 0);
3051 /* Handle -msched-costly-dep option. */
3052 rs6000_sched_costly_dep
3053 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
3055 if (rs6000_sched_costly_dep_str)
3057 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
3058 rs6000_sched_costly_dep = no_dep_costly;
3059 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
3060 rs6000_sched_costly_dep = all_deps_costly;
3061 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
3062 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
3063 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
3064 rs6000_sched_costly_dep = store_to_load_dep_costly;
3066 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
3067 atoi (rs6000_sched_costly_dep_str));
3070 /* Handle -minsert-sched-nops option. */
3071 rs6000_sched_insert_nops
3072 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
3074 if (rs6000_sched_insert_nops_str)
3076 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
3077 rs6000_sched_insert_nops = sched_finish_none;
3078 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
3079 rs6000_sched_insert_nops = sched_finish_pad_groups;
3080 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
3081 rs6000_sched_insert_nops = sched_finish_regroup_exact;
3083 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
3084 atoi (rs6000_sched_insert_nops_str));
3089 #ifdef TARGET_REGNAMES
3090 /* If the user desires alternate register names, copy in the
3091 alternate names now. */
3092 if (TARGET_REGNAMES)
3093 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
3096 /* Set aix_struct_return last, after the ABI is determined.
3097 If -maix-struct-return or -msvr4-struct-return was explicitly
3098 used, don't override with the ABI default. */
3099 if (!rs6000_explicit_options.aix_struct_ret)
3100 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
3103 /* IBM XL compiler defaults to unsigned bitfields. */
3104 if (TARGET_XL_COMPAT)
3105 flag_signed_bitfields = 0;
3108 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
3109 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
3112 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
3114 /* We can only guarantee the availability of DI pseudo-ops when
3115 assembling for 64-bit targets. */
3118 targetm.asm_out.aligned_op.di = NULL;
3119 targetm.asm_out.unaligned_op.di = NULL;
3123 /* Set branch target alignment, if not optimizing for size. */
3126 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be
3127 aligned 8byte to avoid misprediction by the branch predictor. */
3128 if (rs6000_cpu == PROCESSOR_TITAN
3129 || rs6000_cpu == PROCESSOR_CELL)
3131 if (align_functions <= 0)
3132 align_functions = 8;
3133 if (align_jumps <= 0)
3135 if (align_loops <= 0)
3138 if (rs6000_align_branch_targets)
3140 if (align_functions <= 0)
3141 align_functions = 16;
3142 if (align_jumps <= 0)
3144 if (align_loops <= 0)
3146 can_override_loop_align = 1;
3150 if (align_jumps_max_skip <= 0)
3151 align_jumps_max_skip = 15;
3152 if (align_loops_max_skip <= 0)
3153 align_loops_max_skip = 15;
3156 /* Arrange to save and restore machine status around nested functions. */
3157 init_machine_status = rs6000_init_machine_status;
3159 /* We should always be splitting complex arguments, but we can't break
3160 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
3161 if (DEFAULT_ABI != ABI_AIX)
3162 targetm.calls.split_complex_arg = NULL;
3165 /* Initialize rs6000_cost with the appropriate target costs. */
3167 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
3171 case PROCESSOR_RIOS1:
3172 rs6000_cost = &rios1_cost;
3175 case PROCESSOR_RIOS2:
3176 rs6000_cost = &rios2_cost;
3179 case PROCESSOR_RS64A:
3180 rs6000_cost = &rs64a_cost;
3183 case PROCESSOR_MPCCORE:
3184 rs6000_cost = &mpccore_cost;
3187 case PROCESSOR_PPC403:
3188 rs6000_cost = &ppc403_cost;
3191 case PROCESSOR_PPC405:
3192 rs6000_cost = &ppc405_cost;
3195 case PROCESSOR_PPC440:
3196 rs6000_cost = &ppc440_cost;
3199 case PROCESSOR_PPC476:
3200 rs6000_cost = &ppc476_cost;
3203 case PROCESSOR_PPC601:
3204 rs6000_cost = &ppc601_cost;
3207 case PROCESSOR_PPC603:
3208 rs6000_cost = &ppc603_cost;
3211 case PROCESSOR_PPC604:
3212 rs6000_cost = &ppc604_cost;
3215 case PROCESSOR_PPC604e:
3216 rs6000_cost = &ppc604e_cost;
3219 case PROCESSOR_PPC620:
3220 rs6000_cost = &ppc620_cost;
3223 case PROCESSOR_PPC630:
3224 rs6000_cost = &ppc630_cost;
3227 case PROCESSOR_CELL:
3228 rs6000_cost = &ppccell_cost;
3231 case PROCESSOR_PPC750:
3232 case PROCESSOR_PPC7400:
3233 rs6000_cost = &ppc750_cost;
3236 case PROCESSOR_PPC7450:
3237 rs6000_cost = &ppc7450_cost;
3240 case PROCESSOR_PPC8540:
3241 rs6000_cost = &ppc8540_cost;
3244 case PROCESSOR_PPCE300C2:
3245 case PROCESSOR_PPCE300C3:
3246 rs6000_cost = &ppce300c2c3_cost;
3249 case PROCESSOR_PPCE500MC:
3250 rs6000_cost = &ppce500mc_cost;
3253 case PROCESSOR_PPCE500MC64:
3254 rs6000_cost = &ppce500mc64_cost;
3257 case PROCESSOR_TITAN:
3258 rs6000_cost = &titan_cost;
3261 case PROCESSOR_POWER4:
3262 case PROCESSOR_POWER5:
3263 rs6000_cost = &power4_cost;
3266 case PROCESSOR_POWER6:
3267 rs6000_cost = &power6_cost;
3270 case PROCESSOR_POWER7:
3271 rs6000_cost = &power7_cost;
3274 case PROCESSOR_PPCA2:
3275 rs6000_cost = &ppca2_cost;
3284 maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
3285 rs6000_cost->simultaneous_prefetches,
3286 global_options.x_param_values,
3287 global_options_set.x_param_values);
3288 maybe_set_param_value (PARAM_L1_CACHE_SIZE, rs6000_cost->l1_cache_size,
3289 global_options.x_param_values,
3290 global_options_set.x_param_values);
3291 maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
3292 rs6000_cost->cache_line_size,
3293 global_options.x_param_values,
3294 global_options_set.x_param_values);
3295 maybe_set_param_value (PARAM_L2_CACHE_SIZE, rs6000_cost->l2_cache_size,
3296 global_options.x_param_values,
3297 global_options_set.x_param_values);
3299 /* If using typedef char *va_list, signal that
3300 __builtin_va_start (&ap, 0) can be optimized to
3301 ap = __builtin_next_arg (0). */
3302 if (DEFAULT_ABI != ABI_V4)
3303 targetm.expand_builtin_va_start = NULL;
3306 /* Set up single/double float flags.
3307 If TARGET_HARD_FLOAT is set, but neither single or double is set,
3308 then set both flags. */
3309 if (TARGET_HARD_FLOAT && TARGET_FPRS
3310 && rs6000_single_float == 0 && rs6000_double_float == 0)
3311 rs6000_single_float = rs6000_double_float = 1;
3313 /* Reset single and double FP flags if target is E500. */
3316 rs6000_single_float = rs6000_double_float = 0;
3317 if (TARGET_E500_SINGLE)
3318 rs6000_single_float = 1;
3319 if (TARGET_E500_DOUBLE)
3320 rs6000_single_float = rs6000_double_float = 1;
3323 if (main_target_opt)
3325 if (main_target_opt->x_rs6000_single_float != rs6000_single_float)
3326 error ("target attribute or pragma changes single precision floating "
3328 if (main_target_opt->x_rs6000_double_float != rs6000_double_float)
3329 error ("target attribute or pragma changes double precision floating "
3333 /* If not explicitly specified via option, decide whether to generate indexed
3334 load/store instructions. */
3335 if (TARGET_AVOID_XFORM == -1)
3336 /* Avoid indexed addressing when targeting Power6 in order to avoid the
3337 DERAT mispredict penalty. However the LVE and STVE altivec instructions
3338 need indexed accesses and the type used is the scalar type of the element
3339 being loaded or stored. */
3340 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB
3341 && !TARGET_ALTIVEC);
3343 /* Set the -mrecip options. */
3344 if (rs6000_recip_name)
3346 char *p = ASTRDUP (rs6000_recip_name);
3348 unsigned int mask, i;
3351 while ((q = strtok (p, ",")) != NULL)
3362 if (!strcmp (q, "default"))
3363 mask = ((TARGET_RECIP_PRECISION)
3364 ? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION);
3367 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
3368 if (!strcmp (q, recip_options[i].string))
3370 mask = recip_options[i].mask;
3374 if (i == ARRAY_SIZE (recip_options))
3376 error ("unknown option for -mrecip=%s", q);
3384 rs6000_recip_control &= ~mask;
3386 rs6000_recip_control |= mask;
3390 rs6000_init_hard_regno_mode_ok (global_init_p);
3392 /* Save the initial options in case the user does function specific options */
3394 target_option_default_node = target_option_current_node
3395 = build_target_option_node ();
3400 /* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to
3401 define the target cpu type. */
3404 rs6000_option_override (void)
3406 (void) rs6000_option_override_internal (true);
3410 /* Implement targetm.vectorize.builtin_mask_for_load. */
3412 rs6000_builtin_mask_for_load (void)
3414 if (TARGET_ALTIVEC || TARGET_VSX)
3415 return altivec_builtin_mask_for_load;
3420 /* Implement LOOP_ALIGN. */
3422 rs6000_loop_align (rtx label)
3427 /* Don't override loop alignment if -falign-loops was specified. */
3428 if (!can_override_loop_align)
3429 return align_loops_log;
3431 bb = BLOCK_FOR_INSN (label);
3432 ninsns = num_loop_insns(bb->loop_father);
3434 /* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */
3435 if (ninsns > 4 && ninsns <= 8
3436 && (rs6000_cpu == PROCESSOR_POWER4
3437 || rs6000_cpu == PROCESSOR_POWER5
3438 || rs6000_cpu == PROCESSOR_POWER6
3439 || rs6000_cpu == PROCESSOR_POWER7))
3442 return align_loops_log;
3445 /* Implement TARGET_LOOP_ALIGN_MAX_SKIP. */
3447 rs6000_loop_align_max_skip (rtx label)
3449 return (1 << rs6000_loop_align (label)) - 1;
3452 /* Implement targetm.vectorize.builtin_conversion.
3453 Returns a decl of a function that implements conversion of an integer vector
3454 into a floating-point vector, or vice-versa. DEST_TYPE is the
3455 destination type and SRC_TYPE the source type of the conversion.
3456 Return NULL_TREE if it is not available. */
3458 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
3460 enum tree_code code = (enum tree_code) tcode;
3464 case FIX_TRUNC_EXPR:
3465 switch (TYPE_MODE (dest_type))
3468 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3471 return TYPE_UNSIGNED (dest_type)
3472 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
3473 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
3476 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3479 return TYPE_UNSIGNED (dest_type)
3480 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
3481 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
3488 switch (TYPE_MODE (src_type))
3491 if (!VECTOR_UNIT_VSX_P (V2DFmode))
3494 return TYPE_UNSIGNED (src_type)
3495 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
3496 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
3499 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
3502 return TYPE_UNSIGNED (src_type)
3503 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
3504 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
3515 /* Implement targetm.vectorize.builtin_mul_widen_even. */
3517 rs6000_builtin_mul_widen_even (tree type)
3519 if (!TARGET_ALTIVEC)
3522 switch (TYPE_MODE (type))
3525 return TYPE_UNSIGNED (type)
3526 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
3527 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
3530 return TYPE_UNSIGNED (type)
3531 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
3532 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
3538 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
3540 rs6000_builtin_mul_widen_odd (tree type)
3542 if (!TARGET_ALTIVEC)
3545 switch (TYPE_MODE (type))
3548 return TYPE_UNSIGNED (type)
3549 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
3550 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
3553 return TYPE_UNSIGNED (type)
3554 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
3555 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
3562 /* Return true iff, data reference of TYPE can reach vector alignment (16)
3563 after applying N number of iterations. This routine does not determine
3564 how may iterations are required to reach desired alignment. */
3567 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3574 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3577 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3587 /* Assuming that all other types are naturally aligned. CHECKME! */
3592 /* Return true if the vector misalignment factor is supported by the
3595 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3602 /* Return if movmisalign pattern is not supported for this mode. */
3603 if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing)
3606 if (misalignment == -1)
3608 /* Misalignment factor is unknown at compile time but we know
3609 it's word aligned. */
3610 if (rs6000_vector_alignment_reachable (type, is_packed))
3612 int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type));
3614 if (element_size == 64 || element_size == 32)
3621 /* VSX supports word-aligned vector. */
3622 if (misalignment % 4 == 0)
3628 /* Implement targetm.vectorize.builtin_vec_perm. */
3630 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
3632 tree inner_type = TREE_TYPE (type);
3633 bool uns_p = TYPE_UNSIGNED (inner_type);
3636 *mask_element_type = unsigned_char_type_node;
3638 switch (TYPE_MODE (type))
3642 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI_UNS]
3643 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI]);
3648 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI_UNS]
3649 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI]);
3654 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI_UNS]
3655 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI]);
3659 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
3663 if (!TARGET_ALLOW_DF_PERMUTE)
3666 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DF];
3670 if (!TARGET_ALLOW_DF_PERMUTE)
3674 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI_UNS]
3675 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI]);
3687 /* Implement targetm.vectorize.builtin_vectorization_cost. */
3689 rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
3690 tree vectype, int misalign)
3694 switch (type_of_cost)
3704 case cond_branch_not_taken:
3708 case cond_branch_taken:
3711 case unaligned_load:
3712 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3714 elements = TYPE_VECTOR_SUBPARTS (vectype);
3716 /* Double word aligned. */
3724 /* Double word aligned. */
3728 /* Unknown misalignment. */
3741 /* Misaligned loads are not supported. */
3746 case unaligned_store:
3747 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3749 elements = TYPE_VECTOR_SUBPARTS (vectype);
3751 /* Double word aligned. */
3759 /* Double word aligned. */
3763 /* Unknown misalignment. */
3776 /* Misaligned stores are not supported. */
3786 /* Implement targetm.vectorize.preferred_simd_mode. */
3788 static enum machine_mode
3789 rs6000_preferred_simd_mode (enum machine_mode mode)
3798 if (TARGET_ALTIVEC || TARGET_VSX)
3822 if (TARGET_PAIRED_FLOAT
3828 /* Handle generic options of the form -mfoo=yes/no.
3829 NAME is the option name.
3830 VALUE is the option value.
3831 FLAG is the pointer to the flag where to store a 1 or 0, depending on
3832 whether the option value is 'yes' or 'no' respectively. */
3834 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
3838 else if (!strcmp (value, "yes"))
3840 else if (!strcmp (value, "no"))
3843 error ("unknown -m%s= option specified: '%s'", name, value);
3846 /* Implement TARGET_OPTION_INIT_STRUCT. */
3849 rs6000_option_init_struct (struct gcc_options *opts)
3851 if (DEFAULT_ABI == ABI_DARWIN)
3852 /* The Darwin libraries never set errno, so we might as well
3853 avoid calling them when that's the only reason we would. */
3854 opts->x_flag_errno_math = 0;
3856 /* Enable section anchors by default. */
3858 opts->x_flag_section_anchors = 1;
3861 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */
3864 rs6000_option_default_params (void)
3866 /* Double growth factor to counter reduced min jump length. */
3867 set_default_param_value (PARAM_MAX_GROW_COPY_BB_INSNS, 16);
3870 static enum fpu_type_t
3871 rs6000_parse_fpu_option (const char *option)
3873 if (!strcmp("none", option)) return FPU_NONE;
3874 if (!strcmp("sp_lite", option)) return FPU_SF_LITE;
3875 if (!strcmp("dp_lite", option)) return FPU_DF_LITE;
3876 if (!strcmp("sp_full", option)) return FPU_SF_FULL;
3877 if (!strcmp("dp_full", option)) return FPU_DF_FULL;
3878 error("unknown value %s for -mfpu", option);
3883 /* Handler for the Mathematical Acceleration Subsystem (mass) interface to a
3884 library with vectorized intrinsics. */
3887 rs6000_builtin_vectorized_libmass (tree fndecl, tree type_out, tree type_in)
3890 const char *suffix = NULL;
3891 tree fntype, new_fndecl, bdecl = NULL_TREE;
3894 enum machine_mode el_mode, in_mode;
3897 /* Libmass is suitable for unsafe math only as it does not correctly support
3898 parts of IEEE with the required precision such as denormals. Only support
3899 it if we have VSX to use the simd d2 or f4 functions.
3900 XXX: Add variable length support. */
3901 if (!flag_unsafe_math_optimizations || !TARGET_VSX)
3904 el_mode = TYPE_MODE (TREE_TYPE (type_out));
3905 n = TYPE_VECTOR_SUBPARTS (type_out);
3906 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3907 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3908 if (el_mode != in_mode
3912 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
3914 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3917 case BUILT_IN_ATAN2:
3918 case BUILT_IN_HYPOT:
3924 case BUILT_IN_ACOSH:
3926 case BUILT_IN_ASINH:
3928 case BUILT_IN_ATANH:
3936 case BUILT_IN_EXPM1:
3937 case BUILT_IN_LGAMMA:
3938 case BUILT_IN_LOG10:
3939 case BUILT_IN_LOG1P:
3947 bdecl = implicit_built_in_decls[fn];
3948 suffix = "d2"; /* pow -> powd2 */
3949 if (el_mode != DFmode
3954 case BUILT_IN_ATAN2F:
3955 case BUILT_IN_HYPOTF:
3960 case BUILT_IN_ACOSF:
3961 case BUILT_IN_ACOSHF:
3962 case BUILT_IN_ASINF:
3963 case BUILT_IN_ASINHF: