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,
5 Free Software Foundation, Inc.
6 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published
12 by the Free Software Foundation; either version 3, or (at your
13 option) any later version.
15 GCC is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
26 #include "coretypes.h"
30 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
45 #include "diagnostic-core.h"
51 #include "target-def.h"
52 #include "common/common-target.h"
53 #include "langhooks.h"
55 #include "cfglayout.h"
57 #include "sched-int.h"
59 #include "tree-flow.h"
62 #include "tm-constrs.h"
65 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
68 #include "gstab.h" /* for N_SLINE */
71 #ifndef TARGET_NO_PROTOTYPE
72 #define TARGET_NO_PROTOTYPE 0
75 #define min(A,B) ((A) < (B) ? (A) : (B))
76 #define max(A,B) ((A) > (B) ? (A) : (B))
78 /* Structure used to define the rs6000 stack */
79 typedef struct rs6000_stack {
80 int reload_completed; /* stack info won't change from here on */
81 int first_gp_reg_save; /* first callee saved GP register used */
82 int first_fp_reg_save; /* first callee saved FP register used */
83 int first_altivec_reg_save; /* first callee saved AltiVec register used */
84 int lr_save_p; /* true if the link reg needs to be saved */
85 int cr_save_p; /* true if the CR reg needs to be saved */
86 unsigned int vrsave_mask; /* mask of vec registers to save */
87 int push_p; /* true if we need to allocate stack space */
88 int calls_p; /* true if the function makes any calls */
89 int world_save_p; /* true if we're saving *everything*:
90 r13-r31, cr, f14-f31, vrsave, v20-v31 */
91 enum rs6000_abi abi; /* which ABI to use */
92 int gp_save_offset; /* offset to save GP regs from initial SP */
93 int fp_save_offset; /* offset to save FP regs from initial SP */
94 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
95 int lr_save_offset; /* offset to save LR from initial SP */
96 int cr_save_offset; /* offset to save CR from initial SP */
97 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
98 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
99 int varargs_save_offset; /* offset to save the varargs registers */
100 int ehrd_offset; /* offset to EH return data */
101 int reg_size; /* register size (4 or 8) */
102 HOST_WIDE_INT vars_size; /* variable save area size */
103 int parm_size; /* outgoing parameter size */
104 int save_size; /* save area size */
105 int fixed_size; /* fixed size of stack frame */
106 int gp_size; /* size of saved GP registers */
107 int fp_size; /* size of saved FP registers */
108 int altivec_size; /* size of saved AltiVec registers */
109 int cr_size; /* size to hold CR if not in save_size */
110 int vrsave_size; /* size to hold VRSAVE if not in save_size */
111 int altivec_padding_size; /* size of altivec alignment padding if
113 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
114 int spe_padding_size;
115 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
116 int spe_64bit_regs_used;
120 /* A C structure for machine-specific, per-function data.
121 This is added to the cfun structure. */
122 typedef struct GTY(()) machine_function
124 /* Some local-dynamic symbol. */
125 const char *some_ld_name;
126 /* Whether the instruction chain has been scanned already. */
127 int insn_chain_scanned_p;
128 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
129 int ra_needs_full_frame;
130 /* Flags if __builtin_return_address (0) was used. */
132 /* Cache lr_save_p after expansion of builtin_eh_return. */
134 /* Whether we need to save the TOC to the reserved stack location in the
135 function prologue. */
136 bool save_toc_in_prologue;
137 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
138 varargs save area. */
139 HOST_WIDE_INT varargs_save_offset;
140 /* Temporary stack slot to use for SDmode copies. This slot is
141 64-bits wide and is allocated early enough so that the offset
142 does not overflow the 16-bit load/store offset field. */
143 rtx sdmode_stack_slot;
146 /* Support targetm.vectorize.builtin_mask_for_load. */
147 static GTY(()) tree altivec_builtin_mask_for_load;
149 /* Set to nonzero once AIX common-mode calls have been defined. */
150 static GTY(()) int common_mode_defined;
152 /* Label number of label created for -mrelocatable, to call to so we can
153 get the address of the GOT section */
154 static int rs6000_pic_labelno;
157 /* Counter for labels which are to be placed in .fixup. */
158 int fixuplabelno = 0;
161 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
164 /* Specify the machine mode that pointers have. After generation of rtl, the
165 compiler makes no further distinction between pointers and any other objects
166 of this machine mode. The type is unsigned since not all things that
167 include rs6000.h also include machmode.h. */
168 unsigned rs6000_pmode;
170 /* Width in bits of a pointer. */
171 unsigned rs6000_pointer_size;
173 #ifdef HAVE_AS_GNU_ATTRIBUTE
174 /* Flag whether floating point values have been passed/returned. */
175 static bool rs6000_passes_float;
176 /* Flag whether vector values have been passed/returned. */
177 static bool rs6000_passes_vector;
178 /* Flag whether small (<= 8 byte) structures have been returned. */
179 static bool rs6000_returns_struct;
182 /* Value is TRUE if register/mode pair is acceptable. */
183 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
185 /* Maximum number of registers needed for a given register class and mode. */
186 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
188 /* How many registers are needed for a given register and mode. */
189 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
191 /* Map register number to register class. */
192 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
194 /* Reload functions based on the type and the vector unit. */
195 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
197 static int dbg_cost_ctrl;
199 /* Built in types. */
200 tree rs6000_builtin_types[RS6000_BTI_MAX];
201 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
203 /* Flag to say the TOC is initialized */
205 char toc_label_name[10];
207 /* Cached value of rs6000_variable_issue. This is cached in
208 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
209 static short cached_can_issue_more;
211 static GTY(()) section *read_only_data_section;
212 static GTY(()) section *private_data_section;
213 static GTY(()) section *read_only_private_data_section;
214 static GTY(()) section *sdata2_section;
215 static GTY(()) section *toc_section;
217 struct builtin_description
219 const unsigned int mask;
220 const enum insn_code icode;
221 const char *const name;
222 const enum rs6000_builtins code;
225 /* Describe the vector unit used for modes. */
226 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
227 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
229 /* Register classes for various constraints that are based on the target
231 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
233 /* Describe the alignment of a vector. */
234 int rs6000_vector_align[NUM_MACHINE_MODES];
236 /* Map selected modes to types for builtins. */
237 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
239 /* What modes to automatically generate reciprocal divide estimate (fre) and
240 reciprocal sqrt (frsqrte) for. */
241 unsigned char rs6000_recip_bits[MAX_MACHINE_MODE];
243 /* Masks to determine which reciprocal esitmate instructions to generate
245 enum rs6000_recip_mask {
246 RECIP_SF_DIV = 0x001, /* Use divide estimate */
247 RECIP_DF_DIV = 0x002,
248 RECIP_V4SF_DIV = 0x004,
249 RECIP_V2DF_DIV = 0x008,
251 RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */
252 RECIP_DF_RSQRT = 0x020,
253 RECIP_V4SF_RSQRT = 0x040,
254 RECIP_V2DF_RSQRT = 0x080,
256 /* Various combination of flags for -mrecip=xxx. */
258 RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
259 | RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT
260 | RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT),
262 RECIP_HIGH_PRECISION = RECIP_ALL,
264 /* On low precision machines like the power5, don't enable double precision
265 reciprocal square root estimate, since it isn't accurate enough. */
266 RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT))
269 /* -mrecip options. */
272 const char *string; /* option name */
273 unsigned int mask; /* mask bits to set */
274 } recip_options[] = {
275 { "all", RECIP_ALL },
276 { "none", RECIP_NONE },
277 { "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV
279 { "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) },
280 { "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) },
281 { "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT
282 | RECIP_V2DF_RSQRT) },
283 { "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) },
284 { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) },
287 /* 2 argument gen function typedef. */
288 typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx);
290 /* Pointer to function (in rs6000-c.c) that can define or undefine target
291 macros that have changed. Languages that don't support the preprocessor
292 don't link in rs6000-c.c, so we can't call it directly. */
293 void (*rs6000_target_modify_macros_ptr) (bool, int, unsigned);
296 /* Target cpu costs. */
298 struct processor_costs {
299 const int mulsi; /* cost of SImode multiplication. */
300 const int mulsi_const; /* cost of SImode multiplication by constant. */
301 const int mulsi_const9; /* cost of SImode mult by short constant. */
302 const int muldi; /* cost of DImode multiplication. */
303 const int divsi; /* cost of SImode division. */
304 const int divdi; /* cost of DImode division. */
305 const int fp; /* cost of simple SFmode and DFmode insns. */
306 const int dmul; /* cost of DFmode multiplication (and fmadd). */
307 const int sdiv; /* cost of SFmode division (fdivs). */
308 const int ddiv; /* cost of DFmode division (fdiv). */
309 const int cache_line_size; /* cache line size in bytes. */
310 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
311 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
312 const int simultaneous_prefetches; /* number of parallel prefetch
316 const struct processor_costs *rs6000_cost;
318 /* Processor costs (relative to an add) */
320 /* Instruction size costs on 32bit processors. */
322 struct processor_costs size32_cost = {
323 COSTS_N_INSNS (1), /* mulsi */
324 COSTS_N_INSNS (1), /* mulsi_const */
325 COSTS_N_INSNS (1), /* mulsi_const9 */
326 COSTS_N_INSNS (1), /* muldi */
327 COSTS_N_INSNS (1), /* divsi */
328 COSTS_N_INSNS (1), /* divdi */
329 COSTS_N_INSNS (1), /* fp */
330 COSTS_N_INSNS (1), /* dmul */
331 COSTS_N_INSNS (1), /* sdiv */
332 COSTS_N_INSNS (1), /* ddiv */
339 /* Instruction size costs on 64bit processors. */
341 struct processor_costs size64_cost = {
342 COSTS_N_INSNS (1), /* mulsi */
343 COSTS_N_INSNS (1), /* mulsi_const */
344 COSTS_N_INSNS (1), /* mulsi_const9 */
345 COSTS_N_INSNS (1), /* muldi */
346 COSTS_N_INSNS (1), /* divsi */
347 COSTS_N_INSNS (1), /* divdi */
348 COSTS_N_INSNS (1), /* fp */
349 COSTS_N_INSNS (1), /* dmul */
350 COSTS_N_INSNS (1), /* sdiv */
351 COSTS_N_INSNS (1), /* ddiv */
358 /* Instruction costs on RIOS1 processors. */
360 struct processor_costs rios1_cost = {
361 COSTS_N_INSNS (5), /* mulsi */
362 COSTS_N_INSNS (4), /* mulsi_const */
363 COSTS_N_INSNS (3), /* mulsi_const9 */
364 COSTS_N_INSNS (5), /* muldi */
365 COSTS_N_INSNS (19), /* divsi */
366 COSTS_N_INSNS (19), /* divdi */
367 COSTS_N_INSNS (2), /* fp */
368 COSTS_N_INSNS (2), /* dmul */
369 COSTS_N_INSNS (19), /* sdiv */
370 COSTS_N_INSNS (19), /* ddiv */
371 128, /* cache line size */
377 /* Instruction costs on RIOS2 processors. */
379 struct processor_costs rios2_cost = {
380 COSTS_N_INSNS (2), /* mulsi */
381 COSTS_N_INSNS (2), /* mulsi_const */
382 COSTS_N_INSNS (2), /* mulsi_const9 */
383 COSTS_N_INSNS (2), /* muldi */
384 COSTS_N_INSNS (13), /* divsi */
385 COSTS_N_INSNS (13), /* divdi */
386 COSTS_N_INSNS (2), /* fp */
387 COSTS_N_INSNS (2), /* dmul */
388 COSTS_N_INSNS (17), /* sdiv */
389 COSTS_N_INSNS (17), /* ddiv */
390 256, /* cache line size */
396 /* Instruction costs on RS64A processors. */
398 struct processor_costs rs64a_cost = {
399 COSTS_N_INSNS (20), /* mulsi */
400 COSTS_N_INSNS (12), /* mulsi_const */
401 COSTS_N_INSNS (8), /* mulsi_const9 */
402 COSTS_N_INSNS (34), /* muldi */
403 COSTS_N_INSNS (65), /* divsi */
404 COSTS_N_INSNS (67), /* divdi */
405 COSTS_N_INSNS (4), /* fp */
406 COSTS_N_INSNS (4), /* dmul */
407 COSTS_N_INSNS (31), /* sdiv */
408 COSTS_N_INSNS (31), /* ddiv */
409 128, /* cache line size */
415 /* Instruction costs on MPCCORE processors. */
417 struct processor_costs mpccore_cost = {
418 COSTS_N_INSNS (2), /* mulsi */
419 COSTS_N_INSNS (2), /* mulsi_const */
420 COSTS_N_INSNS (2), /* mulsi_const9 */
421 COSTS_N_INSNS (2), /* muldi */
422 COSTS_N_INSNS (6), /* divsi */
423 COSTS_N_INSNS (6), /* divdi */
424 COSTS_N_INSNS (4), /* fp */
425 COSTS_N_INSNS (5), /* dmul */
426 COSTS_N_INSNS (10), /* sdiv */
427 COSTS_N_INSNS (17), /* ddiv */
428 32, /* cache line size */
434 /* Instruction costs on PPC403 processors. */
436 struct processor_costs ppc403_cost = {
437 COSTS_N_INSNS (4), /* mulsi */
438 COSTS_N_INSNS (4), /* mulsi_const */
439 COSTS_N_INSNS (4), /* mulsi_const9 */
440 COSTS_N_INSNS (4), /* muldi */
441 COSTS_N_INSNS (33), /* divsi */
442 COSTS_N_INSNS (33), /* divdi */
443 COSTS_N_INSNS (11), /* fp */
444 COSTS_N_INSNS (11), /* dmul */
445 COSTS_N_INSNS (11), /* sdiv */
446 COSTS_N_INSNS (11), /* ddiv */
447 32, /* cache line size */
453 /* Instruction costs on PPC405 processors. */
455 struct processor_costs ppc405_cost = {
456 COSTS_N_INSNS (5), /* mulsi */
457 COSTS_N_INSNS (4), /* mulsi_const */
458 COSTS_N_INSNS (3), /* mulsi_const9 */
459 COSTS_N_INSNS (5), /* muldi */
460 COSTS_N_INSNS (35), /* divsi */
461 COSTS_N_INSNS (35), /* divdi */
462 COSTS_N_INSNS (11), /* fp */
463 COSTS_N_INSNS (11), /* dmul */
464 COSTS_N_INSNS (11), /* sdiv */
465 COSTS_N_INSNS (11), /* ddiv */
466 32, /* cache line size */
472 /* Instruction costs on PPC440 processors. */
474 struct processor_costs ppc440_cost = {
475 COSTS_N_INSNS (3), /* mulsi */
476 COSTS_N_INSNS (2), /* mulsi_const */
477 COSTS_N_INSNS (2), /* mulsi_const9 */
478 COSTS_N_INSNS (3), /* muldi */
479 COSTS_N_INSNS (34), /* divsi */
480 COSTS_N_INSNS (34), /* divdi */
481 COSTS_N_INSNS (5), /* fp */
482 COSTS_N_INSNS (5), /* dmul */
483 COSTS_N_INSNS (19), /* sdiv */
484 COSTS_N_INSNS (33), /* ddiv */
485 32, /* cache line size */
491 /* Instruction costs on PPC476 processors. */
493 struct processor_costs ppc476_cost = {
494 COSTS_N_INSNS (4), /* mulsi */
495 COSTS_N_INSNS (4), /* mulsi_const */
496 COSTS_N_INSNS (4), /* mulsi_const9 */
497 COSTS_N_INSNS (4), /* muldi */
498 COSTS_N_INSNS (11), /* divsi */
499 COSTS_N_INSNS (11), /* divdi */
500 COSTS_N_INSNS (6), /* fp */
501 COSTS_N_INSNS (6), /* dmul */
502 COSTS_N_INSNS (19), /* sdiv */
503 COSTS_N_INSNS (33), /* ddiv */
504 32, /* l1 cache line size */
510 /* Instruction costs on PPC601 processors. */
512 struct processor_costs ppc601_cost = {
513 COSTS_N_INSNS (5), /* mulsi */
514 COSTS_N_INSNS (5), /* mulsi_const */
515 COSTS_N_INSNS (5), /* mulsi_const9 */
516 COSTS_N_INSNS (5), /* muldi */
517 COSTS_N_INSNS (36), /* divsi */
518 COSTS_N_INSNS (36), /* divdi */
519 COSTS_N_INSNS (4), /* fp */
520 COSTS_N_INSNS (5), /* dmul */
521 COSTS_N_INSNS (17), /* sdiv */
522 COSTS_N_INSNS (31), /* ddiv */
523 32, /* cache line size */
529 /* Instruction costs on PPC603 processors. */
531 struct processor_costs ppc603_cost = {
532 COSTS_N_INSNS (5), /* mulsi */
533 COSTS_N_INSNS (3), /* mulsi_const */
534 COSTS_N_INSNS (2), /* mulsi_const9 */
535 COSTS_N_INSNS (5), /* muldi */
536 COSTS_N_INSNS (37), /* divsi */
537 COSTS_N_INSNS (37), /* divdi */
538 COSTS_N_INSNS (3), /* fp */
539 COSTS_N_INSNS (4), /* dmul */
540 COSTS_N_INSNS (18), /* sdiv */
541 COSTS_N_INSNS (33), /* ddiv */
542 32, /* cache line size */
548 /* Instruction costs on PPC604 processors. */
550 struct processor_costs ppc604_cost = {
551 COSTS_N_INSNS (4), /* mulsi */
552 COSTS_N_INSNS (4), /* mulsi_const */
553 COSTS_N_INSNS (4), /* mulsi_const9 */
554 COSTS_N_INSNS (4), /* muldi */
555 COSTS_N_INSNS (20), /* divsi */
556 COSTS_N_INSNS (20), /* divdi */
557 COSTS_N_INSNS (3), /* fp */
558 COSTS_N_INSNS (3), /* dmul */
559 COSTS_N_INSNS (18), /* sdiv */
560 COSTS_N_INSNS (32), /* ddiv */
561 32, /* cache line size */
567 /* Instruction costs on PPC604e processors. */
569 struct processor_costs ppc604e_cost = {
570 COSTS_N_INSNS (2), /* mulsi */
571 COSTS_N_INSNS (2), /* mulsi_const */
572 COSTS_N_INSNS (2), /* mulsi_const9 */
573 COSTS_N_INSNS (2), /* muldi */
574 COSTS_N_INSNS (20), /* divsi */
575 COSTS_N_INSNS (20), /* divdi */
576 COSTS_N_INSNS (3), /* fp */
577 COSTS_N_INSNS (3), /* dmul */
578 COSTS_N_INSNS (18), /* sdiv */
579 COSTS_N_INSNS (32), /* ddiv */
580 32, /* cache line size */
586 /* Instruction costs on PPC620 processors. */
588 struct processor_costs ppc620_cost = {
589 COSTS_N_INSNS (5), /* mulsi */
590 COSTS_N_INSNS (4), /* mulsi_const */
591 COSTS_N_INSNS (3), /* mulsi_const9 */
592 COSTS_N_INSNS (7), /* muldi */
593 COSTS_N_INSNS (21), /* divsi */
594 COSTS_N_INSNS (37), /* divdi */
595 COSTS_N_INSNS (3), /* fp */
596 COSTS_N_INSNS (3), /* dmul */
597 COSTS_N_INSNS (18), /* sdiv */
598 COSTS_N_INSNS (32), /* ddiv */
599 128, /* cache line size */
605 /* Instruction costs on PPC630 processors. */
607 struct processor_costs ppc630_cost = {
608 COSTS_N_INSNS (5), /* mulsi */
609 COSTS_N_INSNS (4), /* mulsi_const */
610 COSTS_N_INSNS (3), /* mulsi_const9 */
611 COSTS_N_INSNS (7), /* muldi */
612 COSTS_N_INSNS (21), /* divsi */
613 COSTS_N_INSNS (37), /* divdi */
614 COSTS_N_INSNS (3), /* fp */
615 COSTS_N_INSNS (3), /* dmul */
616 COSTS_N_INSNS (17), /* sdiv */
617 COSTS_N_INSNS (21), /* ddiv */
618 128, /* cache line size */
624 /* Instruction costs on Cell processor. */
625 /* COSTS_N_INSNS (1) ~ one add. */
627 struct processor_costs ppccell_cost = {
628 COSTS_N_INSNS (9/2)+2, /* mulsi */
629 COSTS_N_INSNS (6/2), /* mulsi_const */
630 COSTS_N_INSNS (6/2), /* mulsi_const9 */
631 COSTS_N_INSNS (15/2)+2, /* muldi */
632 COSTS_N_INSNS (38/2), /* divsi */
633 COSTS_N_INSNS (70/2), /* divdi */
634 COSTS_N_INSNS (10/2), /* fp */
635 COSTS_N_INSNS (10/2), /* dmul */
636 COSTS_N_INSNS (74/2), /* sdiv */
637 COSTS_N_INSNS (74/2), /* ddiv */
638 128, /* cache line size */
644 /* Instruction costs on PPC750 and PPC7400 processors. */
646 struct processor_costs ppc750_cost = {
647 COSTS_N_INSNS (5), /* mulsi */
648 COSTS_N_INSNS (3), /* mulsi_const */
649 COSTS_N_INSNS (2), /* mulsi_const9 */
650 COSTS_N_INSNS (5), /* muldi */
651 COSTS_N_INSNS (17), /* divsi */
652 COSTS_N_INSNS (17), /* divdi */
653 COSTS_N_INSNS (3), /* fp */
654 COSTS_N_INSNS (3), /* dmul */
655 COSTS_N_INSNS (17), /* sdiv */
656 COSTS_N_INSNS (31), /* ddiv */
657 32, /* cache line size */
663 /* Instruction costs on PPC7450 processors. */
665 struct processor_costs ppc7450_cost = {
666 COSTS_N_INSNS (4), /* mulsi */
667 COSTS_N_INSNS (3), /* mulsi_const */
668 COSTS_N_INSNS (3), /* mulsi_const9 */
669 COSTS_N_INSNS (4), /* muldi */
670 COSTS_N_INSNS (23), /* divsi */
671 COSTS_N_INSNS (23), /* divdi */
672 COSTS_N_INSNS (5), /* fp */
673 COSTS_N_INSNS (5), /* dmul */
674 COSTS_N_INSNS (21), /* sdiv */
675 COSTS_N_INSNS (35), /* ddiv */
676 32, /* cache line size */
682 /* Instruction costs on PPC8540 processors. */
684 struct processor_costs ppc8540_cost = {
685 COSTS_N_INSNS (4), /* mulsi */
686 COSTS_N_INSNS (4), /* mulsi_const */
687 COSTS_N_INSNS (4), /* mulsi_const9 */
688 COSTS_N_INSNS (4), /* muldi */
689 COSTS_N_INSNS (19), /* divsi */
690 COSTS_N_INSNS (19), /* divdi */
691 COSTS_N_INSNS (4), /* fp */
692 COSTS_N_INSNS (4), /* dmul */
693 COSTS_N_INSNS (29), /* sdiv */
694 COSTS_N_INSNS (29), /* ddiv */
695 32, /* cache line size */
698 1, /* prefetch streams /*/
701 /* Instruction costs on E300C2 and E300C3 cores. */
703 struct processor_costs ppce300c2c3_cost = {
704 COSTS_N_INSNS (4), /* mulsi */
705 COSTS_N_INSNS (4), /* mulsi_const */
706 COSTS_N_INSNS (4), /* mulsi_const9 */
707 COSTS_N_INSNS (4), /* muldi */
708 COSTS_N_INSNS (19), /* divsi */
709 COSTS_N_INSNS (19), /* divdi */
710 COSTS_N_INSNS (3), /* fp */
711 COSTS_N_INSNS (4), /* dmul */
712 COSTS_N_INSNS (18), /* sdiv */
713 COSTS_N_INSNS (33), /* ddiv */
717 1, /* prefetch streams /*/
720 /* Instruction costs on PPCE500MC processors. */
722 struct processor_costs ppce500mc_cost = {
723 COSTS_N_INSNS (4), /* mulsi */
724 COSTS_N_INSNS (4), /* mulsi_const */
725 COSTS_N_INSNS (4), /* mulsi_const9 */
726 COSTS_N_INSNS (4), /* muldi */
727 COSTS_N_INSNS (14), /* divsi */
728 COSTS_N_INSNS (14), /* divdi */
729 COSTS_N_INSNS (8), /* fp */
730 COSTS_N_INSNS (10), /* dmul */
731 COSTS_N_INSNS (36), /* sdiv */
732 COSTS_N_INSNS (66), /* ddiv */
733 64, /* cache line size */
736 1, /* prefetch streams /*/
739 /* Instruction costs on PPCE500MC64 processors. */
741 struct processor_costs ppce500mc64_cost = {
742 COSTS_N_INSNS (4), /* mulsi */
743 COSTS_N_INSNS (4), /* mulsi_const */
744 COSTS_N_INSNS (4), /* mulsi_const9 */
745 COSTS_N_INSNS (4), /* muldi */
746 COSTS_N_INSNS (14), /* divsi */
747 COSTS_N_INSNS (14), /* divdi */
748 COSTS_N_INSNS (4), /* fp */
749 COSTS_N_INSNS (10), /* dmul */
750 COSTS_N_INSNS (36), /* sdiv */
751 COSTS_N_INSNS (66), /* ddiv */
752 64, /* cache line size */
755 1, /* prefetch streams /*/
758 /* Instruction costs on AppliedMicro Titan processors. */
760 struct processor_costs titan_cost = {
761 COSTS_N_INSNS (5), /* mulsi */
762 COSTS_N_INSNS (5), /* mulsi_const */
763 COSTS_N_INSNS (5), /* mulsi_const9 */
764 COSTS_N_INSNS (5), /* muldi */
765 COSTS_N_INSNS (18), /* divsi */
766 COSTS_N_INSNS (18), /* divdi */
767 COSTS_N_INSNS (10), /* fp */
768 COSTS_N_INSNS (10), /* dmul */
769 COSTS_N_INSNS (46), /* sdiv */
770 COSTS_N_INSNS (72), /* ddiv */
771 32, /* cache line size */
774 1, /* prefetch streams /*/
777 /* Instruction costs on POWER4 and POWER5 processors. */
779 struct processor_costs power4_cost = {
780 COSTS_N_INSNS (3), /* mulsi */
781 COSTS_N_INSNS (2), /* mulsi_const */
782 COSTS_N_INSNS (2), /* mulsi_const9 */
783 COSTS_N_INSNS (4), /* muldi */
784 COSTS_N_INSNS (18), /* divsi */
785 COSTS_N_INSNS (34), /* divdi */
786 COSTS_N_INSNS (3), /* fp */
787 COSTS_N_INSNS (3), /* dmul */
788 COSTS_N_INSNS (17), /* sdiv */
789 COSTS_N_INSNS (17), /* ddiv */
790 128, /* cache line size */
793 8, /* prefetch streams /*/
796 /* Instruction costs on POWER6 processors. */
798 struct processor_costs power6_cost = {
799 COSTS_N_INSNS (8), /* mulsi */
800 COSTS_N_INSNS (8), /* mulsi_const */
801 COSTS_N_INSNS (8), /* mulsi_const9 */
802 COSTS_N_INSNS (8), /* muldi */
803 COSTS_N_INSNS (22), /* divsi */
804 COSTS_N_INSNS (28), /* divdi */
805 COSTS_N_INSNS (3), /* fp */
806 COSTS_N_INSNS (3), /* dmul */
807 COSTS_N_INSNS (13), /* sdiv */
808 COSTS_N_INSNS (16), /* ddiv */
809 128, /* cache line size */
812 16, /* prefetch streams */
815 /* Instruction costs on POWER7 processors. */
817 struct processor_costs power7_cost = {
818 COSTS_N_INSNS (2), /* mulsi */
819 COSTS_N_INSNS (2), /* mulsi_const */
820 COSTS_N_INSNS (2), /* mulsi_const9 */
821 COSTS_N_INSNS (2), /* muldi */
822 COSTS_N_INSNS (18), /* divsi */
823 COSTS_N_INSNS (34), /* divdi */
824 COSTS_N_INSNS (3), /* fp */
825 COSTS_N_INSNS (3), /* dmul */
826 COSTS_N_INSNS (13), /* sdiv */
827 COSTS_N_INSNS (16), /* ddiv */
828 128, /* cache line size */
831 12, /* prefetch streams */
834 /* Instruction costs on POWER A2 processors. */
836 struct processor_costs ppca2_cost = {
837 COSTS_N_INSNS (16), /* mulsi */
838 COSTS_N_INSNS (16), /* mulsi_const */
839 COSTS_N_INSNS (16), /* mulsi_const9 */
840 COSTS_N_INSNS (16), /* muldi */
841 COSTS_N_INSNS (22), /* divsi */
842 COSTS_N_INSNS (28), /* divdi */
843 COSTS_N_INSNS (3), /* fp */
844 COSTS_N_INSNS (3), /* dmul */
845 COSTS_N_INSNS (59), /* sdiv */
846 COSTS_N_INSNS (72), /* ddiv */
850 16, /* prefetch streams */
854 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
855 #undef RS6000_BUILTIN_1
856 #undef RS6000_BUILTIN_2
857 #undef RS6000_BUILTIN_3
858 #undef RS6000_BUILTIN_A
859 #undef RS6000_BUILTIN_D
860 #undef RS6000_BUILTIN_E
861 #undef RS6000_BUILTIN_P
862 #undef RS6000_BUILTIN_Q
863 #undef RS6000_BUILTIN_S
864 #undef RS6000_BUILTIN_X
866 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) \
867 { NAME, ICODE, MASK, ATTR },
869 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) \
870 { NAME, ICODE, MASK, ATTR },
872 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) \
873 { NAME, ICODE, MASK, ATTR },
875 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) \
876 { NAME, ICODE, MASK, ATTR },
878 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) \
879 { NAME, ICODE, MASK, ATTR },
881 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE) \
882 { NAME, ICODE, MASK, ATTR },
884 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \
885 { NAME, ICODE, MASK, ATTR },
887 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) \
888 { NAME, ICODE, MASK, ATTR },
890 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE) \
891 { NAME, ICODE, MASK, ATTR },
893 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) \
894 { NAME, ICODE, MASK, ATTR },
896 struct rs6000_builtin_info_type {
898 const enum insn_code icode;
903 static const struct rs6000_builtin_info_type rs6000_builtin_info[] =
905 #include "rs6000-builtin.def"
908 #undef RS6000_BUILTIN_1
909 #undef RS6000_BUILTIN_2
910 #undef RS6000_BUILTIN_3
911 #undef RS6000_BUILTIN_A
912 #undef RS6000_BUILTIN_D
913 #undef RS6000_BUILTIN_E
914 #undef RS6000_BUILTIN_P
915 #undef RS6000_BUILTIN_Q
916 #undef RS6000_BUILTIN_S
917 #undef RS6000_BUILTIN_X
919 /* Support for -mveclibabi=<xxx> to control which vector library to use. */
920 static tree (*rs6000_veclib_handler) (tree, tree, tree);
923 static bool rs6000_function_ok_for_sibcall (tree, tree);
924 static const char *rs6000_invalid_within_doloop (const_rtx);
925 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
926 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
927 static rtx rs6000_generate_compare (rtx, enum machine_mode);
928 static void rs6000_emit_stack_tie (void);
929 static bool spe_func_has_64bit_regs_p (void);
930 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
931 static unsigned rs6000_hash_constant (rtx);
932 static unsigned toc_hash_function (const void *);
933 static int toc_hash_eq (const void *, const void *);
934 static bool reg_offset_addressing_ok_p (enum machine_mode);
935 static bool virtual_stack_registers_memory_p (rtx);
936 static bool constant_pool_expr_p (rtx);
937 static bool legitimate_small_data_p (enum machine_mode, rtx);
938 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
939 static struct machine_function * rs6000_init_machine_status (void);
940 static bool rs6000_assemble_integer (rtx, unsigned int, int);
941 static bool no_global_regs_above (int, bool);
942 #if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO
943 static void rs6000_assemble_visibility (tree, int);
945 static int rs6000_ra_ever_killed (void);
946 static bool rs6000_attribute_takes_identifier_p (const_tree);
947 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
948 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
949 static bool rs6000_ms_bitfield_layout_p (const_tree);
950 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
951 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
952 static const char *rs6000_mangle_type (const_tree);
953 static void rs6000_set_default_type_attributes (tree);
954 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
955 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
956 static bool rs6000_reg_live_or_pic_offset_p (int);
957 static tree rs6000_builtin_vectorized_libmass (tree, tree, tree);
958 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
959 static void rs6000_restore_saved_cr (rtx, int);
960 static bool rs6000_output_addr_const_extra (FILE *, rtx);
961 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
962 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
963 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
965 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
966 static bool rs6000_return_in_memory (const_tree, const_tree);
967 static rtx rs6000_function_value (const_tree, const_tree, bool);
968 static void rs6000_file_start (void);
970 static int rs6000_elf_reloc_rw_mask (void);
971 static void rs6000_elf_asm_out_constructor (rtx, int) ATTRIBUTE_UNUSED;
972 static void rs6000_elf_asm_out_destructor (rtx, int) ATTRIBUTE_UNUSED;
973 static void rs6000_elf_file_end (void) ATTRIBUTE_UNUSED;
974 static void rs6000_elf_asm_init_sections (void);
975 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
976 unsigned HOST_WIDE_INT);
977 static void rs6000_elf_encode_section_info (tree, rtx, int)
980 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
981 static void rs6000_alloc_sdmode_stack_slot (void);
982 static void rs6000_instantiate_decls (void);
984 static void rs6000_xcoff_asm_output_anchor (rtx);
985 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
986 static void rs6000_xcoff_asm_init_sections (void);
987 static int rs6000_xcoff_reloc_rw_mask (void);
988 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
989 static section *rs6000_xcoff_select_section (tree, int,
990 unsigned HOST_WIDE_INT);
991 static void rs6000_xcoff_unique_section (tree, int);
992 static section *rs6000_xcoff_select_rtx_section
993 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
994 static const char * rs6000_xcoff_strip_name_encoding (const char *);
995 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
996 static void rs6000_xcoff_file_start (void);
997 static void rs6000_xcoff_file_end (void);
999 static int rs6000_variable_issue (FILE *, int, rtx, int);
1000 static int rs6000_register_move_cost (enum machine_mode,
1001 reg_class_t, reg_class_t);
1002 static int rs6000_memory_move_cost (enum machine_mode, reg_class_t, bool);
1003 static bool rs6000_rtx_costs (rtx, int, int, int, int *, bool);
1004 static bool rs6000_debug_rtx_costs (rtx, int, int, int, int *, bool);
1005 static int rs6000_debug_address_cost (rtx, bool);
1006 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
1007 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
1008 static void rs6000_sched_init (FILE *, int, int);
1009 static bool is_microcoded_insn (rtx);
1010 static bool is_nonpipeline_insn (rtx);
1011 static bool is_cracked_insn (rtx);
1012 static bool is_branch_slot_insn (rtx);
1013 static bool is_load_insn (rtx);
1014 static rtx get_store_dest (rtx pat);
1015 static bool is_store_insn (rtx);
1016 static bool set_to_load_agen (rtx,rtx);
1017 static bool adjacent_mem_locations (rtx,rtx);
1018 static int rs6000_adjust_priority (rtx, int);
1019 static int rs6000_issue_rate (void);
1020 static bool rs6000_is_costly_dependence (dep_t, int, int);
1021 static rtx get_next_active_insn (rtx, rtx);
1022 static bool insn_terminates_group_p (rtx , enum group_termination);
1023 static bool insn_must_be_first_in_group (rtx);
1024 static bool insn_must_be_last_in_group (rtx);
1025 static bool is_costly_group (rtx *, rtx);
1026 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
1027 static int redefine_groups (FILE *, int, rtx, rtx);
1028 static int pad_groups (FILE *, int, rtx, rtx);
1029 static void rs6000_sched_finish (FILE *, int);
1030 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
1031 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
1032 static int rs6000_use_sched_lookahead (void);
1033 static int rs6000_use_sched_lookahead_guard (rtx);
1034 static void * rs6000_alloc_sched_context (void);
1035 static void rs6000_init_sched_context (void *, bool);
1036 static void rs6000_set_sched_context (void *);
1037 static void rs6000_free_sched_context (void *);
1038 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
1039 static tree rs6000_builtin_mask_for_load (void);
1040 static tree rs6000_builtin_mul_widen_even (tree);
1041 static tree rs6000_builtin_mul_widen_odd (tree);
1042 static bool rs6000_builtin_support_vector_misalignment (enum
1046 static int rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt,
1048 static enum machine_mode rs6000_preferred_simd_mode (enum machine_mode);
1050 static void def_builtin (const char *, tree, enum rs6000_builtins);
1051 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1052 static void rs6000_init_builtins (void);
1053 static tree rs6000_builtin_decl (unsigned, bool);
1055 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1056 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1057 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1058 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1059 static void altivec_init_builtins (void);
1060 static unsigned builtin_hash_function (const void *);
1061 static int builtin_hash_eq (const void *, const void *);
1062 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1063 enum machine_mode, enum machine_mode,
1064 enum rs6000_builtins, const char *name);
1065 static void rs6000_common_init_builtins (void);
1066 static void rs6000_init_libfuncs (void);
1068 static void paired_init_builtins (void);
1069 static rtx paired_expand_builtin (tree, rtx, bool *);
1070 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1071 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1072 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1074 static void spe_init_builtins (void);
1075 static rtx spe_expand_builtin (tree, rtx, bool *);
1076 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1077 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1078 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1079 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1080 static rs6000_stack_t *rs6000_stack_info (void);
1081 static void debug_stack_info (rs6000_stack_t *);
1083 static rtx altivec_expand_builtin (tree, rtx, bool *);
1084 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1085 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1086 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1087 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1088 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1089 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1090 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1091 static rtx altivec_expand_vec_set_builtin (tree);
1092 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1093 static int get_element_number (tree, tree);
1094 static void rs6000_option_override (void);
1095 static int rs6000_loop_align_max_skip (rtx);
1096 static int first_altivec_reg_to_save (void);
1097 static unsigned int compute_vrsave_mask (void);
1098 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1099 static void is_altivec_return_reg (rtx, void *);
1100 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1101 int easy_vector_constant (rtx, enum machine_mode);
1102 static rtx rs6000_dwarf_register_span (rtx);
1103 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1104 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1105 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1106 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1107 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1108 static rtx rs6000_delegitimize_address (rtx);
1109 static bool rs6000_const_not_ok_for_debug_p (rtx);
1110 static rtx rs6000_tls_get_addr (void);
1111 static rtx rs6000_got_sym (void);
1112 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1113 static const char *rs6000_get_some_local_dynamic_name (void);
1114 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1115 static rtx rs6000_complex_function_value (enum machine_mode);
1116 static rtx rs6000_spe_function_arg (const CUMULATIVE_ARGS *,
1117 enum machine_mode, const_tree);
1118 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1119 HOST_WIDE_INT, int);
1120 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1123 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1126 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1127 const_tree, HOST_WIDE_INT,
1129 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, bool, bool);
1130 static rtx rs6000_mixed_function_arg (enum machine_mode, const_tree, int);
1131 static void rs6000_function_arg_advance (cumulative_args_t, enum machine_mode,
1133 static rtx rs6000_function_arg (cumulative_args_t, enum machine_mode,
1135 static unsigned int rs6000_function_arg_boundary (enum machine_mode,
1137 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1138 static void setup_incoming_varargs (cumulative_args_t,
1139 enum machine_mode, tree,
1141 static bool rs6000_pass_by_reference (cumulative_args_t, enum machine_mode,
1143 static int rs6000_arg_partial_bytes (cumulative_args_t, enum machine_mode,
1145 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1147 static void macho_branch_islands (void);
1148 static int no_previous_def (tree function_name);
1149 static tree get_prev_label (tree function_name);
1150 static void rs6000_darwin_file_start (void);
1153 static tree rs6000_build_builtin_va_list (void);
1154 static void rs6000_va_start (tree, rtx);
1155 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1156 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1157 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1158 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1159 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1160 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1162 static tree rs6000_stack_protect_fail (void);
1164 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1167 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1170 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1172 = rs6000_legitimize_reload_address;
1174 static bool rs6000_mode_dependent_address_p (const_rtx);
1175 static bool rs6000_mode_dependent_address (const_rtx);
1176 static bool rs6000_debug_mode_dependent_address (const_rtx);
1177 static bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1178 = rs6000_mode_dependent_address;
1180 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1181 enum machine_mode, rtx);
1182 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1185 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1186 enum machine_mode, rtx)
1187 = rs6000_secondary_reload_class;
1189 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1190 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1192 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1193 = rs6000_preferred_reload_class;
1195 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1198 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1202 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1204 = rs6000_secondary_memory_needed;
1206 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1209 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1213 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1216 = rs6000_cannot_change_mode_class;
1218 static reg_class_t rs6000_secondary_reload (bool, rtx, reg_class_t,
1220 struct secondary_reload_info *);
1222 const int INSN_NOT_AVAILABLE = -1;
1223 static enum machine_mode rs6000_eh_return_filter_mode (void);
1224 static bool rs6000_can_eliminate (const int, const int);
1225 static void rs6000_conditional_register_usage (void);
1226 static void rs6000_trampoline_init (rtx, tree, rtx);
1227 static bool rs6000_cannot_force_const_mem (enum machine_mode, rtx);
1228 static bool rs6000_legitimate_constant_p (enum machine_mode, rtx);
1229 static bool rs6000_save_toc_in_prologue_p (void);
1230 static void rs6000_code_end (void) ATTRIBUTE_UNUSED;
1231 static void rs6000_set_up_by_prologue (struct hard_reg_set_container *);
1233 /* Hash table stuff for keeping track of TOC entries. */
1235 struct GTY(()) toc_hash_struct
1237 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1238 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1240 enum machine_mode key_mode;
1244 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1246 /* Hash table to keep track of the argument types for builtin functions. */
1248 struct GTY(()) builtin_hash_struct
1251 enum machine_mode mode[4]; /* return value + 3 arguments. */
1252 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1255 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1257 static bool rs6000_valid_attribute_p (tree, tree, tree, int);
1258 static void rs6000_function_specific_save (struct cl_target_option *);
1259 static void rs6000_function_specific_restore (struct cl_target_option *);
1260 static void rs6000_function_specific_print (FILE *, int,
1261 struct cl_target_option *);
1262 static bool rs6000_can_inline_p (tree, tree);
1263 static void rs6000_set_current_function (tree);
1266 /* Default register names. */
1267 char rs6000_reg_names[][8] =
1269 "0", "1", "2", "3", "4", "5", "6", "7",
1270 "8", "9", "10", "11", "12", "13", "14", "15",
1271 "16", "17", "18", "19", "20", "21", "22", "23",
1272 "24", "25", "26", "27", "28", "29", "30", "31",
1273 "0", "1", "2", "3", "4", "5", "6", "7",
1274 "8", "9", "10", "11", "12", "13", "14", "15",
1275 "16", "17", "18", "19", "20", "21", "22", "23",
1276 "24", "25", "26", "27", "28", "29", "30", "31",
1277 "mq", "lr", "ctr","ap",
1278 "0", "1", "2", "3", "4", "5", "6", "7",
1280 /* AltiVec registers. */
1281 "0", "1", "2", "3", "4", "5", "6", "7",
1282 "8", "9", "10", "11", "12", "13", "14", "15",
1283 "16", "17", "18", "19", "20", "21", "22", "23",
1284 "24", "25", "26", "27", "28", "29", "30", "31",
1286 /* SPE registers. */
1287 "spe_acc", "spefscr",
1288 /* Soft frame pointer. */
1292 #ifdef TARGET_REGNAMES
1293 static const char alt_reg_names[][8] =
1295 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1296 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1297 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1298 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1299 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1300 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1301 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1302 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1303 "mq", "lr", "ctr", "ap",
1304 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1306 /* AltiVec registers. */
1307 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1308 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1309 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1310 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1312 /* SPE registers. */
1313 "spe_acc", "spefscr",
1314 /* Soft frame pointer. */
1319 /* Table of valid machine attributes. */
1321 static const struct attribute_spec rs6000_attribute_table[] =
1323 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
1324 affects_type_identity } */
1325 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute,
1327 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute,
1329 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute,
1331 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute,
1333 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute,
1335 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1336 SUBTARGET_ATTRIBUTE_TABLE,
1338 { NULL, 0, 0, false, false, false, NULL, false }
1341 #ifndef MASK_STRICT_ALIGN
1342 #define MASK_STRICT_ALIGN 0
1344 #ifndef TARGET_PROFILE_KERNEL
1345 #define TARGET_PROFILE_KERNEL 0
1348 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1349 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1351 /* Initialize the GCC target structure. */
1352 #undef TARGET_ATTRIBUTE_TABLE
1353 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1354 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1355 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1356 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1357 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1359 #undef TARGET_ASM_ALIGNED_DI_OP
1360 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1362 /* Default unaligned ops are only provided for ELF. Find the ops needed
1363 for non-ELF systems. */
1364 #ifndef OBJECT_FORMAT_ELF
1366 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1368 #undef TARGET_ASM_UNALIGNED_HI_OP
1369 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1370 #undef TARGET_ASM_UNALIGNED_SI_OP
1371 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1372 #undef TARGET_ASM_UNALIGNED_DI_OP
1373 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1376 #undef TARGET_ASM_UNALIGNED_HI_OP
1377 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1378 #undef TARGET_ASM_UNALIGNED_SI_OP
1379 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1380 #undef TARGET_ASM_UNALIGNED_DI_OP
1381 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1382 #undef TARGET_ASM_ALIGNED_DI_OP
1383 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1387 /* This hook deals with fixups for relocatable code and DI-mode objects
1389 #undef TARGET_ASM_INTEGER
1390 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1392 #if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO
1393 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1394 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1397 #undef TARGET_SET_UP_BY_PROLOGUE
1398 #define TARGET_SET_UP_BY_PROLOGUE rs6000_set_up_by_prologue
1400 #undef TARGET_HAVE_TLS
1401 #define TARGET_HAVE_TLS HAVE_AS_TLS
1403 #undef TARGET_CANNOT_FORCE_CONST_MEM
1404 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_cannot_force_const_mem
1406 #undef TARGET_DELEGITIMIZE_ADDRESS
1407 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1409 #undef TARGET_CONST_NOT_OK_FOR_DEBUG_P
1410 #define TARGET_CONST_NOT_OK_FOR_DEBUG_P rs6000_const_not_ok_for_debug_p
1412 #undef TARGET_ASM_FUNCTION_PROLOGUE
1413 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1414 #undef TARGET_ASM_FUNCTION_EPILOGUE
1415 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1417 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
1418 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA rs6000_output_addr_const_extra
1420 #undef TARGET_LEGITIMIZE_ADDRESS
1421 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1423 #undef TARGET_SCHED_VARIABLE_ISSUE
1424 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1426 #undef TARGET_SCHED_ISSUE_RATE
1427 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1428 #undef TARGET_SCHED_ADJUST_COST
1429 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1430 #undef TARGET_SCHED_ADJUST_PRIORITY
1431 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1432 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1433 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1434 #undef TARGET_SCHED_INIT
1435 #define TARGET_SCHED_INIT rs6000_sched_init
1436 #undef TARGET_SCHED_FINISH
1437 #define TARGET_SCHED_FINISH rs6000_sched_finish
1438 #undef TARGET_SCHED_REORDER
1439 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1440 #undef TARGET_SCHED_REORDER2
1441 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1443 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1444 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1446 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1447 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1449 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1450 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1451 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1452 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1453 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1454 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1455 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1456 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1458 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1459 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1460 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1461 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1462 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1463 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1464 #undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
1465 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
1466 rs6000_builtin_support_vector_misalignment
1467 #undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
1468 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1469 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
1470 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \
1471 rs6000_builtin_vectorization_cost
1472 #undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
1473 #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \
1474 rs6000_preferred_simd_mode
1476 #undef TARGET_INIT_BUILTINS
1477 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1478 #undef TARGET_BUILTIN_DECL
1479 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1481 #undef TARGET_EXPAND_BUILTIN
1482 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1484 #undef TARGET_MANGLE_TYPE
1485 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1487 #undef TARGET_INIT_LIBFUNCS
1488 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1491 #undef TARGET_BINDS_LOCAL_P
1492 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1495 #undef TARGET_MS_BITFIELD_LAYOUT_P
1496 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1498 #undef TARGET_ASM_OUTPUT_MI_THUNK
1499 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1501 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1502 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1504 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1505 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1507 #undef TARGET_INVALID_WITHIN_DOLOOP
1508 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1510 #undef TARGET_REGISTER_MOVE_COST
1511 #define TARGET_REGISTER_MOVE_COST rs6000_register_move_cost
1512 #undef TARGET_MEMORY_MOVE_COST
1513 #define TARGET_MEMORY_MOVE_COST rs6000_memory_move_cost
1514 #undef TARGET_RTX_COSTS
1515 #define TARGET_RTX_COSTS rs6000_rtx_costs
1516 #undef TARGET_ADDRESS_COST
1517 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1519 #undef TARGET_DWARF_REGISTER_SPAN
1520 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1522 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1523 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1525 /* On rs6000, function arguments are promoted, as are function return
1527 #undef TARGET_PROMOTE_FUNCTION_MODE
1528 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1530 #undef TARGET_RETURN_IN_MEMORY
1531 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1533 #undef TARGET_SETUP_INCOMING_VARARGS
1534 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1536 /* Always strict argument naming on rs6000. */
1537 #undef TARGET_STRICT_ARGUMENT_NAMING
1538 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1539 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1540 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1541 #undef TARGET_SPLIT_COMPLEX_ARG
1542 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1543 #undef TARGET_MUST_PASS_IN_STACK
1544 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1545 #undef TARGET_PASS_BY_REFERENCE
1546 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1547 #undef TARGET_ARG_PARTIAL_BYTES
1548 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1549 #undef TARGET_FUNCTION_ARG_ADVANCE
1550 #define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance
1551 #undef TARGET_FUNCTION_ARG
1552 #define TARGET_FUNCTION_ARG rs6000_function_arg
1553 #undef TARGET_FUNCTION_ARG_BOUNDARY
1554 #define TARGET_FUNCTION_ARG_BOUNDARY rs6000_function_arg_boundary
1556 #undef TARGET_BUILD_BUILTIN_VA_LIST
1557 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1559 #undef TARGET_EXPAND_BUILTIN_VA_START
1560 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1562 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1563 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1565 #undef TARGET_EH_RETURN_FILTER_MODE
1566 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1568 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1569 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1571 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1572 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1574 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1575 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1577 #undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP
1578 #define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rs6000_loop_align_max_skip
1580 #undef TARGET_OPTION_OVERRIDE
1581 #define TARGET_OPTION_OVERRIDE rs6000_option_override
1583 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1584 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1585 rs6000_builtin_vectorized_function
1588 #undef TARGET_STACK_PROTECT_FAIL
1589 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1592 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1593 The PowerPC architecture requires only weak consistency among
1594 processors--that is, memory accesses between processors need not be
1595 sequentially consistent and memory accesses among processors can occur
1596 in any order. The ability to order memory accesses weakly provides
1597 opportunities for more efficient use of the system bus. Unless a
1598 dependency exists, the 604e allows read operations to precede store
1600 #undef TARGET_RELAXED_ORDERING
1601 #define TARGET_RELAXED_ORDERING true
1604 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1605 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1608 /* Use a 32-bit anchor range. This leads to sequences like:
1610 addis tmp,anchor,high
1613 where tmp itself acts as an anchor, and can be shared between
1614 accesses to the same 64k page. */
1615 #undef TARGET_MIN_ANCHOR_OFFSET
1616 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1617 #undef TARGET_MAX_ANCHOR_OFFSET
1618 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1619 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1620 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1622 #undef TARGET_BUILTIN_RECIPROCAL
1623 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1625 #undef TARGET_EXPAND_TO_RTL_HOOK
1626 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1628 #undef TARGET_INSTANTIATE_DECLS
1629 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1631 #undef TARGET_SECONDARY_RELOAD
1632 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1634 #undef TARGET_LEGITIMATE_ADDRESS_P
1635 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1637 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
1638 #define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p
1640 #undef TARGET_CAN_ELIMINATE
1641 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1643 #undef TARGET_CONDITIONAL_REGISTER_USAGE
1644 #define TARGET_CONDITIONAL_REGISTER_USAGE rs6000_conditional_register_usage
1646 #undef TARGET_TRAMPOLINE_INIT
1647 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1649 #undef TARGET_FUNCTION_VALUE
1650 #define TARGET_FUNCTION_VALUE rs6000_function_value
1652 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
1653 #define TARGET_OPTION_VALID_ATTRIBUTE_P rs6000_valid_attribute_p
1655 #undef TARGET_OPTION_SAVE
1656 #define TARGET_OPTION_SAVE rs6000_function_specific_save
1658 #undef TARGET_OPTION_RESTORE
1659 #define TARGET_OPTION_RESTORE rs6000_function_specific_restore
1661 #undef TARGET_OPTION_PRINT
1662 #define TARGET_OPTION_PRINT rs6000_function_specific_print
1664 #undef TARGET_CAN_INLINE_P
1665 #define TARGET_CAN_INLINE_P rs6000_can_inline_p
1667 #undef TARGET_SET_CURRENT_FUNCTION
1668 #define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function
1670 #undef TARGET_LEGITIMATE_CONSTANT_P
1671 #define TARGET_LEGITIMATE_CONSTANT_P rs6000_legitimate_constant_p
1673 #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
1674 #define TARGET_VECTORIZE_VEC_PERM_CONST_OK rs6000_vectorize_vec_perm_const_ok
1677 /* Simplifications for entries below. */
1680 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1681 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1684 /* Some OSs don't support saving the high part of 64-bit registers on context
1685 switch. Other OSs don't support saving Altivec registers. On those OSs, we
1686 don't touch the MASK_POWERPC64 or MASK_ALTIVEC settings; if the user wants
1687 either, the user must explicitly specify them and we won't interfere with
1688 the user's specification. */
1691 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1692 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1693 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1694 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1695 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
1696 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE
1697 | MASK_RECIP_PRECISION)
1700 /* Masks for instructions set at various powerpc ISAs. */
1702 ISA_2_1_MASKS = MASK_MFCRF,
1703 ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB),
1704 ISA_2_4_MASKS = (ISA_2_2_MASKS | MASK_FPRND),
1706 /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't add
1707 ALTIVEC, since in general it isn't a win on power6. In ISA 2.04, fsel,
1708 fre, fsqrt, etc. were no longer documented as optional. Group masks by
1709 server and embedded. */
1710 ISA_2_5_MASKS_EMBEDDED = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION
1711 | MASK_PPC_GFXOPT | MASK_PPC_GPOPT),
1712 ISA_2_5_MASKS_SERVER = (ISA_2_5_MASKS_EMBEDDED | MASK_DFP),
1714 /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
1715 altivec is a win so enable it. */
1716 ISA_2_6_MASKS_EMBEDDED = (ISA_2_5_MASKS_EMBEDDED | MASK_POPCNTD),
1717 ISA_2_6_MASKS_SERVER = (ISA_2_5_MASKS_SERVER | MASK_POPCNTD | MASK_ALTIVEC
1723 const char *const name; /* Canonical processor name. */
1724 const enum processor_type processor; /* Processor type enum value. */
1725 const int target_enable; /* Target flags to enable. */
1728 static struct rs6000_ptt const processor_target_table[] =
1730 #define RS6000_CPU(NAME, CPU, FLAGS) { NAME, CPU, FLAGS },
1731 #include "rs6000-cpus.def"
1735 /* Look up a processor name for -mcpu=xxx and -mtune=xxx. Return -1 if the
1739 rs6000_cpu_name_lookup (const char *name)
1745 for (i = 0; i < ARRAY_SIZE (processor_target_table); i++)
1746 if (! strcmp (name, processor_target_table[i].name))
1754 /* Return number of consecutive hard regs needed starting at reg REGNO
1755 to hold something of mode MODE.
1756 This is ordinarily the length in words of a value of mode MODE
1757 but can be less for certain modes in special long registers.
1759 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1760 scalar instructions. The upper 32 bits are only available to the
1763 POWER and PowerPC GPRs hold 32 bits worth;
1764 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1767 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1769 unsigned HOST_WIDE_INT reg_size;
1771 if (FP_REGNO_P (regno))
1772 reg_size = (VECTOR_MEM_VSX_P (mode)
1773 ? UNITS_PER_VSX_WORD
1774 : UNITS_PER_FP_WORD);
1776 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1777 reg_size = UNITS_PER_SPE_WORD;
1779 else if (ALTIVEC_REGNO_P (regno))
1780 reg_size = UNITS_PER_ALTIVEC_WORD;
1782 /* The value returned for SCmode in the E500 double case is 2 for
1783 ABI compatibility; storing an SCmode value in a single register
1784 would require function_arg and rs6000_spe_function_arg to handle
1785 SCmode so as to pass the value correctly in a pair of
1787 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1788 && !DECIMAL_FLOAT_MODE_P (mode))
1789 reg_size = UNITS_PER_FP_WORD;
1792 reg_size = UNITS_PER_WORD;
1794 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1797 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1800 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1802 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1804 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1805 implementations. Don't allow an item to be split between a FP register
1806 and an Altivec register. */
1807 if (VECTOR_MEM_VSX_P (mode))
1809 if (FP_REGNO_P (regno))
1810 return FP_REGNO_P (last_regno);
1812 if (ALTIVEC_REGNO_P (regno))
1813 return ALTIVEC_REGNO_P (last_regno);
1816 /* The GPRs can hold any mode, but values bigger than one register
1817 cannot go past R31. */
1818 if (INT_REGNO_P (regno))
1819 return INT_REGNO_P (last_regno);
1821 /* The float registers (except for VSX vector modes) can only hold floating
1822 modes and DImode. This excludes the 32-bit decimal float mode for
1824 if (FP_REGNO_P (regno))
1826 if (SCALAR_FLOAT_MODE_P (mode)
1827 && (mode != TDmode || (regno % 2) == 0)
1828 && FP_REGNO_P (last_regno))
1831 if (GET_MODE_CLASS (mode) == MODE_INT
1832 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1835 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1836 && PAIRED_VECTOR_MODE (mode))
1842 /* The CR register can only hold CC modes. */
1843 if (CR_REGNO_P (regno))
1844 return GET_MODE_CLASS (mode) == MODE_CC;
1846 if (CA_REGNO_P (regno))
1847 return mode == BImode;
1849 /* AltiVec only in AldyVec registers. */
1850 if (ALTIVEC_REGNO_P (regno))
1851 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1853 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1854 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1857 /* We cannot put TImode anywhere except general register and it must be able
1858 to fit within the register set. In the future, allow TImode in the
1859 Altivec or VSX registers. */
1861 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1864 /* Print interesting facts about registers. */
1866 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1870 for (r = first_regno; r <= last_regno; ++r)
1872 const char *comma = "";
1875 if (first_regno == last_regno)
1876 fprintf (stderr, "%s:\t", reg_name);
1878 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1881 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1882 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1886 fprintf (stderr, ",\n\t");
1891 if (rs6000_hard_regno_nregs[m][r] > 1)
1892 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1893 rs6000_hard_regno_nregs[m][r]);
1895 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1900 if (call_used_regs[r])
1904 fprintf (stderr, ",\n\t");
1909 len += fprintf (stderr, "%s%s", comma, "call-used");
1917 fprintf (stderr, ",\n\t");
1922 len += fprintf (stderr, "%s%s", comma, "fixed");
1928 fprintf (stderr, ",\n\t");
1932 fprintf (stderr, "%sregno = %d\n", comma, r);
1936 #define DEBUG_FMT_D "%-32s= %d\n"
1937 #define DEBUG_FMT_X "%-32s= 0x%x\n"
1938 #define DEBUG_FMT_S "%-32s= %s\n"
1940 /* Print various interesting information with -mdebug=reg. */
1942 rs6000_debug_reg_global (void)
1944 static const char *const tf[2] = { "false", "true" };
1945 const char *nl = (const char *)0;
1947 char costly_num[20];
1949 const char *costly_str;
1950 const char *nop_str;
1951 const char *trace_str;
1952 const char *abi_str;
1953 const char *cmodel_str;
1955 /* Map enum rs6000_vector to string. */
1956 static const char *rs6000_debug_vector_unit[] = {
1965 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
1966 LAST_VIRTUAL_REGISTER);
1967 rs6000_debug_reg_print (0, 31, "gr");
1968 rs6000_debug_reg_print (32, 63, "fp");
1969 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
1972 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
1973 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
1974 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
1975 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
1976 rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca");
1977 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
1978 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
1979 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
1980 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
1984 "d reg_class = %s\n"
1985 "f reg_class = %s\n"
1986 "v reg_class = %s\n"
1987 "wa reg_class = %s\n"
1988 "wd reg_class = %s\n"
1989 "wf reg_class = %s\n"
1990 "ws reg_class = %s\n\n",
1991 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
1992 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
1993 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
1994 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
1995 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
1996 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
1997 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
1999 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2000 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
2003 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
2005 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
2006 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
2012 if (rs6000_recip_control)
2014 fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control);
2016 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2017 if (rs6000_recip_bits[m])
2020 "Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n",
2022 (RS6000_RECIP_AUTO_RE_P (m)
2024 : (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")),
2025 (RS6000_RECIP_AUTO_RSQRTE_P (m)
2027 : (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none")));
2030 fputs ("\n", stderr);
2033 if (rs6000_cpu_index >= 0)
2034 fprintf (stderr, DEBUG_FMT_S, "cpu",
2035 processor_target_table[rs6000_cpu_index].name);
2037 if (rs6000_tune_index >= 0)
2038 fprintf (stderr, DEBUG_FMT_S, "tune",
2039 processor_target_table[rs6000_tune_index].name);
2041 switch (rs6000_sched_costly_dep)
2043 case max_dep_latency:
2044 costly_str = "max_dep_latency";
2048 costly_str = "no_dep_costly";
2051 case all_deps_costly:
2052 costly_str = "all_deps_costly";
2055 case true_store_to_load_dep_costly:
2056 costly_str = "true_store_to_load_dep_costly";
2059 case store_to_load_dep_costly:
2060 costly_str = "store_to_load_dep_costly";
2064 costly_str = costly_num;
2065 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
2069 fprintf (stderr, DEBUG_FMT_S, "sched_costly_dep", costly_str);
2071 switch (rs6000_sched_insert_nops)
2073 case sched_finish_regroup_exact:
2074 nop_str = "sched_finish_regroup_exact";
2077 case sched_finish_pad_groups:
2078 nop_str = "sched_finish_pad_groups";
2081 case sched_finish_none:
2082 nop_str = "sched_finish_none";
2087 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
2091 fprintf (stderr, DEBUG_FMT_S, "sched_insert_nops", nop_str);
2093 switch (rs6000_sdata)
2100 fprintf (stderr, DEBUG_FMT_S, "sdata", "data");
2104 fprintf (stderr, DEBUG_FMT_S, "sdata", "sysv");
2108 fprintf (stderr, DEBUG_FMT_S, "sdata", "eabi");
2113 switch (rs6000_traceback)
2115 case traceback_default: trace_str = "default"; break;
2116 case traceback_none: trace_str = "none"; break;
2117 case traceback_part: trace_str = "part"; break;
2118 case traceback_full: trace_str = "full"; break;
2119 default: trace_str = "unknown"; break;
2122 fprintf (stderr, DEBUG_FMT_S, "traceback", trace_str);
2124 switch (rs6000_current_cmodel)
2126 case CMODEL_SMALL: cmodel_str = "small"; break;
2127 case CMODEL_MEDIUM: cmodel_str = "medium"; break;
2128 case CMODEL_LARGE: cmodel_str = "large"; break;
2129 default: cmodel_str = "unknown"; break;
2132 fprintf (stderr, DEBUG_FMT_S, "cmodel", cmodel_str);
2134 switch (rs6000_current_abi)
2136 case ABI_NONE: abi_str = "none"; break;
2137 case ABI_AIX: abi_str = "aix"; break;
2138 case ABI_V4: abi_str = "V4"; break;
2139 case ABI_DARWIN: abi_str = "darwin"; break;
2140 default: abi_str = "unknown"; break;
2143 fprintf (stderr, DEBUG_FMT_S, "abi", abi_str);
2145 if (rs6000_altivec_abi)
2146 fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true");
2149 fprintf (stderr, DEBUG_FMT_S, "spe_abi", "true");
2151 if (rs6000_darwin64_abi)
2152 fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true");
2154 if (rs6000_float_gprs)
2155 fprintf (stderr, DEBUG_FMT_S, "float_gprs", "true");
2157 fprintf (stderr, DEBUG_FMT_S, "always_hint", tf[!!rs6000_always_hint]);
2158 fprintf (stderr, DEBUG_FMT_S, "align_branch",
2159 tf[!!rs6000_align_branch_targets]);
2160 fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size);
2161 fprintf (stderr, DEBUG_FMT_D, "long_double_size",
2162 rs6000_long_double_type_size);
2163 fprintf (stderr, DEBUG_FMT_D, "sched_restricted_insns_priority",
2164 (int)rs6000_sched_restricted_insns_priority);
2165 fprintf (stderr, DEBUG_FMT_D, "Number of standard builtins",
2167 fprintf (stderr, DEBUG_FMT_D, "Number of rs6000 builtins",
2168 (int)RS6000_BUILTIN_COUNT);
2169 fprintf (stderr, DEBUG_FMT_X, "Builtin mask", rs6000_builtin_mask);
2172 /* Initialize the various global tables that are based on register size. */
2174 rs6000_init_hard_regno_mode_ok (bool global_init_p)
2180 /* Precalculate REGNO_REG_CLASS. */
2181 rs6000_regno_regclass[0] = GENERAL_REGS;
2182 for (r = 1; r < 32; ++r)
2183 rs6000_regno_regclass[r] = BASE_REGS;
2185 for (r = 32; r < 64; ++r)
2186 rs6000_regno_regclass[r] = FLOAT_REGS;
2188 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
2189 rs6000_regno_regclass[r] = NO_REGS;
2191 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
2192 rs6000_regno_regclass[r] = ALTIVEC_REGS;
2194 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
2195 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
2196 rs6000_regno_regclass[r] = CR_REGS;
2198 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
2199 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
2200 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
2201 rs6000_regno_regclass[CA_REGNO] = CA_REGS;
2202 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
2203 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
2204 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
2205 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
2206 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
2207 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
2209 /* Precalculate vector information, this must be set up before the
2210 rs6000_hard_regno_nregs_internal below. */
2211 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2213 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
2214 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
2215 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
2218 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
2219 rs6000_constraints[c] = NO_REGS;
2221 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
2222 believes it can use native alignment or still uses 128-bit alignment. */
2223 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
2234 /* V2DF mode, VSX only. */
2237 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
2238 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
2239 rs6000_vector_align[V2DFmode] = align64;
2242 /* V4SF mode, either VSX or Altivec. */
2245 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
2246 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
2247 rs6000_vector_align[V4SFmode] = align32;
2249 else if (TARGET_ALTIVEC)
2251 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
2252 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
2253 rs6000_vector_align[V4SFmode] = align32;
2256 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
2260 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
2261 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
2262 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
2263 rs6000_vector_align[V4SImode] = align32;
2264 rs6000_vector_align[V8HImode] = align32;
2265 rs6000_vector_align[V16QImode] = align32;
2269 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
2270 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
2271 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
2275 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
2276 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
2277 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
2281 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
2282 Altivec doesn't have 64-bit support. */
2285 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
2286 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
2287 rs6000_vector_align[V2DImode] = align64;
2290 /* DFmode, see if we want to use the VSX unit. */
2291 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
2293 rs6000_vector_unit[DFmode] = VECTOR_VSX;
2294 rs6000_vector_mem[DFmode]
2295 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
2296 rs6000_vector_align[DFmode] = align64;
2299 /* TODO add SPE and paired floating point vector support. */
2301 /* Register class constaints for the constraints that depend on compile
2303 if (TARGET_HARD_FLOAT && TARGET_FPRS)
2304 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2306 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2307 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2311 /* At present, we just use VSX_REGS, but we have different constraints
2312 based on the use, in case we want to fine tune the default register
2313 class used. wa = any VSX register, wf = register class to use for
2314 V4SF, wd = register class to use for V2DF, and ws = register classs to
2315 use for DF scalars. */
2316 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2317 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2318 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2319 rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
2325 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2327 /* Set up the reload helper functions. */
2328 if (TARGET_VSX || TARGET_ALTIVEC)
2332 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2333 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2334 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2335 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2336 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2337 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2338 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2339 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2340 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2341 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2342 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2343 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2344 if (TARGET_VSX && TARGET_VSX_SCALAR_MEMORY)
2346 rs6000_vector_reload[DFmode][0] = CODE_FOR_reload_df_di_store;
2347 rs6000_vector_reload[DFmode][1] = CODE_FOR_reload_df_di_load;
2352 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2353 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2354 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2355 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2356 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2357 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2358 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2359 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2360 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2361 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2362 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2363 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2364 if (TARGET_VSX && TARGET_VSX_SCALAR_MEMORY)
2366 rs6000_vector_reload[DFmode][0] = CODE_FOR_reload_df_si_store;
2367 rs6000_vector_reload[DFmode][1] = CODE_FOR_reload_df_si_load;
2372 /* Precalculate HARD_REGNO_NREGS. */
2373 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2374 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2375 rs6000_hard_regno_nregs[m][r]
2376 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2378 /* Precalculate HARD_REGNO_MODE_OK. */
2379 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2380 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2381 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2382 rs6000_hard_regno_mode_ok_p[m][r] = true;
2384 /* Precalculate CLASS_MAX_NREGS sizes. */
2385 for (c = 0; c < LIM_REG_CLASSES; ++c)
2389 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2390 reg_size = UNITS_PER_VSX_WORD;
2392 else if (c == ALTIVEC_REGS)
2393 reg_size = UNITS_PER_ALTIVEC_WORD;
2395 else if (c == FLOAT_REGS)
2396 reg_size = UNITS_PER_FP_WORD;
2399 reg_size = UNITS_PER_WORD;
2401 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2402 rs6000_class_max_nregs[m][c]
2403 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2406 if (TARGET_E500_DOUBLE)
2407 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2409 /* Calculate which modes to automatically generate code to use a the
2410 reciprocal divide and square root instructions. In the future, possibly
2411 automatically generate the instructions even if the user did not specify
2412 -mrecip. The older machines double precision reciprocal sqrt estimate is
2413 not accurate enough. */
2414 memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits));
2416 rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2418 rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2419 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2420 rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE;
2421 if (VECTOR_UNIT_VSX_P (V2DFmode))
2422 rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE;
2424 if (TARGET_FRSQRTES)
2425 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2427 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2428 if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode))
2429 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2430 if (VECTOR_UNIT_VSX_P (V2DFmode))
2431 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE;
2433 if (rs6000_recip_control)
2435 if (!flag_finite_math_only)
2436 warning (0, "-mrecip requires -ffinite-math or -ffast-math");
2437 if (flag_trapping_math)
2438 warning (0, "-mrecip requires -fno-trapping-math or -ffast-math");
2439 if (!flag_reciprocal_math)
2440 warning (0, "-mrecip requires -freciprocal-math or -ffast-math");
2441 if (flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math)
2443 if (RS6000_RECIP_HAVE_RE_P (SFmode)
2444 && (rs6000_recip_control & RECIP_SF_DIV) != 0)
2445 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2447 if (RS6000_RECIP_HAVE_RE_P (DFmode)
2448 && (rs6000_recip_control & RECIP_DF_DIV) != 0)
2449 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2451 if (RS6000_RECIP_HAVE_RE_P (V4SFmode)
2452 && (rs6000_recip_control & RECIP_V4SF_DIV) != 0)
2453 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2455 if (RS6000_RECIP_HAVE_RE_P (V2DFmode)
2456 && (rs6000_recip_control & RECIP_V2DF_DIV) != 0)
2457 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE;
2459 if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode)
2460 && (rs6000_recip_control & RECIP_SF_RSQRT) != 0)
2461 rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2463 if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode)
2464 && (rs6000_recip_control & RECIP_DF_RSQRT) != 0)
2465 rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2467 if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode)
2468 && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0)
2469 rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2471 if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode)
2472 && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0)
2473 rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE;
2477 if (global_init_p || TARGET_DEBUG_TARGET)
2479 if (TARGET_DEBUG_REG)
2480 rs6000_debug_reg_global ();
2482 if (TARGET_DEBUG_COST || TARGET_DEBUG_REG)
2484 "SImode variable mult cost = %d\n"
2485 "SImode constant mult cost = %d\n"
2486 "SImode short constant mult cost = %d\n"
2487 "DImode multipliciation cost = %d\n"
2488 "SImode division cost = %d\n"
2489 "DImode division cost = %d\n"
2490 "Simple fp operation cost = %d\n"
2491 "DFmode multiplication cost = %d\n"
2492 "SFmode division cost = %d\n"
2493 "DFmode division cost = %d\n"
2494 "cache line size = %d\n"
2495 "l1 cache size = %d\n"
2496 "l2 cache size = %d\n"
2497 "simultaneous prefetches = %d\n"
2500 rs6000_cost->mulsi_const,
2501 rs6000_cost->mulsi_const9,
2509 rs6000_cost->cache_line_size,
2510 rs6000_cost->l1_cache_size,
2511 rs6000_cost->l2_cache_size,
2512 rs6000_cost->simultaneous_prefetches);
2517 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2520 darwin_rs6000_override_options (void)
2522 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2524 rs6000_altivec_abi = 1;
2525 TARGET_ALTIVEC_VRSAVE = 1;
2526 rs6000_current_abi = ABI_DARWIN;
2528 if (DEFAULT_ABI == ABI_DARWIN
2530 darwin_one_byte_bool = 1;
2532 if (TARGET_64BIT && ! TARGET_POWERPC64)
2534 target_flags |= MASK_POWERPC64;
2535 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2539 rs6000_default_long_calls = 1;
2540 target_flags |= MASK_SOFT_FLOAT;
2543 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2545 if (!flag_mkernel && !flag_apple_kext
2547 && ! (target_flags_explicit & MASK_ALTIVEC))
2548 target_flags |= MASK_ALTIVEC;
2550 /* Unless the user (not the configurer) has explicitly overridden
2551 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2552 G4 unless targetting the kernel. */
2555 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2556 && ! (target_flags_explicit & MASK_ALTIVEC)
2557 && ! global_options_set.x_rs6000_cpu_index)
2559 target_flags |= MASK_ALTIVEC;
2564 /* If not otherwise specified by a target, make 'long double' equivalent to
2567 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2568 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2571 /* Return the builtin mask of the various options used that could affect which
2572 builtins were used. In the past we used target_flags, but we've run out of
2573 bits, and some options like SPE and PAIRED are no longer in
2577 rs6000_builtin_mask_calculate (void)
2579 return (((TARGET_ALTIVEC) ? RS6000_BTM_ALTIVEC : 0)
2580 | ((TARGET_VSX) ? RS6000_BTM_VSX : 0)
2581 | ((TARGET_SPE) ? RS6000_BTM_SPE : 0)
2582 | ((TARGET_PAIRED_FLOAT) ? RS6000_BTM_PAIRED : 0)
2583 | ((TARGET_FRE) ? RS6000_BTM_FRE : 0)
2584 | ((TARGET_FRES) ? RS6000_BTM_FRES : 0)
2585 | ((TARGET_FRSQRTE) ? RS6000_BTM_FRSQRTE : 0)
2586 | ((TARGET_FRSQRTES) ? RS6000_BTM_FRSQRTES : 0)
2587 | ((TARGET_POPCNTD) ? RS6000_BTM_POPCNTD : 0)
2588 | ((TARGET_POWERPC) ? RS6000_BTM_POWERPC : 0)
2589 | ((rs6000_cpu == PROCESSOR_CELL) ? RS6000_BTM_CELL : 0));
2592 /* Override command line options. Mostly we process the processor type and
2593 sometimes adjust other TARGET_ options. */
2596 rs6000_option_override_internal (bool global_init_p)
2599 const char *default_cpu = OPTION_TARGET_CPU_DEFAULT;
2603 struct cl_target_option *main_target_opt
2604 = ((global_init_p || target_option_default_node == NULL)
2605 ? NULL : TREE_TARGET_OPTION (target_option_default_node));
2607 /* On 64-bit Darwin, power alignment is ABI-incompatible with some C
2608 library functions, so warn about it. The flag may be useful for
2609 performance studies from time to time though, so don't disable it
2611 if (global_options_set.x_rs6000_alignment_flags
2612 && rs6000_alignment_flags == MASK_ALIGN_POWER
2613 && DEFAULT_ABI == ABI_DARWIN
2615 warning (0, "-malign-power is not supported for 64-bit Darwin;"
2616 " it is incompatible with the installed C and C++ libraries");
2618 if (global_options_set.x_rs6000_spe_abi
2621 error ("not configured for SPE ABI");
2623 /* Numerous experiment shows that IRA based loop pressure
2624 calculation works better for RTL loop invariant motion on targets
2625 with enough (>= 32) registers. It is an expensive optimization.
2626 So it is on only for peak performance. */
2627 if (optimize >= 3 && global_init_p)
2628 flag_ira_loop_pressure = 1;
2630 /* Set the pointer size. */
2633 rs6000_pmode = (int)DImode;
2634 rs6000_pointer_size = 64;
2638 rs6000_pmode = (int)SImode;
2639 rs6000_pointer_size = 32;
2642 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2643 #ifdef OS_MISSING_POWERPC64
2644 if (OS_MISSING_POWERPC64)
2645 set_masks &= ~MASK_POWERPC64;
2647 #ifdef OS_MISSING_ALTIVEC
2648 if (OS_MISSING_ALTIVEC)
2649 set_masks &= ~MASK_ALTIVEC;
2652 /* Don't override by the processor default if given explicitly. */
2653 set_masks &= ~target_flags_explicit;
2655 /* Identify the processor type. */
2658 if (TARGET_POWERPC64)
2659 default_cpu = "powerpc64";
2660 else if (TARGET_POWERPC)
2661 default_cpu = "powerpc";
2664 /* Process the -mcpu=<xxx> and -mtune=<xxx> argument. If the user changed
2665 the cpu in a target attribute or pragma, but did not specify a tuning
2666 option, use the cpu for the tuning option rather than the option specified
2667 with -mtune on the command line. */
2668 if (rs6000_cpu_index > 0)
2669 cpu_index = rs6000_cpu_index;
2670 else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index > 0)
2671 rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index;
2673 rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (default_cpu);
2675 if (rs6000_tune_index > 0)
2676 tune_index = rs6000_tune_index;
2678 rs6000_tune_index = tune_index = cpu_index;
2682 target_flags &= ~set_masks;
2683 target_flags |= (processor_target_table[cpu_index].target_enable
2687 rs6000_cpu = ((tune_index >= 0)
2688 ? processor_target_table[tune_index].processor
2690 ? PROCESSOR_DEFAULT64
2691 : PROCESSOR_DEFAULT));
2693 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2694 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2697 error ("AltiVec not supported in this target");
2699 error ("SPE not supported in this target");
2702 /* Disable Cell microcode if we are optimizing for the Cell
2703 and not optimizing for size. */
2704 if (rs6000_gen_cell_microcode == -1)
2705 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2708 /* If we are optimizing big endian systems for space and it's OK to
2709 use instructions that would be microcoded on the Cell, use the
2710 load/store multiple and string instructions. */
2711 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2712 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2714 /* Don't allow -mmultiple or -mstring on little endian systems
2715 unless the cpu is a 750, because the hardware doesn't support the
2716 instructions used in little endian mode, and causes an alignment
2717 trap. The 750 does not cause an alignment trap (except when the
2718 target is unaligned). */
2720 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2722 if (TARGET_MULTIPLE)
2724 target_flags &= ~MASK_MULTIPLE;
2725 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2726 warning (0, "-mmultiple is not supported on little endian systems");
2731 target_flags &= ~MASK_STRING;
2732 if ((target_flags_explicit & MASK_STRING) != 0)
2733 warning (0, "-mstring is not supported on little endian systems");
2737 /* Add some warnings for VSX. */
2740 const char *msg = NULL;
2741 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2742 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2744 if (target_flags_explicit & MASK_VSX)
2745 msg = N_("-mvsx requires hardware floating point");
2747 target_flags &= ~ MASK_VSX;
2749 else if (TARGET_PAIRED_FLOAT)
2750 msg = N_("-mvsx and -mpaired are incompatible");
2751 /* The hardware will allow VSX and little endian, but until we make sure
2752 things like vector select, etc. work don't allow VSX on little endian
2753 systems at this point. */
2754 else if (!BYTES_BIG_ENDIAN)
2755 msg = N_("-mvsx used with little endian code");
2756 else if (TARGET_AVOID_XFORM > 0)
2757 msg = N_("-mvsx needs indexed addressing");
2758 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2760 if (target_flags_explicit & MASK_VSX)
2761 msg = N_("-mvsx and -mno-altivec are incompatible");
2763 msg = N_("-mno-altivec disables vsx");
2769 target_flags &= ~ MASK_VSX;
2770 target_flags_explicit |= MASK_VSX;
2774 /* For the newer switches (vsx, dfp, etc.) set some of the older options,
2775 unless the user explicitly used the -mno-<option> to disable the code. */
2777 target_flags |= (ISA_2_6_MASKS_SERVER & ~target_flags_explicit);
2778 else if (TARGET_POPCNTD)
2779 target_flags |= (ISA_2_6_MASKS_EMBEDDED & ~target_flags_explicit);
2780 else if (TARGET_DFP)
2781 target_flags |= (ISA_2_5_MASKS_SERVER & ~target_flags_explicit);
2782 else if (TARGET_CMPB)
2783 target_flags |= (ISA_2_5_MASKS_EMBEDDED & ~target_flags_explicit);
2784 else if (TARGET_FPRND)
2785 target_flags |= (ISA_2_4_MASKS & ~target_flags_explicit);
2786 else if (TARGET_POPCNTB)
2787 target_flags |= (ISA_2_2_MASKS & ~target_flags_explicit);
2788 else if (TARGET_ALTIVEC)
2789 target_flags |= (MASK_PPC_GFXOPT & ~target_flags_explicit);
2791 /* E500mc does "better" if we inline more aggressively. Respect the
2792 user's opinion, though. */
2793 if (rs6000_block_move_inline_limit == 0
2794 && (rs6000_cpu == PROCESSOR_PPCE500MC
2795 || rs6000_cpu == PROCESSOR_PPCE500MC64))
2796 rs6000_block_move_inline_limit = 128;
2798 /* store_one_arg depends on expand_block_move to handle at least the
2799 size of reg_parm_stack_space. */
2800 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32))
2801 rs6000_block_move_inline_limit = (TARGET_POWERPC64 ? 64 : 32);
2805 /* If the appropriate debug option is enabled, replace the target hooks
2806 with debug versions that call the real version and then prints
2807 debugging information. */
2808 if (TARGET_DEBUG_COST)
2810 targetm.rtx_costs = rs6000_debug_rtx_costs;
2811 targetm.address_cost = rs6000_debug_address_cost;
2812 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2815 if (TARGET_DEBUG_ADDR)
2817 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2818 targetm.legitimize_address = rs6000_debug_legitimize_address;
2819 rs6000_secondary_reload_class_ptr
2820 = rs6000_debug_secondary_reload_class;
2821 rs6000_secondary_memory_needed_ptr
2822 = rs6000_debug_secondary_memory_needed;
2823 rs6000_cannot_change_mode_class_ptr
2824 = rs6000_debug_cannot_change_mode_class;
2825 rs6000_preferred_reload_class_ptr
2826 = rs6000_debug_preferred_reload_class;
2827 rs6000_legitimize_reload_address_ptr
2828 = rs6000_debug_legitimize_reload_address;
2829 rs6000_mode_dependent_address_ptr
2830 = rs6000_debug_mode_dependent_address;
2833 if (rs6000_veclibabi_name)
2835 if (strcmp (rs6000_veclibabi_name, "mass") == 0)
2836 rs6000_veclib_handler = rs6000_builtin_vectorized_libmass;
2839 error ("unknown vectorization library ABI type (%s) for "
2840 "-mveclibabi= switch", rs6000_veclibabi_name);
2846 if (!global_options_set.x_rs6000_long_double_type_size)
2848 if (main_target_opt != NULL
2849 && (main_target_opt->x_rs6000_long_double_type_size
2850 != RS6000_DEFAULT_LONG_DOUBLE_SIZE))
2851 error ("target attribute or pragma changes long double size");
2853 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2856 #ifndef POWERPC_LINUX
2857 if (!global_options_set.x_rs6000_ieeequad)
2858 rs6000_ieeequad = 1;
2861 /* Disable VSX and Altivec silently if the user switched cpus to power7 in a
2862 target attribute or pragma which automatically enables both options,
2863 unless the altivec ABI was set. This is set by default for 64-bit, but
2865 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2866 target_flags &= ~((MASK_VSX | MASK_ALTIVEC) & ~target_flags_explicit);
2868 /* Enable Altivec ABI for AIX -maltivec. */
2869 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2871 if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi)
2872 error ("target attribute or pragma changes AltiVec ABI");
2874 rs6000_altivec_abi = 1;
2877 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2878 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2879 be explicitly overridden in either case. */
2882 if (!global_options_set.x_rs6000_altivec_abi
2883 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2885 if (main_target_opt != NULL &&
2886 !main_target_opt->x_rs6000_altivec_abi)
2887 error ("target attribute or pragma changes AltiVec ABI");
2889 rs6000_altivec_abi = 1;
2892 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2893 if (!global_options_set.x_TARGET_ALTIVEC_VRSAVE)
2894 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2897 /* Set the Darwin64 ABI as default for 64-bit Darwin.
2898 So far, the only darwin64 targets are also MACH-O. */
2900 && DEFAULT_ABI == ABI_DARWIN
2903 if (main_target_opt != NULL && !main_target_opt->x_rs6000_darwin64_abi)
2904 error ("target attribute or pragma changes darwin64 ABI");
2907 rs6000_darwin64_abi = 1;
2908 /* Default to natural alignment, for better performance. */
2909 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2913 /* Place FP constants in the constant pool instead of TOC
2914 if section anchors enabled. */
2915 if (flag_section_anchors)
2916 TARGET_NO_FP_IN_TOC = 1;
2918 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2919 SUBTARGET_OVERRIDE_OPTIONS;
2921 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2922 SUBSUBTARGET_OVERRIDE_OPTIONS;
2924 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2925 SUB3TARGET_OVERRIDE_OPTIONS;
2928 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2929 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2931 /* The e500 and e500mc do not have string instructions, and we set
2932 MASK_STRING above when optimizing for size. */
2933 if ((target_flags & MASK_STRING) != 0)
2934 target_flags = target_flags & ~MASK_STRING;
2936 else if (global_options_set.x_rs6000_cpu_index)
2938 /* For the powerpc-eabispe configuration, we set all these by
2939 default, so let's unset them if we manually set another
2940 CPU that is not the E500. */
2941 if (main_target_opt != NULL
2942 && ((main_target_opt->x_rs6000_spe_abi != rs6000_spe_abi)
2943 || (main_target_opt->x_rs6000_spe != rs6000_spe)
2944 || (main_target_opt->x_rs6000_float_gprs != rs6000_float_gprs)))
2945 error ("target attribute or pragma changes SPE ABI");
2948 if (!global_options_set.x_rs6000_spe_abi)
2950 if (!global_options_set.x_rs6000_spe)
2952 if (!global_options_set.x_rs6000_float_gprs)
2953 rs6000_float_gprs = 0;
2955 if (!(target_flags_explicit & MASK_ISEL))
2956 target_flags &= ~MASK_ISEL;
2959 /* Detect invalid option combinations with E500. */
2962 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
2963 && rs6000_cpu != PROCESSOR_POWER5
2964 && rs6000_cpu != PROCESSOR_POWER6
2965 && rs6000_cpu != PROCESSOR_POWER7
2966 && rs6000_cpu != PROCESSOR_PPCA2
2967 && rs6000_cpu != PROCESSOR_CELL
2968 && rs6000_cpu != PROCESSOR_PPC476);
2969 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
2970 || rs6000_cpu == PROCESSOR_POWER5
2971 || rs6000_cpu == PROCESSOR_POWER7);
2972 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
2973 || rs6000_cpu == PROCESSOR_POWER5
2974 || rs6000_cpu == PROCESSOR_POWER6
2975 || rs6000_cpu == PROCESSOR_POWER7
2976 || rs6000_cpu == PROCESSOR_PPCE500MC
2977 || rs6000_cpu == PROCESSOR_PPCE500MC64);
2979 /* Allow debug switches to override the above settings. These are set to -1
2980 in rs6000.opt to indicate the user hasn't directly set the switch. */
2981 if (TARGET_ALWAYS_HINT >= 0)
2982 rs6000_always_hint = TARGET_ALWAYS_HINT;
2984 if (TARGET_SCHED_GROUPS >= 0)
2985 rs6000_sched_groups = TARGET_SCHED_GROUPS;
2987 if (TARGET_ALIGN_BRANCH_TARGETS >= 0)
2988 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
2990 rs6000_sched_restricted_insns_priority
2991 = (rs6000_sched_groups ? 1 : 0);
2993 /* Handle -msched-costly-dep option. */
2994 rs6000_sched_costly_dep
2995 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
2997 if (rs6000_sched_costly_dep_str)
2999 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
3000 rs6000_sched_costly_dep = no_dep_costly;
3001 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
3002 rs6000_sched_costly_dep = all_deps_costly;
3003 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
3004 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
3005 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
3006 rs6000_sched_costly_dep = store_to_load_dep_costly;
3008 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
3009 atoi (rs6000_sched_costly_dep_str));
3012 /* Handle -minsert-sched-nops option. */
3013 rs6000_sched_insert_nops
3014 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
3016 if (rs6000_sched_insert_nops_str)
3018 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
3019 rs6000_sched_insert_nops = sched_finish_none;
3020 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
3021 rs6000_sched_insert_nops = sched_finish_pad_groups;
3022 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
3023 rs6000_sched_insert_nops = sched_finish_regroup_exact;
3025 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
3026 atoi (rs6000_sched_insert_nops_str));
3031 #ifdef TARGET_REGNAMES
3032 /* If the user desires alternate register names, copy in the
3033 alternate names now. */
3034 if (TARGET_REGNAMES)
3035 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
3038 /* Set aix_struct_return last, after the ABI is determined.
3039 If -maix-struct-return or -msvr4-struct-return was explicitly
3040 used, don't override with the ABI default. */
3041 if (!global_options_set.x_aix_struct_return)
3042 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
3045 /* IBM XL compiler defaults to unsigned bitfields. */
3046 if (TARGET_XL_COMPAT)
3047 flag_signed_bitfields = 0;
3050 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
3051 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
3054 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
3056 /* We can only guarantee the availability of DI pseudo-ops when
3057 assembling for 64-bit targets. */
3060 targetm.asm_out.aligned_op.di = NULL;
3061 targetm.asm_out.unaligned_op.di = NULL;
3065 /* Set branch target alignment, if not optimizing for size. */
3068 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be
3069 aligned 8byte to avoid misprediction by the branch predictor. */
3070 if (rs6000_cpu == PROCESSOR_TITAN
3071 || rs6000_cpu == PROCESSOR_CELL)
3073 if (align_functions <= 0)
3074 align_functions = 8;
3075 if (align_jumps <= 0)
3077 if (align_loops <= 0)
3080 if (rs6000_align_branch_targets)
3082 if (align_functions <= 0)
3083 align_functions = 16;
3084 if (align_jumps <= 0)
3086 if (align_loops <= 0)
3088 can_override_loop_align = 1;
3092 if (align_jumps_max_skip <= 0)
3093 align_jumps_max_skip = 15;
3094 if (align_loops_max_skip <= 0)
3095 align_loops_max_skip = 15;
3098 /* Arrange to save and restore machine status around nested functions. */
3099 init_machine_status = rs6000_init_machine_status;
3101 /* We should always be splitting complex arguments, but we can't break
3102 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
3103 if (DEFAULT_ABI != ABI_AIX)
3104 targetm.calls.split_complex_arg = NULL;
3107 /* Initialize rs6000_cost with the appropriate target costs. */
3109 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
3113 case PROCESSOR_RIOS1:
3114 rs6000_cost = &rios1_cost;
3117 case PROCESSOR_RIOS2:
3118 rs6000_cost = &rios2_cost;
3121 case PROCESSOR_RS64A:
3122 rs6000_cost = &rs64a_cost;
3125 case PROCESSOR_MPCCORE:
3126 rs6000_cost = &mpccore_cost;
3129 case PROCESSOR_PPC403:
3130 rs6000_cost = &ppc403_cost;
3133 case PROCESSOR_PPC405:
3134 rs6000_cost = &ppc405_cost;
3137 case PROCESSOR_PPC440:
3138 rs6000_cost = &ppc440_cost;
3141 case PROCESSOR_PPC476:
3142 rs6000_cost = &ppc476_cost;
3145 case PROCESSOR_PPC601:
3146 rs6000_cost = &ppc601_cost;
3149 case PROCESSOR_PPC603:
3150 rs6000_cost = &ppc603_cost;
3153 case PROCESSOR_PPC604:
3154 rs6000_cost = &ppc604_cost;
3157 case PROCESSOR_PPC604e:
3158 rs6000_cost = &ppc604e_cost;
3161 case PROCESSOR_PPC620:
3162 rs6000_cost = &ppc620_cost;
3165 case PROCESSOR_PPC630:
3166 rs6000_cost = &ppc630_cost;
3169 case PROCESSOR_CELL:
3170 rs6000_cost = &ppccell_cost;
3173 case PROCESSOR_PPC750:
3174 case PROCESSOR_PPC7400:
3175 rs6000_cost = &ppc750_cost;
3178 case PROCESSOR_PPC7450:
3179 rs6000_cost = &ppc7450_cost;
3182 case PROCESSOR_PPC8540:
3183 rs6000_cost = &ppc8540_cost;
3186 case PROCESSOR_PPCE300C2:
3187 case PROCESSOR_PPCE300C3:
3188 rs6000_cost = &ppce300c2c3_cost;
3191 case PROCESSOR_PPCE500MC:
3192 rs6000_cost = &ppce500mc_cost;
3195 case PROCESSOR_PPCE500MC64:
3196 rs6000_cost = &ppce500mc64_cost;
3199 case PROCESSOR_TITAN:
3200 rs6000_cost = &titan_cost;
3203 case PROCESSOR_POWER4:
3204 case PROCESSOR_POWER5:
3205 rs6000_cost = &power4_cost;
3208 case PROCESSOR_POWER6:
3209 rs6000_cost = &power6_cost;
3212 case PROCESSOR_POWER7:
3213 rs6000_cost = &power7_cost;
3216 case PROCESSOR_PPCA2:
3217 rs6000_cost = &ppca2_cost;
3226 maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
3227 rs6000_cost->simultaneous_prefetches,
3228 global_options.x_param_values,
3229 global_options_set.x_param_values);
3230 maybe_set_param_value (PARAM_L1_CACHE_SIZE, rs6000_cost->l1_cache_size,
3231 global_options.x_param_values,
3232 global_options_set.x_param_values);
3233 maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
3234 rs6000_cost->cache_line_size,
3235 global_options.x_param_values,
3236 global_options_set.x_param_values);
3237 maybe_set_param_value (PARAM_L2_CACHE_SIZE, rs6000_cost->l2_cache_size,
3238 global_options.x_param_values,
3239 global_options_set.x_param_values);
3241 /* If using typedef char *va_list, signal that
3242 __builtin_va_start (&ap, 0) can be optimized to
3243 ap = __builtin_next_arg (0). */
3244 if (DEFAULT_ABI != ABI_V4)
3245 targetm.expand_builtin_va_start = NULL;
3248 /* Set up single/double float flags.
3249 If TARGET_HARD_FLOAT is set, but neither single or double is set,
3250 then set both flags. */
3251 if (TARGET_HARD_FLOAT && TARGET_FPRS
3252 && rs6000_single_float == 0 && rs6000_double_float == 0)
3253 rs6000_single_float = rs6000_double_float = 1;
3255 /* Reset single and double FP flags if target is E500. */
3258 rs6000_single_float = rs6000_double_float = 0;
3259 if (TARGET_E500_SINGLE)
3260 rs6000_single_float = 1;
3261 if (TARGET_E500_DOUBLE)
3262 rs6000_single_float = rs6000_double_float = 1;
3265 if (main_target_opt)
3267 if (main_target_opt->x_rs6000_single_float != rs6000_single_float)
3268 error ("target attribute or pragma changes single precision floating "
3270 if (main_target_opt->x_rs6000_double_float != rs6000_double_float)
3271 error ("target attribute or pragma changes double precision floating "
3275 /* If not explicitly specified via option, decide whether to generate indexed
3276 load/store instructions. */
3277 if (TARGET_AVOID_XFORM == -1)
3278 /* Avoid indexed addressing when targeting Power6 in order to avoid the
3279 DERAT mispredict penalty. However the LVE and STVE altivec instructions
3280 need indexed accesses and the type used is the scalar type of the element
3281 being loaded or stored. */
3282 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB
3283 && !TARGET_ALTIVEC);
3285 /* Set the -mrecip options. */
3286 if (rs6000_recip_name)
3288 char *p = ASTRDUP (rs6000_recip_name);
3290 unsigned int mask, i;
3293 while ((q = strtok (p, ",")) != NULL)
3304 if (!strcmp (q, "default"))
3305 mask = ((TARGET_RECIP_PRECISION)
3306 ? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION);
3309 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
3310 if (!strcmp (q, recip_options[i].string))
3312 mask = recip_options[i].mask;
3316 if (i == ARRAY_SIZE (recip_options))
3318 error ("unknown option for -mrecip=%s", q);
3326 rs6000_recip_control &= ~mask;
3328 rs6000_recip_control |= mask;
3332 /* Set the builtin mask of the various options used that could affect which
3333 builtins were used. In the past we used target_flags, but we've run out
3334 of bits, and some options like SPE and PAIRED are no longer in
3336 rs6000_builtin_mask = rs6000_builtin_mask_calculate ();
3337 if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET)
3338 fprintf (stderr, "new builtin mask = 0x%x%s%s%s%s\n", rs6000_builtin_mask,
3339 (rs6000_builtin_mask & RS6000_BTM_ALTIVEC) ? ", altivec" : "",
3340 (rs6000_builtin_mask & RS6000_BTM_VSX) ? ", vsx" : "",
3341 (rs6000_builtin_mask & RS6000_BTM_PAIRED) ? ", paired" : "",
3342 (rs6000_builtin_mask & RS6000_BTM_SPE) ? ", spe" : "");
3344 /* Initialize all of the registers. */
3345 rs6000_init_hard_regno_mode_ok (global_init_p);
3347 /* Save the initial options in case the user does function specific options */
3349 target_option_default_node = target_option_current_node
3350 = build_target_option_node ();
3352 /* If not explicitly specified via option, decide whether to generate the
3353 extra blr's required to preserve the link stack on some cpus (eg, 476). */
3354 if (TARGET_LINK_STACK == -1)
3355 SET_TARGET_LINK_STACK (rs6000_cpu == PROCESSOR_PPC476 && flag_pic);
3360 /* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to
3361 define the target cpu type. */
3364 rs6000_option_override (void)
3366 (void) rs6000_option_override_internal (true);
3370 /* Implement targetm.vectorize.builtin_mask_for_load. */
3372 rs6000_builtin_mask_for_load (void)
3374 if (TARGET_ALTIVEC || TARGET_VSX)
3375 return altivec_builtin_mask_for_load;
3380 /* Implement LOOP_ALIGN. */
3382 rs6000_loop_align (rtx label)
3387 /* Don't override loop alignment if -falign-loops was specified. */
3388 if (!can_override_loop_align)
3389 return align_loops_log;
3391 bb = BLOCK_FOR_INSN (label);
3392 ninsns = num_loop_insns(bb->loop_father);
3394 /* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */
3395 if (ninsns > 4 && ninsns <= 8
3396 && (rs6000_cpu == PROCESSOR_POWER4
3397 || rs6000_cpu == PROCESSOR_POWER5
3398 || rs6000_cpu == PROCESSOR_POWER6
3399 || rs6000_cpu == PROCESSOR_POWER7))
3402 return align_loops_log;
3405 /* Implement TARGET_LOOP_ALIGN_MAX_SKIP. */
3407 rs6000_loop_align_max_skip (rtx label)
3409 return (1 << rs6000_loop_align (label)) - 1;
3412 /* Implement targetm.vectorize.builtin_mul_widen_even. */
3414 rs6000_builtin_mul_widen_even (tree type)
3416 if (!TARGET_ALTIVEC)
3419 switch (TYPE_MODE (type))
3422 return TYPE_UNSIGNED (type)
3423 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
3424 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
3427 return TYPE_UNSIGNED (type)
3428 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
3429 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
3435 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
3437 rs6000_builtin_mul_widen_odd (tree type)
3439 if (!TARGET_ALTIVEC)
3442 switch (TYPE_MODE (type))
3445 return TYPE_UNSIGNED (type)
3446 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
3447 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
3450 return TYPE_UNSIGNED (type)
3451 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
3452 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
3459 /* Return true iff, data reference of TYPE can reach vector alignment (16)
3460 after applying N number of iterations. This routine does not determine
3461 how may iterations are required to reach desired alignment. */
3464 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3471 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3474 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3484 /* Assuming that all other types are naturally aligned. CHECKME! */
3489 /* Return true if the vector misalignment factor is supported by the
3492 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3499 /* Return if movmisalign pattern is not supported for this mode. */
3500 if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing)
3503 if (misalignment == -1)
3505 /* Misalignment factor is unknown at compile time but we know
3506 it's word aligned. */
3507 if (rs6000_vector_alignment_reachable (type, is_packed))
3509 int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type));
3511 if (element_size == 64 || element_size == 32)
3518 /* VSX supports word-aligned vector. */
3519 if (misalignment % 4 == 0)
3525 /* Implement targetm.vectorize.builtin_vectorization_cost. */
3527 rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
3528 tree vectype, int misalign)
3532 switch (type_of_cost)
3542 case cond_branch_not_taken:
3550 case cond_branch_taken:
3553 case unaligned_load:
3554 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3556 elements = TYPE_VECTOR_SUBPARTS (vectype);
3558 /* Double word aligned. */
3566 /* Double word aligned. */
3570 /* Unknown misalignment. */
3583 /* Misaligned loads are not supported. */
3588 case unaligned_store:
3589 if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN)
3591 elements = TYPE_VECTOR_SUBPARTS (vectype);
3593 /* Double word aligned. */
3601 /* Double word aligned. */
3605 /* Unknown misalignment. */
3618 /* Misaligned stores are not supported. */
3628 /* Implement targetm.vectorize.preferred_simd_mode. */
3630 static enum machine_mode
3631 rs6000_preferred_simd_mode (enum machine_mode mode)
3640 if (TARGET_ALTIVEC || TARGET_VSX)
3664 if (TARGET_PAIRED_FLOAT
3670 /* Handler for the Mathematical Acceleration Subsystem (mass) interface to a
3671 library with vectorized intrinsics. */
3674 rs6000_builtin_vectorized_libmass (tree fndecl, tree type_out, tree type_in)
3677 const char *suffix = NULL;
3678 tree fntype, new_fndecl, bdecl = NULL_TREE;
3681 enum machine_mode el_mode, in_mode;
3684 /* Libmass is suitable for unsafe math only as it does not correctly support
3685 parts of IEEE with the required precision such as denormals. Only support
3686 it if we have VSX to use the simd d2 or f4 functions.
3687 XXX: Add variable length support. */
3688 if (!flag_unsafe_math_optimizations || !TARGET_VSX)
3691 el_mode = TYPE_MODE (TREE_TYPE (type_out));
3692 n = TYPE_VECTOR_SUBPARTS (type_out);
3693 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3694 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3695 if (el_mode != in_mode
3699 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
3701 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3704 case BUILT_IN_ATAN2:
3705 case BUILT_IN_HYPOT:
3711 case BUILT_IN_ACOSH:
3713 case BUILT_IN_ASINH:
3715 case BUILT_IN_ATANH:
3723 case BUILT_IN_EXPM1:
3724 case BUILT_IN_LGAMMA:
3725 case BUILT_IN_LOG10:
3726 case BUILT_IN_LOG1P:
3734 bdecl = builtin_decl_implicit (fn);
3735 suffix = "d2"; /* pow -> powd2 */
3736 if (el_mode != DFmode
3741 case BUILT_IN_ATAN2F:
3742 case BUILT_IN_HYPOTF:
3747 case BUILT_IN_ACOSF:
3748 case BUILT_IN_ACOSHF:
3749 case BUILT_IN_ASINF:
3750 case BUILT_IN_ASINHF:
3751 case BUILT_IN_ATANF:
3752 case BUILT_IN_ATANHF:
3753 case BUILT_IN_CBRTF:
3755 case BUILT_IN_COSHF:
3757 case BUILT_IN_ERFCF:
3758 case BUILT_IN_EXP2F:
3760 case BUILT_IN_EXPM1F:
3761 case BUILT_IN_LGAMMAF:
3762 case BUILT_IN_LOG10F:
3763 case BUILT_IN_LOG1PF:
3764 case BUILT_IN_LOG2F:
3767 case BUILT_IN_SINHF:
3768 case BUILT_IN_SQRTF:
3770 case BUILT_IN_TANHF:
3771 bdecl = builtin_decl_implicit (fn);
3772 suffix = "4"; /* powf -> powf4 */
3773 if (el_mode != SFmode
3785 gcc_assert (suffix != NULL);
3786 bname = IDENTIFIER_POINTER (DECL_NAME (bdecl));
3787 strcpy (name, bname + sizeof ("__builtin_") - 1);
3788 strcat (name, suffix);
3791 fntype = build_function_type_list (type_out, type_in, NULL);
3792 else if (n_args == 2)
3793 fntype = build_function_type_list (type_out, type_in, type_in, NULL);
3797 /* Build a function declaration for the vectorized function. */
3798 new_fndecl = build_decl (BUILTINS_LOCATION,
3799 FUNCTION_DECL, get_identifier (name), fntype);
3800 TREE_PUBLIC (new_fndecl) = 1;
3801 DECL_EXTERNAL (new_fndecl) = 1;
3802 DECL_IS_NOVOPS (new_fndecl) = 1;
3803 TREE_READONLY (new_fndecl) = 1;
3808 /* Returns a function decl for a vectorized version of the builtin function
3809 with builtin function code FN and the result vector type TYPE, or NULL_TREE
3810 if it is not available. */
3813 rs6000_builtin_vectorized_function (tree fndecl, tree type_out,
3816 enum machine_mode in_mode, out_mode;
3819 if (TARGET_DEBUG_BUILTIN)
3820 fprintf (stderr, "rs6000_builtin_vectorized_function (%s, %s, %s)\n",
3821 IDENTIFIER_POINTER (DECL_NAME (fndecl)),
3822 GET_MODE_NAME (TYPE_MODE (type_out)),
3823 GET_MODE_NAME (TYPE_MODE (type_in)));
3825 if (TREE_CODE (type_out) != VECTOR_TYPE
3826 || TREE_CODE (type_in) != VECTOR_TYPE
3827 || !TARGET_VECTORIZE_BUILTINS)
3830 out_mode = TYPE_MODE (TREE_TYPE (type_out));
3831 out_n = TYPE_VECTOR_SUBPARTS (type_out);
3832 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3833 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3835 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
3837 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3840 case BUILT_IN_COPYSIGN:
3841 if (VECTOR_UNIT_VSX_P (V2DFmode)
3842 && out_mode == DFmode && out_n == 2
3843 && in_mode == DFmode && in_n == 2)
3844 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNDP];
3846 case BUILT_IN_COPYSIGNF:
3847 if (out_mode != SFmode || out_n != 4
3848 || in_mode != SFmode || in_n != 4)
3850 if (VECTOR_UNIT_VSX_P (V4SFmode))
3851 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNSP];
3852 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3853 return rs6000_builtin_decls[ALTIVEC_BUILTIN_COPYSIGN_V4SF];
3856 if (VECTOR_UNIT_VSX_P (V2DFmode)
3857 && out_mode == DFmode && out_n == 2
3858 && in_mode == DFmode && in_n == 2)
3859 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTDP];
3861 case BUILT_IN_SQRTF:
3862 if (VECTOR_UNIT_VSX_P (V4SFmode)
3863 && out_mode == SFmode && out_n == 4
3864 && in_mode == SFmode && in_n == 4)
3865 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTSP];
3868 if (VECTOR_UNIT_VSX_P (V2DFmode)
3869 && out_mode == DFmode && out_n == 2
3870 && in_mode == DFmode && in_n == 2)
3871 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIP];
3873 case BUILT_IN_CEILF:
3874 if (out_mode != SFmode || out_n != 4
3875 || in_mode != SFmode || in_n != 4)
3877 if (VECTOR_UNIT_VSX_P (V4SFmode))
3878 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIP];
3879 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3880 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIP];
3882 case BUILT_IN_FLOOR:
3883 if (VECTOR_UNIT_VSX_P (V2DFmode)
3884 && out_mode == DFmode && out_n == 2
3885 && in_mode == DFmode && in_n == 2)
3886 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIM];
3888 case BUILT_IN_FLOORF:
3889 if (out_mode != SFmode || out_n != 4
3890 || in_mode != SFmode || in_n != 4)
3892 if (VECTOR_UNIT_VSX_P (V4SFmode))
3893 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIM];
3894 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3895 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIM];
3898 if (VECTOR_UNIT_VSX_P (V2DFmode)
3899 && out_mode == DFmode && out_n == 2
3900 && in_mode == DFmode && in_n == 2)
3901 return rs6000_builtin_decls[VSX_BUILTIN_XVMADDDP];
3904 if (VECTOR_UNIT_VSX_P (V4SFmode)
3905 && out_mode == SFmode && out_n == 4
3906 && in_mode == SFmode && in_n == 4)
3907 return rs6000_builtin_decls[VSX_BUILTIN_XVMADDSP];
3908 else if (VECTOR_UNIT_ALTIVEC_P (V4SFmode)
3909 && out_mode == SFmode && out_n == 4
3910 && in_mode == SFmode && in_n == 4)
3911 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VMADDFP];
3913 case BUILT_IN_TRUNC:
3914 if (VECTOR_UNIT_VSX_P (V2DFmode)
3915 && out_mode == DFmode && out_n == 2
3916 && in_mode == DFmode && in_n == 2)
3917 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIZ];
3919 case BUILT_IN_TRUNCF:
3920 if (out_mode != SFmode || out_n != 4
3921 || in_mode != SFmode || in_n != 4)
3923 if (VECTOR_UNIT_VSX_P (V4SFmode))
3924 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIZ];
3925 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3926 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIZ];
3928 case BUILT_IN_NEARBYINT:
3929 if (VECTOR_UNIT_VSX_P (V2DFmode)
3930 && flag_unsafe_math_optimizations
3931 && out_mode == DFmode && out_n == 2
3932 && in_mode == DFmode && in_n == 2)
3933 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPI];
3935 case BUILT_IN_NEARBYINTF:
3936 if (VECTOR_UNIT_VSX_P (V4SFmode)
3937 && flag_unsafe_math_optimizations
3938 && out_mode == SFmode && out_n == 4
3939 && in_mode == SFmode && in_n == 4)
3940 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPI];