1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 3, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
54 #include "sched-int.h"
56 #include "tree-flow.h"
59 #include "tm-constrs.h"
61 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
64 #include "gstab.h" /* for N_SLINE */
67 #ifndef TARGET_NO_PROTOTYPE
68 #define TARGET_NO_PROTOTYPE 0
71 #define min(A,B) ((A) < (B) ? (A) : (B))
72 #define max(A,B) ((A) > (B) ? (A) : (B))
74 /* Structure used to define the rs6000 stack */
75 typedef struct rs6000_stack {
76 int first_gp_reg_save; /* first callee saved GP register used */
77 int first_fp_reg_save; /* first callee saved FP register used */
78 int first_altivec_reg_save; /* first callee saved AltiVec register used */
79 int lr_save_p; /* true if the link reg needs to be saved */
80 int cr_save_p; /* true if the CR reg needs to be saved */
81 unsigned int vrsave_mask; /* mask of vec registers to save */
82 int push_p; /* true if we need to allocate stack space */
83 int calls_p; /* true if the function makes any calls */
84 int world_save_p; /* true if we're saving *everything*:
85 r13-r31, cr, f14-f31, vrsave, v20-v31 */
86 enum rs6000_abi abi; /* which ABI to use */
87 int gp_save_offset; /* offset to save GP regs from initial SP */
88 int fp_save_offset; /* offset to save FP regs from initial SP */
89 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
90 int lr_save_offset; /* offset to save LR from initial SP */
91 int cr_save_offset; /* offset to save CR from initial SP */
92 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
93 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
94 int varargs_save_offset; /* offset to save the varargs registers */
95 int ehrd_offset; /* offset to EH return data */
96 int reg_size; /* register size (4 or 8) */
97 HOST_WIDE_INT vars_size; /* variable save area size */
98 int parm_size; /* outgoing parameter size */
99 int save_size; /* save area size */
100 int fixed_size; /* fixed size of stack frame */
101 int gp_size; /* size of saved GP registers */
102 int fp_size; /* size of saved FP registers */
103 int altivec_size; /* size of saved AltiVec registers */
104 int cr_size; /* size to hold CR if not in save_size */
105 int vrsave_size; /* size to hold VRSAVE if not in save_size */
106 int altivec_padding_size; /* size of altivec alignment padding if
108 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
109 int spe_padding_size;
110 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
111 int spe_64bit_regs_used;
114 /* A C structure for machine-specific, per-function data.
115 This is added to the cfun structure. */
116 typedef struct GTY(()) machine_function
118 /* Some local-dynamic symbol. */
119 const char *some_ld_name;
120 /* Whether the instruction chain has been scanned already. */
121 int insn_chain_scanned_p;
122 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
123 int ra_needs_full_frame;
124 /* Flags if __builtin_return_address (0) was used. */
126 /* Cache lr_save_p after expansion of builtin_eh_return. */
128 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
129 varargs save area. */
130 HOST_WIDE_INT varargs_save_offset;
131 /* Temporary stack slot to use for SDmode copies. This slot is
132 64-bits wide and is allocated early enough so that the offset
133 does not overflow the 16-bit load/store offset field. */
134 rtx sdmode_stack_slot;
137 /* Target cpu type */
139 enum processor_type rs6000_cpu;
140 struct rs6000_cpu_select rs6000_select[3] =
142 /* switch name, tune arch */
143 { (const char *)0, "--with-cpu=", 1, 1 },
144 { (const char *)0, "-mcpu=", 1, 1 },
145 { (const char *)0, "-mtune=", 1, 0 },
148 /* Always emit branch hint bits. */
149 static GTY(()) bool rs6000_always_hint;
151 /* Schedule instructions for group formation. */
152 static GTY(()) bool rs6000_sched_groups;
154 /* Align branch targets. */
155 static GTY(()) bool rs6000_align_branch_targets;
157 /* Support for -msched-costly-dep option. */
158 const char *rs6000_sched_costly_dep_str;
159 enum rs6000_dependence_cost rs6000_sched_costly_dep;
161 /* Support for -minsert-sched-nops option. */
162 const char *rs6000_sched_insert_nops_str;
163 enum rs6000_nop_insertion rs6000_sched_insert_nops;
165 /* Support targetm.vectorize.builtin_mask_for_load. */
166 static GTY(()) tree altivec_builtin_mask_for_load;
168 /* Size of long double. */
169 int rs6000_long_double_type_size;
171 /* IEEE quad extended precision long double. */
174 /* Nonzero to use AltiVec ABI. */
175 int rs6000_altivec_abi;
177 /* Nonzero if we want SPE SIMD instructions. */
180 /* Nonzero if we want SPE ABI extensions. */
183 /* Nonzero if floating point operations are done in the GPRs. */
184 int rs6000_float_gprs = 0;
186 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
187 int rs6000_darwin64_abi;
189 /* Set to nonzero once AIX common-mode calls have been defined. */
190 static GTY(()) int common_mode_defined;
192 /* Label number of label created for -mrelocatable, to call to so we can
193 get the address of the GOT section */
194 int rs6000_pic_labelno;
197 /* Which abi to adhere to */
198 const char *rs6000_abi_name;
200 /* Semantics of the small data area */
201 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
203 /* Which small data model to use */
204 const char *rs6000_sdata_name = (char *)0;
206 /* Counter for labels which are to be placed in .fixup. */
207 int fixuplabelno = 0;
210 /* Bit size of immediate TLS offsets and string from which it is decoded. */
211 int rs6000_tls_size = 32;
212 const char *rs6000_tls_size_string;
214 /* ABI enumeration available for subtarget to use. */
215 enum rs6000_abi rs6000_current_abi;
217 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
221 const char *rs6000_debug_name;
222 int rs6000_debug_stack; /* debug stack applications */
223 int rs6000_debug_arg; /* debug argument handling */
224 int rs6000_debug_reg; /* debug register classes */
225 int rs6000_debug_addr; /* debug memory addressing */
226 int rs6000_debug_cost; /* debug rtx_costs */
228 /* Specify the machine mode that pointers have. After generation of rtl, the
229 compiler makes no further distinction between pointers and any other objects
230 of this machine mode. The type is unsigned since not all things that
231 include rs6000.h also include machmode.h. */
232 unsigned rs6000_pmode;
234 /* Width in bits of a pointer. */
235 unsigned rs6000_pointer_size;
238 /* Value is TRUE if register/mode pair is acceptable. */
239 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
241 /* Maximum number of registers needed for a given register class and mode. */
242 unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES];
244 /* How many registers are needed for a given register and mode. */
245 unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
247 /* Map register number to register class. */
248 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
250 /* Reload functions based on the type and the vector unit. */
251 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
253 /* Built in types. */
254 tree rs6000_builtin_types[RS6000_BTI_MAX];
255 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
257 const char *rs6000_traceback_name;
259 traceback_default = 0,
265 /* Flag to say the TOC is initialized */
267 char toc_label_name[10];
269 /* Cached value of rs6000_variable_issue. This is cached in
270 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
271 static short cached_can_issue_more;
273 static GTY(()) section *read_only_data_section;
274 static GTY(()) section *private_data_section;
275 static GTY(()) section *read_only_private_data_section;
276 static GTY(()) section *sdata2_section;
277 static GTY(()) section *toc_section;
279 /* Control alignment for fields within structures. */
280 /* String from -malign-XXXXX. */
281 int rs6000_alignment_flags;
283 /* True for any options that were explicitly set. */
285 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
286 bool alignment; /* True if -malign- was used. */
287 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
288 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
289 bool spe; /* True if -mspe= was used. */
290 bool float_gprs; /* True if -mfloat-gprs= was used. */
291 bool long_double; /* True if -mlong-double- was used. */
292 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
293 bool vrsave; /* True if -mvrsave was used. */
294 } rs6000_explicit_options;
296 struct builtin_description
298 /* mask is not const because we're going to alter it below. This
299 nonsense will go away when we rewrite the -march infrastructure
300 to give us more target flag bits. */
302 const enum insn_code icode;
303 const char *const name;
304 const enum rs6000_builtins code;
307 /* Describe the vector unit used for modes. */
308 enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
309 enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES];
311 /* Register classes for various constraints that are based on the target
313 enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
315 /* Describe the alignment of a vector. */
316 int rs6000_vector_align[NUM_MACHINE_MODES];
318 /* Map selected modes to types for builtins. */
319 static GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
321 /* Target cpu costs. */
323 struct processor_costs {
324 const int mulsi; /* cost of SImode multiplication. */
325 const int mulsi_const; /* cost of SImode multiplication by constant. */
326 const int mulsi_const9; /* cost of SImode mult by short constant. */
327 const int muldi; /* cost of DImode multiplication. */
328 const int divsi; /* cost of SImode division. */
329 const int divdi; /* cost of DImode division. */
330 const int fp; /* cost of simple SFmode and DFmode insns. */
331 const int dmul; /* cost of DFmode multiplication (and fmadd). */
332 const int sdiv; /* cost of SFmode division (fdivs). */
333 const int ddiv; /* cost of DFmode division (fdiv). */
334 const int cache_line_size; /* cache line size in bytes. */
335 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
336 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
337 const int simultaneous_prefetches; /* number of parallel prefetch
341 const struct processor_costs *rs6000_cost;
343 /* Processor costs (relative to an add) */
345 /* Instruction size costs on 32bit processors. */
347 struct processor_costs size32_cost = {
348 COSTS_N_INSNS (1), /* mulsi */
349 COSTS_N_INSNS (1), /* mulsi_const */
350 COSTS_N_INSNS (1), /* mulsi_const9 */
351 COSTS_N_INSNS (1), /* muldi */
352 COSTS_N_INSNS (1), /* divsi */
353 COSTS_N_INSNS (1), /* divdi */
354 COSTS_N_INSNS (1), /* fp */
355 COSTS_N_INSNS (1), /* dmul */
356 COSTS_N_INSNS (1), /* sdiv */
357 COSTS_N_INSNS (1), /* ddiv */
364 /* Instruction size costs on 64bit processors. */
366 struct processor_costs size64_cost = {
367 COSTS_N_INSNS (1), /* mulsi */
368 COSTS_N_INSNS (1), /* mulsi_const */
369 COSTS_N_INSNS (1), /* mulsi_const9 */
370 COSTS_N_INSNS (1), /* muldi */
371 COSTS_N_INSNS (1), /* divsi */
372 COSTS_N_INSNS (1), /* divdi */
373 COSTS_N_INSNS (1), /* fp */
374 COSTS_N_INSNS (1), /* dmul */
375 COSTS_N_INSNS (1), /* sdiv */
376 COSTS_N_INSNS (1), /* ddiv */
383 /* Instruction costs on RIOS1 processors. */
385 struct processor_costs rios1_cost = {
386 COSTS_N_INSNS (5), /* mulsi */
387 COSTS_N_INSNS (4), /* mulsi_const */
388 COSTS_N_INSNS (3), /* mulsi_const9 */
389 COSTS_N_INSNS (5), /* muldi */
390 COSTS_N_INSNS (19), /* divsi */
391 COSTS_N_INSNS (19), /* divdi */
392 COSTS_N_INSNS (2), /* fp */
393 COSTS_N_INSNS (2), /* dmul */
394 COSTS_N_INSNS (19), /* sdiv */
395 COSTS_N_INSNS (19), /* ddiv */
396 128, /* cache line size */
402 /* Instruction costs on RIOS2 processors. */
404 struct processor_costs rios2_cost = {
405 COSTS_N_INSNS (2), /* mulsi */
406 COSTS_N_INSNS (2), /* mulsi_const */
407 COSTS_N_INSNS (2), /* mulsi_const9 */
408 COSTS_N_INSNS (2), /* muldi */
409 COSTS_N_INSNS (13), /* divsi */
410 COSTS_N_INSNS (13), /* divdi */
411 COSTS_N_INSNS (2), /* fp */
412 COSTS_N_INSNS (2), /* dmul */
413 COSTS_N_INSNS (17), /* sdiv */
414 COSTS_N_INSNS (17), /* ddiv */
415 256, /* cache line size */
421 /* Instruction costs on RS64A processors. */
423 struct processor_costs rs64a_cost = {
424 COSTS_N_INSNS (20), /* mulsi */
425 COSTS_N_INSNS (12), /* mulsi_const */
426 COSTS_N_INSNS (8), /* mulsi_const9 */
427 COSTS_N_INSNS (34), /* muldi */
428 COSTS_N_INSNS (65), /* divsi */
429 COSTS_N_INSNS (67), /* divdi */
430 COSTS_N_INSNS (4), /* fp */
431 COSTS_N_INSNS (4), /* dmul */
432 COSTS_N_INSNS (31), /* sdiv */
433 COSTS_N_INSNS (31), /* ddiv */
434 128, /* cache line size */
440 /* Instruction costs on MPCCORE processors. */
442 struct processor_costs mpccore_cost = {
443 COSTS_N_INSNS (2), /* mulsi */
444 COSTS_N_INSNS (2), /* mulsi_const */
445 COSTS_N_INSNS (2), /* mulsi_const9 */
446 COSTS_N_INSNS (2), /* muldi */
447 COSTS_N_INSNS (6), /* divsi */
448 COSTS_N_INSNS (6), /* divdi */
449 COSTS_N_INSNS (4), /* fp */
450 COSTS_N_INSNS (5), /* dmul */
451 COSTS_N_INSNS (10), /* sdiv */
452 COSTS_N_INSNS (17), /* ddiv */
453 32, /* cache line size */
459 /* Instruction costs on PPC403 processors. */
461 struct processor_costs ppc403_cost = {
462 COSTS_N_INSNS (4), /* mulsi */
463 COSTS_N_INSNS (4), /* mulsi_const */
464 COSTS_N_INSNS (4), /* mulsi_const9 */
465 COSTS_N_INSNS (4), /* muldi */
466 COSTS_N_INSNS (33), /* divsi */
467 COSTS_N_INSNS (33), /* divdi */
468 COSTS_N_INSNS (11), /* fp */
469 COSTS_N_INSNS (11), /* dmul */
470 COSTS_N_INSNS (11), /* sdiv */
471 COSTS_N_INSNS (11), /* ddiv */
472 32, /* cache line size */
478 /* Instruction costs on PPC405 processors. */
480 struct processor_costs ppc405_cost = {
481 COSTS_N_INSNS (5), /* mulsi */
482 COSTS_N_INSNS (4), /* mulsi_const */
483 COSTS_N_INSNS (3), /* mulsi_const9 */
484 COSTS_N_INSNS (5), /* muldi */
485 COSTS_N_INSNS (35), /* divsi */
486 COSTS_N_INSNS (35), /* divdi */
487 COSTS_N_INSNS (11), /* fp */
488 COSTS_N_INSNS (11), /* dmul */
489 COSTS_N_INSNS (11), /* sdiv */
490 COSTS_N_INSNS (11), /* ddiv */
491 32, /* cache line size */
497 /* Instruction costs on PPC440 processors. */
499 struct processor_costs ppc440_cost = {
500 COSTS_N_INSNS (3), /* mulsi */
501 COSTS_N_INSNS (2), /* mulsi_const */
502 COSTS_N_INSNS (2), /* mulsi_const9 */
503 COSTS_N_INSNS (3), /* muldi */
504 COSTS_N_INSNS (34), /* divsi */
505 COSTS_N_INSNS (34), /* divdi */
506 COSTS_N_INSNS (5), /* fp */
507 COSTS_N_INSNS (5), /* dmul */
508 COSTS_N_INSNS (19), /* sdiv */
509 COSTS_N_INSNS (33), /* ddiv */
510 32, /* cache line size */
516 /* Instruction costs on PPC476 processors. */
518 struct processor_costs ppc476_cost = {
519 COSTS_N_INSNS (4), /* mulsi */
520 COSTS_N_INSNS (4), /* mulsi_const */
521 COSTS_N_INSNS (4), /* mulsi_const9 */
522 COSTS_N_INSNS (4), /* muldi */
523 COSTS_N_INSNS (11), /* divsi */
524 COSTS_N_INSNS (11), /* divdi */
525 COSTS_N_INSNS (6), /* fp */
526 COSTS_N_INSNS (6), /* dmul */
527 COSTS_N_INSNS (19), /* sdiv */
528 COSTS_N_INSNS (33), /* ddiv */
529 32, /* l1 cache line size */
535 /* Instruction costs on PPC601 processors. */
537 struct processor_costs ppc601_cost = {
538 COSTS_N_INSNS (5), /* mulsi */
539 COSTS_N_INSNS (5), /* mulsi_const */
540 COSTS_N_INSNS (5), /* mulsi_const9 */
541 COSTS_N_INSNS (5), /* muldi */
542 COSTS_N_INSNS (36), /* divsi */
543 COSTS_N_INSNS (36), /* divdi */
544 COSTS_N_INSNS (4), /* fp */
545 COSTS_N_INSNS (5), /* dmul */
546 COSTS_N_INSNS (17), /* sdiv */
547 COSTS_N_INSNS (31), /* ddiv */
548 32, /* cache line size */
554 /* Instruction costs on PPC603 processors. */
556 struct processor_costs ppc603_cost = {
557 COSTS_N_INSNS (5), /* mulsi */
558 COSTS_N_INSNS (3), /* mulsi_const */
559 COSTS_N_INSNS (2), /* mulsi_const9 */
560 COSTS_N_INSNS (5), /* muldi */
561 COSTS_N_INSNS (37), /* divsi */
562 COSTS_N_INSNS (37), /* divdi */
563 COSTS_N_INSNS (3), /* fp */
564 COSTS_N_INSNS (4), /* dmul */
565 COSTS_N_INSNS (18), /* sdiv */
566 COSTS_N_INSNS (33), /* ddiv */
567 32, /* cache line size */
573 /* Instruction costs on PPC604 processors. */
575 struct processor_costs ppc604_cost = {
576 COSTS_N_INSNS (4), /* mulsi */
577 COSTS_N_INSNS (4), /* mulsi_const */
578 COSTS_N_INSNS (4), /* mulsi_const9 */
579 COSTS_N_INSNS (4), /* muldi */
580 COSTS_N_INSNS (20), /* divsi */
581 COSTS_N_INSNS (20), /* divdi */
582 COSTS_N_INSNS (3), /* fp */
583 COSTS_N_INSNS (3), /* dmul */
584 COSTS_N_INSNS (18), /* sdiv */
585 COSTS_N_INSNS (32), /* ddiv */
586 32, /* cache line size */
592 /* Instruction costs on PPC604e processors. */
594 struct processor_costs ppc604e_cost = {
595 COSTS_N_INSNS (2), /* mulsi */
596 COSTS_N_INSNS (2), /* mulsi_const */
597 COSTS_N_INSNS (2), /* mulsi_const9 */
598 COSTS_N_INSNS (2), /* muldi */
599 COSTS_N_INSNS (20), /* divsi */
600 COSTS_N_INSNS (20), /* divdi */
601 COSTS_N_INSNS (3), /* fp */
602 COSTS_N_INSNS (3), /* dmul */
603 COSTS_N_INSNS (18), /* sdiv */
604 COSTS_N_INSNS (32), /* ddiv */
605 32, /* cache line size */
611 /* Instruction costs on PPC620 processors. */
613 struct processor_costs ppc620_cost = {
614 COSTS_N_INSNS (5), /* mulsi */
615 COSTS_N_INSNS (4), /* mulsi_const */
616 COSTS_N_INSNS (3), /* mulsi_const9 */
617 COSTS_N_INSNS (7), /* muldi */
618 COSTS_N_INSNS (21), /* divsi */
619 COSTS_N_INSNS (37), /* divdi */
620 COSTS_N_INSNS (3), /* fp */
621 COSTS_N_INSNS (3), /* dmul */
622 COSTS_N_INSNS (18), /* sdiv */
623 COSTS_N_INSNS (32), /* ddiv */
624 128, /* cache line size */
630 /* Instruction costs on PPC630 processors. */
632 struct processor_costs ppc630_cost = {
633 COSTS_N_INSNS (5), /* mulsi */
634 COSTS_N_INSNS (4), /* mulsi_const */
635 COSTS_N_INSNS (3), /* mulsi_const9 */
636 COSTS_N_INSNS (7), /* muldi */
637 COSTS_N_INSNS (21), /* divsi */
638 COSTS_N_INSNS (37), /* divdi */
639 COSTS_N_INSNS (3), /* fp */
640 COSTS_N_INSNS (3), /* dmul */
641 COSTS_N_INSNS (17), /* sdiv */
642 COSTS_N_INSNS (21), /* ddiv */
643 128, /* cache line size */
649 /* Instruction costs on Cell processor. */
650 /* COSTS_N_INSNS (1) ~ one add. */
652 struct processor_costs ppccell_cost = {
653 COSTS_N_INSNS (9/2)+2, /* mulsi */
654 COSTS_N_INSNS (6/2), /* mulsi_const */
655 COSTS_N_INSNS (6/2), /* mulsi_const9 */
656 COSTS_N_INSNS (15/2)+2, /* muldi */
657 COSTS_N_INSNS (38/2), /* divsi */
658 COSTS_N_INSNS (70/2), /* divdi */
659 COSTS_N_INSNS (10/2), /* fp */
660 COSTS_N_INSNS (10/2), /* dmul */
661 COSTS_N_INSNS (74/2), /* sdiv */
662 COSTS_N_INSNS (74/2), /* ddiv */
663 128, /* cache line size */
669 /* Instruction costs on PPC750 and PPC7400 processors. */
671 struct processor_costs ppc750_cost = {
672 COSTS_N_INSNS (5), /* mulsi */
673 COSTS_N_INSNS (3), /* mulsi_const */
674 COSTS_N_INSNS (2), /* mulsi_const9 */
675 COSTS_N_INSNS (5), /* muldi */
676 COSTS_N_INSNS (17), /* divsi */
677 COSTS_N_INSNS (17), /* divdi */
678 COSTS_N_INSNS (3), /* fp */
679 COSTS_N_INSNS (3), /* dmul */
680 COSTS_N_INSNS (17), /* sdiv */
681 COSTS_N_INSNS (31), /* ddiv */
682 32, /* cache line size */
688 /* Instruction costs on PPC7450 processors. */
690 struct processor_costs ppc7450_cost = {
691 COSTS_N_INSNS (4), /* mulsi */
692 COSTS_N_INSNS (3), /* mulsi_const */
693 COSTS_N_INSNS (3), /* mulsi_const9 */
694 COSTS_N_INSNS (4), /* muldi */
695 COSTS_N_INSNS (23), /* divsi */
696 COSTS_N_INSNS (23), /* divdi */
697 COSTS_N_INSNS (5), /* fp */
698 COSTS_N_INSNS (5), /* dmul */
699 COSTS_N_INSNS (21), /* sdiv */
700 COSTS_N_INSNS (35), /* ddiv */
701 32, /* cache line size */
707 /* Instruction costs on PPC8540 processors. */
709 struct processor_costs ppc8540_cost = {
710 COSTS_N_INSNS (4), /* mulsi */
711 COSTS_N_INSNS (4), /* mulsi_const */
712 COSTS_N_INSNS (4), /* mulsi_const9 */
713 COSTS_N_INSNS (4), /* muldi */
714 COSTS_N_INSNS (19), /* divsi */
715 COSTS_N_INSNS (19), /* divdi */
716 COSTS_N_INSNS (4), /* fp */
717 COSTS_N_INSNS (4), /* dmul */
718 COSTS_N_INSNS (29), /* sdiv */
719 COSTS_N_INSNS (29), /* ddiv */
720 32, /* cache line size */
723 1, /* prefetch streams /*/
726 /* Instruction costs on E300C2 and E300C3 cores. */
728 struct processor_costs ppce300c2c3_cost = {
729 COSTS_N_INSNS (4), /* mulsi */
730 COSTS_N_INSNS (4), /* mulsi_const */
731 COSTS_N_INSNS (4), /* mulsi_const9 */
732 COSTS_N_INSNS (4), /* muldi */
733 COSTS_N_INSNS (19), /* divsi */
734 COSTS_N_INSNS (19), /* divdi */
735 COSTS_N_INSNS (3), /* fp */
736 COSTS_N_INSNS (4), /* dmul */
737 COSTS_N_INSNS (18), /* sdiv */
738 COSTS_N_INSNS (33), /* ddiv */
742 1, /* prefetch streams /*/
745 /* Instruction costs on PPCE500MC processors. */
747 struct processor_costs ppce500mc_cost = {
748 COSTS_N_INSNS (4), /* mulsi */
749 COSTS_N_INSNS (4), /* mulsi_const */
750 COSTS_N_INSNS (4), /* mulsi_const9 */
751 COSTS_N_INSNS (4), /* muldi */
752 COSTS_N_INSNS (14), /* divsi */
753 COSTS_N_INSNS (14), /* divdi */
754 COSTS_N_INSNS (8), /* fp */
755 COSTS_N_INSNS (10), /* dmul */
756 COSTS_N_INSNS (36), /* sdiv */
757 COSTS_N_INSNS (66), /* ddiv */
758 64, /* cache line size */
761 1, /* prefetch streams /*/
764 /* Instruction costs on PPCE500MC64 processors. */
766 struct processor_costs ppce500mc64_cost = {
767 COSTS_N_INSNS (4), /* mulsi */
768 COSTS_N_INSNS (4), /* mulsi_const */
769 COSTS_N_INSNS (4), /* mulsi_const9 */
770 COSTS_N_INSNS (4), /* muldi */
771 COSTS_N_INSNS (14), /* divsi */
772 COSTS_N_INSNS (14), /* divdi */
773 COSTS_N_INSNS (4), /* fp */
774 COSTS_N_INSNS (10), /* dmul */
775 COSTS_N_INSNS (36), /* sdiv */
776 COSTS_N_INSNS (66), /* ddiv */
777 64, /* cache line size */
780 1, /* prefetch streams /*/
783 /* Instruction costs on POWER4 and POWER5 processors. */
785 struct processor_costs power4_cost = {
786 COSTS_N_INSNS (3), /* mulsi */
787 COSTS_N_INSNS (2), /* mulsi_const */
788 COSTS_N_INSNS (2), /* mulsi_const9 */
789 COSTS_N_INSNS (4), /* muldi */
790 COSTS_N_INSNS (18), /* divsi */
791 COSTS_N_INSNS (34), /* divdi */
792 COSTS_N_INSNS (3), /* fp */
793 COSTS_N_INSNS (3), /* dmul */
794 COSTS_N_INSNS (17), /* sdiv */
795 COSTS_N_INSNS (17), /* ddiv */
796 128, /* cache line size */
799 8, /* prefetch streams /*/
802 /* Instruction costs on POWER6 processors. */
804 struct processor_costs power6_cost = {
805 COSTS_N_INSNS (8), /* mulsi */
806 COSTS_N_INSNS (8), /* mulsi_const */
807 COSTS_N_INSNS (8), /* mulsi_const9 */
808 COSTS_N_INSNS (8), /* muldi */
809 COSTS_N_INSNS (22), /* divsi */
810 COSTS_N_INSNS (28), /* divdi */
811 COSTS_N_INSNS (3), /* fp */
812 COSTS_N_INSNS (3), /* dmul */
813 COSTS_N_INSNS (13), /* sdiv */
814 COSTS_N_INSNS (16), /* ddiv */
815 128, /* cache line size */
818 16, /* prefetch streams */
821 /* Instruction costs on POWER7 processors. */
823 struct processor_costs power7_cost = {
824 COSTS_N_INSNS (2), /* mulsi */
825 COSTS_N_INSNS (2), /* mulsi_const */
826 COSTS_N_INSNS (2), /* mulsi_const9 */
827 COSTS_N_INSNS (2), /* muldi */
828 COSTS_N_INSNS (18), /* divsi */
829 COSTS_N_INSNS (34), /* divdi */
830 COSTS_N_INSNS (3), /* fp */
831 COSTS_N_INSNS (3), /* dmul */
832 COSTS_N_INSNS (13), /* sdiv */
833 COSTS_N_INSNS (16), /* ddiv */
834 128, /* cache line size */
837 12, /* prefetch streams */
840 /* Instruction costs on POWER A2 processors. */
842 struct processor_costs ppca2_cost = {
843 COSTS_N_INSNS (16), /* mulsi */
844 COSTS_N_INSNS (16), /* mulsi_const */
845 COSTS_N_INSNS (16), /* mulsi_const9 */
846 COSTS_N_INSNS (16), /* muldi */
847 COSTS_N_INSNS (22), /* divsi */
848 COSTS_N_INSNS (28), /* divdi */
849 COSTS_N_INSNS (3), /* fp */
850 COSTS_N_INSNS (3), /* dmul */
851 COSTS_N_INSNS (59), /* sdiv */
852 COSTS_N_INSNS (72), /* ddiv */
856 16, /* prefetch streams */
860 /* Table that classifies rs6000 builtin functions (pure, const, etc.). */
861 #undef RS6000_BUILTIN
862 #undef RS6000_BUILTIN_EQUATE
863 #define RS6000_BUILTIN(NAME, TYPE) TYPE,
864 #define RS6000_BUILTIN_EQUATE(NAME, VALUE)
866 static const enum rs6000_btc builtin_classify[(int)RS6000_BUILTIN_COUNT] =
868 #include "rs6000-builtin.def"
871 #undef RS6000_BUILTIN
872 #undef RS6000_BUILTIN_EQUATE
875 static bool rs6000_function_ok_for_sibcall (tree, tree);
876 static const char *rs6000_invalid_within_doloop (const_rtx);
877 static bool rs6000_legitimate_address_p (enum machine_mode, rtx, bool);
878 static bool rs6000_debug_legitimate_address_p (enum machine_mode, rtx, bool);
879 static rtx rs6000_generate_compare (rtx, enum machine_mode);
880 static void rs6000_emit_stack_tie (void);
881 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
882 static bool spe_func_has_64bit_regs_p (void);
883 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
885 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
886 static unsigned rs6000_hash_constant (rtx);
887 static unsigned toc_hash_function (const void *);
888 static int toc_hash_eq (const void *, const void *);
889 static bool reg_offset_addressing_ok_p (enum machine_mode);
890 static bool virtual_stack_registers_memory_p (rtx);
891 static bool constant_pool_expr_p (rtx);
892 static bool legitimate_small_data_p (enum machine_mode, rtx);
893 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
894 static struct machine_function * rs6000_init_machine_status (void);
895 static bool rs6000_assemble_integer (rtx, unsigned int, int);
896 static bool no_global_regs_above (int, bool);
897 #ifdef HAVE_GAS_HIDDEN
898 static void rs6000_assemble_visibility (tree, int);
900 static int rs6000_ra_ever_killed (void);
901 static bool rs6000_attribute_takes_identifier_p (const_tree);
902 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
903 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
904 static bool rs6000_ms_bitfield_layout_p (const_tree);
905 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
906 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
907 static const char *rs6000_mangle_type (const_tree);
908 static void rs6000_set_default_type_attributes (tree);
909 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
910 static rtx rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
911 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
912 enum machine_mode, bool, bool, bool);
913 static bool rs6000_reg_live_or_pic_offset_p (int);
914 static tree rs6000_builtin_vectorized_function (tree, tree, tree);
915 static int rs6000_savres_strategy (rs6000_stack_t *, bool, int, int);
916 static void rs6000_restore_saved_cr (rtx, int);
917 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
918 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
919 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
921 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
922 static bool rs6000_return_in_memory (const_tree, const_tree);
923 static rtx rs6000_function_value (const_tree, const_tree, bool);
924 static void rs6000_file_start (void);
926 static int rs6000_elf_reloc_rw_mask (void);
927 static void rs6000_elf_asm_out_constructor (rtx, int);
928 static void rs6000_elf_asm_out_destructor (rtx, int);
929 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
930 static void rs6000_elf_asm_init_sections (void);
931 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
932 unsigned HOST_WIDE_INT);
933 static void rs6000_elf_encode_section_info (tree, rtx, int)
936 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
937 static void rs6000_alloc_sdmode_stack_slot (void);
938 static void rs6000_instantiate_decls (void);
940 static void rs6000_xcoff_asm_output_anchor (rtx);
941 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
942 static void rs6000_xcoff_asm_init_sections (void);
943 static int rs6000_xcoff_reloc_rw_mask (void);
944 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
945 static section *rs6000_xcoff_select_section (tree, int,
946 unsigned HOST_WIDE_INT);
947 static void rs6000_xcoff_unique_section (tree, int);
948 static section *rs6000_xcoff_select_rtx_section
949 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
950 static const char * rs6000_xcoff_strip_name_encoding (const char *);
951 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
952 static void rs6000_xcoff_file_start (void);
953 static void rs6000_xcoff_file_end (void);
955 static int rs6000_variable_issue (FILE *, int, rtx, int);
956 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
957 static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool);
958 static int rs6000_debug_address_cost (rtx, bool);
959 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
960 static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int);
961 static void rs6000_sched_init (FILE *, int, int);
962 static bool is_microcoded_insn (rtx);
963 static bool is_nonpipeline_insn (rtx);
964 static bool is_cracked_insn (rtx);
965 static bool is_branch_slot_insn (rtx);
966 static bool is_load_insn (rtx);
967 static rtx get_store_dest (rtx pat);
968 static bool is_store_insn (rtx);
969 static bool set_to_load_agen (rtx,rtx);
970 static bool adjacent_mem_locations (rtx,rtx);
971 static int rs6000_adjust_priority (rtx, int);
972 static int rs6000_issue_rate (void);
973 static bool rs6000_is_costly_dependence (dep_t, int, int);
974 static rtx get_next_active_insn (rtx, rtx);
975 static bool insn_terminates_group_p (rtx , enum group_termination);
976 static bool insn_must_be_first_in_group (rtx);
977 static bool insn_must_be_last_in_group (rtx);
978 static bool is_costly_group (rtx *, rtx);
979 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
980 static int redefine_groups (FILE *, int, rtx, rtx);
981 static int pad_groups (FILE *, int, rtx, rtx);
982 static void rs6000_sched_finish (FILE *, int);
983 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
984 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
985 static int rs6000_use_sched_lookahead (void);
986 static int rs6000_use_sched_lookahead_guard (rtx);
987 static void * rs6000_alloc_sched_context (void);
988 static void rs6000_init_sched_context (void *, bool);
989 static void rs6000_set_sched_context (void *);
990 static void rs6000_free_sched_context (void *);
991 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
992 static tree rs6000_builtin_mask_for_load (void);
993 static tree rs6000_builtin_mul_widen_even (tree);
994 static tree rs6000_builtin_mul_widen_odd (tree);
995 static tree rs6000_builtin_conversion (unsigned int, tree, tree);
996 static tree rs6000_builtin_vec_perm (tree, tree *);
997 static bool rs6000_builtin_support_vector_misalignment (enum
1002 static void def_builtin (int, const char *, tree, int);
1003 static bool rs6000_vector_alignment_reachable (const_tree, bool);
1004 static void rs6000_init_builtins (void);
1005 static tree rs6000_builtin_decl (unsigned, bool);
1007 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
1008 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
1009 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
1010 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1011 static void altivec_init_builtins (void);
1012 static unsigned builtin_hash_function (const void *);
1013 static int builtin_hash_eq (const void *, const void *);
1014 static tree builtin_function_type (enum machine_mode, enum machine_mode,
1015 enum machine_mode, enum machine_mode,
1016 enum rs6000_builtins, const char *name);
1017 static void rs6000_common_init_builtins (void);
1018 static void rs6000_init_libfuncs (void);
1020 static void paired_init_builtins (void);
1021 static rtx paired_expand_builtin (tree, rtx, bool *);
1022 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
1023 static rtx paired_expand_stv_builtin (enum insn_code, tree);
1024 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1026 static void enable_mask_for_builtins (struct builtin_description *, int,
1027 enum rs6000_builtins,
1028 enum rs6000_builtins);
1029 static void spe_init_builtins (void);
1030 static rtx spe_expand_builtin (tree, rtx, bool *);
1031 static rtx spe_expand_stv_builtin (enum insn_code, tree);
1032 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
1033 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
1034 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1035 static rs6000_stack_t *rs6000_stack_info (void);
1036 static void debug_stack_info (rs6000_stack_t *);
1038 static rtx altivec_expand_builtin (tree, rtx, bool *);
1039 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
1040 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
1041 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
1042 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
1043 static rtx altivec_expand_predicate_builtin (enum insn_code, tree, rtx);
1044 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
1045 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
1046 static rtx altivec_expand_vec_set_builtin (tree);
1047 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
1048 static int get_element_number (tree, tree);
1049 static bool rs6000_handle_option (size_t, const char *, int);
1050 static void rs6000_parse_tls_size_option (void);
1051 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
1052 static int first_altivec_reg_to_save (void);
1053 static unsigned int compute_vrsave_mask (void);
1054 static void compute_save_world_info (rs6000_stack_t *info_ptr);
1055 static void is_altivec_return_reg (rtx, void *);
1056 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
1057 int easy_vector_constant (rtx, enum machine_mode);
1058 static rtx rs6000_dwarf_register_span (rtx);
1059 static void rs6000_init_dwarf_reg_sizes_extra (tree);
1060 static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
1061 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
1062 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1063 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
1064 static rtx rs6000_delegitimize_address (rtx);
1065 static rtx rs6000_tls_get_addr (void);
1066 static rtx rs6000_got_sym (void);
1067 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
1068 static const char *rs6000_get_some_local_dynamic_name (void);
1069 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
1070 static rtx rs6000_complex_function_value (enum machine_mode);
1071 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
1072 enum machine_mode, tree);
1073 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
1075 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
1076 tree, HOST_WIDE_INT);
1077 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
1080 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
1081 const_tree, HOST_WIDE_INT,
1083 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
1084 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
1085 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
1086 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
1087 enum machine_mode, tree,
1089 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
1091 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
1093 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
1095 static void macho_branch_islands (void);
1096 static int no_previous_def (tree function_name);
1097 static tree get_prev_label (tree function_name);
1098 static void rs6000_darwin_file_start (void);
1101 static tree rs6000_build_builtin_va_list (void);
1102 static void rs6000_va_start (tree, rtx);
1103 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
1104 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
1105 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
1106 static bool rs6000_vector_mode_supported_p (enum machine_mode);
1107 static rtx rs6000_emit_vector_compare_inner (enum rtx_code, rtx, rtx);
1108 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
1110 static tree rs6000_stack_protect_fail (void);
1112 static rtx rs6000_legitimize_reload_address (rtx, enum machine_mode, int, int,
1115 static rtx rs6000_debug_legitimize_reload_address (rtx, enum machine_mode, int,
1118 rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode, int, int,
1120 = rs6000_legitimize_reload_address;
1122 static bool rs6000_mode_dependent_address (const_rtx);
1123 static bool rs6000_debug_mode_dependent_address (const_rtx);
1124 bool (*rs6000_mode_dependent_address_ptr) (const_rtx)
1125 = rs6000_mode_dependent_address;
1127 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1128 enum machine_mode, rtx);
1129 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1132 enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
1133 enum machine_mode, rtx)
1134 = rs6000_secondary_reload_class;
1136 static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class);
1137 static enum reg_class rs6000_debug_preferred_reload_class (rtx,
1139 enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class)
1140 = rs6000_preferred_reload_class;
1142 static bool rs6000_secondary_memory_needed (enum reg_class, enum reg_class,
1145 static bool rs6000_debug_secondary_memory_needed (enum reg_class,
1149 bool (*rs6000_secondary_memory_needed_ptr) (enum reg_class, enum reg_class,
1151 = rs6000_secondary_memory_needed;
1153 static bool rs6000_cannot_change_mode_class (enum machine_mode,
1156 static bool rs6000_debug_cannot_change_mode_class (enum machine_mode,
1160 bool (*rs6000_cannot_change_mode_class_ptr) (enum machine_mode,
1163 = rs6000_cannot_change_mode_class;
1165 static enum reg_class rs6000_secondary_reload (bool, rtx, enum reg_class,
1167 struct secondary_reload_info *);
1169 static const enum reg_class *rs6000_ira_cover_classes (void);
1171 const int INSN_NOT_AVAILABLE = -1;
1172 static enum machine_mode rs6000_eh_return_filter_mode (void);
1173 static bool rs6000_can_eliminate (const int, const int);
1174 static void rs6000_trampoline_init (rtx, tree, rtx);
1176 /* Hash table stuff for keeping track of TOC entries. */
1178 struct GTY(()) toc_hash_struct
1180 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
1181 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
1183 enum machine_mode key_mode;
1187 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
1189 /* Hash table to keep track of the argument types for builtin functions. */
1191 struct GTY(()) builtin_hash_struct
1194 enum machine_mode mode[4]; /* return value + 3 arguments. */
1195 unsigned char uns_p[4]; /* and whether the types are unsigned. */
1198 static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
1200 /* Default register names. */
1201 char rs6000_reg_names[][8] =
1203 "0", "1", "2", "3", "4", "5", "6", "7",
1204 "8", "9", "10", "11", "12", "13", "14", "15",
1205 "16", "17", "18", "19", "20", "21", "22", "23",
1206 "24", "25", "26", "27", "28", "29", "30", "31",
1207 "0", "1", "2", "3", "4", "5", "6", "7",
1208 "8", "9", "10", "11", "12", "13", "14", "15",
1209 "16", "17", "18", "19", "20", "21", "22", "23",
1210 "24", "25", "26", "27", "28", "29", "30", "31",
1211 "mq", "lr", "ctr","ap",
1212 "0", "1", "2", "3", "4", "5", "6", "7",
1214 /* AltiVec registers. */
1215 "0", "1", "2", "3", "4", "5", "6", "7",
1216 "8", "9", "10", "11", "12", "13", "14", "15",
1217 "16", "17", "18", "19", "20", "21", "22", "23",
1218 "24", "25", "26", "27", "28", "29", "30", "31",
1220 /* SPE registers. */
1221 "spe_acc", "spefscr",
1222 /* Soft frame pointer. */
1226 #ifdef TARGET_REGNAMES
1227 static const char alt_reg_names[][8] =
1229 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1230 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1231 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1232 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1233 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1234 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1235 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1236 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1237 "mq", "lr", "ctr", "ap",
1238 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1240 /* AltiVec registers. */
1241 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1242 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1243 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1244 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1246 /* SPE registers. */
1247 "spe_acc", "spefscr",
1248 /* Soft frame pointer. */
1253 /* Table of valid machine attributes. */
1255 static const struct attribute_spec rs6000_attribute_table[] =
1257 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1258 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute },
1259 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1260 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute },
1261 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1262 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute },
1263 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1264 SUBTARGET_ATTRIBUTE_TABLE,
1266 { NULL, 0, 0, false, false, false, NULL }
1269 #ifndef MASK_STRICT_ALIGN
1270 #define MASK_STRICT_ALIGN 0
1272 #ifndef TARGET_PROFILE_KERNEL
1273 #define TARGET_PROFILE_KERNEL 0
1276 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1277 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1279 /* Initialize the GCC target structure. */
1280 #undef TARGET_ATTRIBUTE_TABLE
1281 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1282 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1283 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1284 #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
1285 #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
1287 #undef TARGET_ASM_ALIGNED_DI_OP
1288 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1290 /* Default unaligned ops are only provided for ELF. Find the ops needed
1291 for non-ELF systems. */
1292 #ifndef OBJECT_FORMAT_ELF
1294 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1296 #undef TARGET_ASM_UNALIGNED_HI_OP
1297 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1298 #undef TARGET_ASM_UNALIGNED_SI_OP
1299 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1300 #undef TARGET_ASM_UNALIGNED_DI_OP
1301 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1304 #undef TARGET_ASM_UNALIGNED_HI_OP
1305 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1306 #undef TARGET_ASM_UNALIGNED_SI_OP
1307 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1308 #undef TARGET_ASM_UNALIGNED_DI_OP
1309 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1310 #undef TARGET_ASM_ALIGNED_DI_OP
1311 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1315 /* This hook deals with fixups for relocatable code and DI-mode objects
1317 #undef TARGET_ASM_INTEGER
1318 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1320 #ifdef HAVE_GAS_HIDDEN
1321 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1322 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1325 #undef TARGET_HAVE_TLS
1326 #define TARGET_HAVE_TLS HAVE_AS_TLS
1328 #undef TARGET_CANNOT_FORCE_CONST_MEM
1329 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1331 #undef TARGET_DELEGITIMIZE_ADDRESS
1332 #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
1334 #undef TARGET_ASM_FUNCTION_PROLOGUE
1335 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1336 #undef TARGET_ASM_FUNCTION_EPILOGUE
1337 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1339 #undef TARGET_LEGITIMIZE_ADDRESS
1340 #define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address
1342 #undef TARGET_SCHED_VARIABLE_ISSUE
1343 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1345 #undef TARGET_SCHED_ISSUE_RATE
1346 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1347 #undef TARGET_SCHED_ADJUST_COST
1348 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1349 #undef TARGET_SCHED_ADJUST_PRIORITY
1350 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1351 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1352 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1353 #undef TARGET_SCHED_INIT
1354 #define TARGET_SCHED_INIT rs6000_sched_init
1355 #undef TARGET_SCHED_FINISH
1356 #define TARGET_SCHED_FINISH rs6000_sched_finish
1357 #undef TARGET_SCHED_REORDER
1358 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1359 #undef TARGET_SCHED_REORDER2
1360 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1362 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1363 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1365 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1366 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1368 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1369 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1370 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1371 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1372 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1373 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1374 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1375 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1377 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1378 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1379 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1380 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1381 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1382 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1383 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1384 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1385 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1386 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1387 #undef TARGET_SUPPORT_VECTOR_MISALIGNMENT
1388 #define TARGET_SUPPORT_VECTOR_MISALIGNMENT \
1389 rs6000_builtin_support_vector_misalignment
1390 #undef TARGET_VECTOR_ALIGNMENT_REACHABLE
1391 #define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1393 #undef TARGET_INIT_BUILTINS
1394 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1395 #undef TARGET_BUILTIN_DECL
1396 #define TARGET_BUILTIN_DECL rs6000_builtin_decl
1398 #undef TARGET_EXPAND_BUILTIN
1399 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1401 #undef TARGET_MANGLE_TYPE
1402 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1404 #undef TARGET_INIT_LIBFUNCS
1405 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1408 #undef TARGET_BINDS_LOCAL_P
1409 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1412 #undef TARGET_MS_BITFIELD_LAYOUT_P
1413 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1415 #undef TARGET_ASM_OUTPUT_MI_THUNK
1416 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1418 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1419 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1421 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1422 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1424 #undef TARGET_INVALID_WITHIN_DOLOOP
1425 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1427 #undef TARGET_RTX_COSTS
1428 #define TARGET_RTX_COSTS rs6000_rtx_costs
1429 #undef TARGET_ADDRESS_COST
1430 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1432 #undef TARGET_DWARF_REGISTER_SPAN
1433 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1435 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1436 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1438 /* On rs6000, function arguments are promoted, as are function return
1440 #undef TARGET_PROMOTE_FUNCTION_MODE
1441 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
1443 #undef TARGET_RETURN_IN_MEMORY
1444 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1446 #undef TARGET_SETUP_INCOMING_VARARGS
1447 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1449 /* Always strict argument naming on rs6000. */
1450 #undef TARGET_STRICT_ARGUMENT_NAMING
1451 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1452 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1453 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1454 #undef TARGET_SPLIT_COMPLEX_ARG
1455 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1456 #undef TARGET_MUST_PASS_IN_STACK
1457 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1458 #undef TARGET_PASS_BY_REFERENCE
1459 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1460 #undef TARGET_ARG_PARTIAL_BYTES
1461 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1463 #undef TARGET_BUILD_BUILTIN_VA_LIST
1464 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1466 #undef TARGET_EXPAND_BUILTIN_VA_START
1467 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1469 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1470 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1472 #undef TARGET_EH_RETURN_FILTER_MODE
1473 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1475 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1476 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1478 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1479 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1481 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1482 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1484 #undef TARGET_HANDLE_OPTION
1485 #define TARGET_HANDLE_OPTION rs6000_handle_option
1487 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
1488 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \
1489 rs6000_builtin_vectorized_function
1491 #undef TARGET_DEFAULT_TARGET_FLAGS
1492 #define TARGET_DEFAULT_TARGET_FLAGS \
1495 #undef TARGET_STACK_PROTECT_FAIL
1496 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1498 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1499 The PowerPC architecture requires only weak consistency among
1500 processors--that is, memory accesses between processors need not be
1501 sequentially consistent and memory accesses among processors can occur
1502 in any order. The ability to order memory accesses weakly provides
1503 opportunities for more efficient use of the system bus. Unless a
1504 dependency exists, the 604e allows read operations to precede store
1506 #undef TARGET_RELAXED_ORDERING
1507 #define TARGET_RELAXED_ORDERING true
1510 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1511 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1514 /* Use a 32-bit anchor range. This leads to sequences like:
1516 addis tmp,anchor,high
1519 where tmp itself acts as an anchor, and can be shared between
1520 accesses to the same 64k page. */
1521 #undef TARGET_MIN_ANCHOR_OFFSET
1522 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1523 #undef TARGET_MAX_ANCHOR_OFFSET
1524 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1525 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1526 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1528 #undef TARGET_BUILTIN_RECIPROCAL
1529 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1531 #undef TARGET_EXPAND_TO_RTL_HOOK
1532 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1534 #undef TARGET_INSTANTIATE_DECLS
1535 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1537 #undef TARGET_SECONDARY_RELOAD
1538 #define TARGET_SECONDARY_RELOAD rs6000_secondary_reload
1540 #undef TARGET_IRA_COVER_CLASSES
1541 #define TARGET_IRA_COVER_CLASSES rs6000_ira_cover_classes
1543 #undef TARGET_LEGITIMATE_ADDRESS_P
1544 #define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p
1546 #undef TARGET_CAN_ELIMINATE
1547 #define TARGET_CAN_ELIMINATE rs6000_can_eliminate
1549 #undef TARGET_TRAMPOLINE_INIT
1550 #define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init
1552 #undef TARGET_FUNCTION_VALUE
1553 #define TARGET_FUNCTION_VALUE rs6000_function_value
1555 struct gcc_target targetm = TARGET_INITIALIZER;
1557 /* Return number of consecutive hard regs needed starting at reg REGNO
1558 to hold something of mode MODE.
1559 This is ordinarily the length in words of a value of mode MODE
1560 but can be less for certain modes in special long registers.
1562 For the SPE, GPRs are 64 bits but only 32 bits are visible in
1563 scalar instructions. The upper 32 bits are only available to the
1566 POWER and PowerPC GPRs hold 32 bits worth;
1567 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
1570 rs6000_hard_regno_nregs_internal (int regno, enum machine_mode mode)
1572 unsigned HOST_WIDE_INT reg_size;
1574 if (FP_REGNO_P (regno))
1575 reg_size = (VECTOR_MEM_VSX_P (mode)
1576 ? UNITS_PER_VSX_WORD
1577 : UNITS_PER_FP_WORD);
1579 else if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1580 reg_size = UNITS_PER_SPE_WORD;
1582 else if (ALTIVEC_REGNO_P (regno))
1583 reg_size = UNITS_PER_ALTIVEC_WORD;
1585 /* The value returned for SCmode in the E500 double case is 2 for
1586 ABI compatibility; storing an SCmode value in a single register
1587 would require function_arg and rs6000_spe_function_arg to handle
1588 SCmode so as to pass the value correctly in a pair of
1590 else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
1591 && !DECIMAL_FLOAT_MODE_P (mode))
1592 reg_size = UNITS_PER_FP_WORD;
1595 reg_size = UNITS_PER_WORD;
1597 return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size;
1600 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1603 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1605 int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
1607 /* VSX registers that overlap the FPR registers are larger than for non-VSX
1608 implementations. Don't allow an item to be split between a FP register
1609 and an Altivec register. */
1610 if (VECTOR_MEM_VSX_P (mode))
1612 if (FP_REGNO_P (regno))
1613 return FP_REGNO_P (last_regno);
1615 if (ALTIVEC_REGNO_P (regno))
1616 return ALTIVEC_REGNO_P (last_regno);
1619 /* The GPRs can hold any mode, but values bigger than one register
1620 cannot go past R31. */
1621 if (INT_REGNO_P (regno))
1622 return INT_REGNO_P (last_regno);
1624 /* The float registers (except for VSX vector modes) can only hold floating
1625 modes and DImode. This excludes the 32-bit decimal float mode for
1627 if (FP_REGNO_P (regno))
1629 if (SCALAR_FLOAT_MODE_P (mode)
1630 && (mode != TDmode || (regno % 2) == 0)
1631 && FP_REGNO_P (last_regno))
1634 if (GET_MODE_CLASS (mode) == MODE_INT
1635 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1638 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1639 && PAIRED_VECTOR_MODE (mode))
1645 /* The CR register can only hold CC modes. */
1646 if (CR_REGNO_P (regno))
1647 return GET_MODE_CLASS (mode) == MODE_CC;
1649 if (XER_REGNO_P (regno))
1650 return mode == PSImode;
1652 /* AltiVec only in AldyVec registers. */
1653 if (ALTIVEC_REGNO_P (regno))
1654 return VECTOR_MEM_ALTIVEC_OR_VSX_P (mode);
1656 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1657 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1660 /* We cannot put TImode anywhere except general register and it must be able
1661 to fit within the register set. In the future, allow TImode in the
1662 Altivec or VSX registers. */
1664 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1667 /* Print interesting facts about registers. */
1669 rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name)
1673 for (r = first_regno; r <= last_regno; ++r)
1675 const char *comma = "";
1678 if (first_regno == last_regno)
1679 fprintf (stderr, "%s:\t", reg_name);
1681 fprintf (stderr, "%s%d:\t", reg_name, r - first_regno);
1684 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1685 if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r])
1689 fprintf (stderr, ",\n\t");
1694 if (rs6000_hard_regno_nregs[m][r] > 1)
1695 len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m),
1696 rs6000_hard_regno_nregs[m][r]);
1698 len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m));
1703 if (call_used_regs[r])
1707 fprintf (stderr, ",\n\t");
1712 len += fprintf (stderr, "%s%s", comma, "call-used");
1720 fprintf (stderr, ",\n\t");
1725 len += fprintf (stderr, "%s%s", comma, "fixed");
1731 fprintf (stderr, ",\n\t");
1735 fprintf (stderr, "%sregno = %d\n", comma, r);
1739 /* Print various interesting information with -mdebug=reg. */
1741 rs6000_debug_reg_global (void)
1743 const char *nl = (const char *)0;
1745 char costly_num[20];
1747 const char *costly_str;
1748 const char *nop_str;
1750 /* Map enum rs6000_vector to string. */
1751 static const char *rs6000_debug_vector_unit[] = {
1760 fprintf (stderr, "Register information: (last virtual reg = %d)\n",
1761 LAST_VIRTUAL_REGISTER);
1762 rs6000_debug_reg_print (0, 31, "gr");
1763 rs6000_debug_reg_print (32, 63, "fp");
1764 rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
1767 rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr");
1768 rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr");
1769 rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr");
1770 rs6000_debug_reg_print (MQ_REGNO, MQ_REGNO, "mq");
1771 rs6000_debug_reg_print (XER_REGNO, XER_REGNO, "xer");
1772 rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave");
1773 rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr");
1774 rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
1775 rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
1779 "d reg_class = %s\n"
1780 "f reg_class = %s\n"
1781 "v reg_class = %s\n"
1782 "wa reg_class = %s\n"
1783 "wd reg_class = %s\n"
1784 "wf reg_class = %s\n"
1785 "ws reg_class = %s\n\n",
1786 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
1787 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
1788 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
1789 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
1790 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
1791 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
1792 reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
1794 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1795 if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
1798 fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
1800 rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
1801 rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
1807 switch (rs6000_sched_costly_dep)
1809 case max_dep_latency:
1810 costly_str = "max_dep_latency";
1814 costly_str = "no_dep_costly";
1817 case all_deps_costly:
1818 costly_str = "all_deps_costly";
1821 case true_store_to_load_dep_costly:
1822 costly_str = "true_store_to_load_dep_costly";
1825 case store_to_load_dep_costly:
1826 costly_str = "store_to_load_dep_costly";
1830 costly_str = costly_num;
1831 sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep);
1835 switch (rs6000_sched_insert_nops)
1837 case sched_finish_regroup_exact:
1838 nop_str = "sched_finish_regroup_exact";
1841 case sched_finish_pad_groups:
1842 nop_str = "sched_finish_pad_groups";
1845 case sched_finish_none:
1846 nop_str = "sched_finish_none";
1851 sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops);
1856 "always_hint = %s\n"
1857 "align_branch_targets = %s\n"
1858 "sched_restricted_insns_priority = %d\n"
1859 "sched_costly_dep = %s\n"
1860 "sched_insert_nops = %s\n\n",
1861 rs6000_always_hint ? "true" : "false",
1862 rs6000_align_branch_targets ? "true" : "false",
1863 (int)rs6000_sched_restricted_insns_priority,
1864 costly_str, nop_str);
1867 /* Initialize the various global tables that are based on register size. */
1869 rs6000_init_hard_regno_mode_ok (void)
1875 /* Precalculate REGNO_REG_CLASS. */
1876 rs6000_regno_regclass[0] = GENERAL_REGS;
1877 for (r = 1; r < 32; ++r)
1878 rs6000_regno_regclass[r] = BASE_REGS;
1880 for (r = 32; r < 64; ++r)
1881 rs6000_regno_regclass[r] = FLOAT_REGS;
1883 for (r = 64; r < FIRST_PSEUDO_REGISTER; ++r)
1884 rs6000_regno_regclass[r] = NO_REGS;
1886 for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r)
1887 rs6000_regno_regclass[r] = ALTIVEC_REGS;
1889 rs6000_regno_regclass[CR0_REGNO] = CR0_REGS;
1890 for (r = CR1_REGNO; r <= CR7_REGNO; ++r)
1891 rs6000_regno_regclass[r] = CR_REGS;
1893 rs6000_regno_regclass[MQ_REGNO] = MQ_REGS;
1894 rs6000_regno_regclass[LR_REGNO] = LINK_REGS;
1895 rs6000_regno_regclass[CTR_REGNO] = CTR_REGS;
1896 rs6000_regno_regclass[XER_REGNO] = XER_REGS;
1897 rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS;
1898 rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
1899 rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
1900 rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
1901 rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
1902 rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
1904 /* Precalculate vector information, this must be set up before the
1905 rs6000_hard_regno_nregs_internal below. */
1906 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1908 rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
1909 rs6000_vector_reload[m][0] = CODE_FOR_nothing;
1910 rs6000_vector_reload[m][1] = CODE_FOR_nothing;
1913 for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
1914 rs6000_constraints[c] = NO_REGS;
1916 /* The VSX hardware allows native alignment for vectors, but control whether the compiler
1917 believes it can use native alignment or still uses 128-bit alignment. */
1918 if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
1929 /* V2DF mode, VSX only. */
1932 rs6000_vector_unit[V2DFmode] = VECTOR_VSX;
1933 rs6000_vector_mem[V2DFmode] = VECTOR_VSX;
1934 rs6000_vector_align[V2DFmode] = align64;
1937 /* V4SF mode, either VSX or Altivec. */
1940 rs6000_vector_unit[V4SFmode] = VECTOR_VSX;
1941 rs6000_vector_mem[V4SFmode] = VECTOR_VSX;
1942 rs6000_vector_align[V4SFmode] = align32;
1944 else if (TARGET_ALTIVEC)
1946 rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC;
1947 rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC;
1948 rs6000_vector_align[V4SFmode] = align32;
1951 /* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads
1955 rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC;
1956 rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC;
1957 rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC;
1958 rs6000_vector_align[V4SImode] = align32;
1959 rs6000_vector_align[V8HImode] = align32;
1960 rs6000_vector_align[V16QImode] = align32;
1964 rs6000_vector_mem[V4SImode] = VECTOR_VSX;
1965 rs6000_vector_mem[V8HImode] = VECTOR_VSX;
1966 rs6000_vector_mem[V16QImode] = VECTOR_VSX;
1970 rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC;
1971 rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC;
1972 rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC;
1976 /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
1977 Altivec doesn't have 64-bit support. */
1980 rs6000_vector_mem[V2DImode] = VECTOR_VSX;
1981 rs6000_vector_unit[V2DImode] = VECTOR_NONE;
1982 rs6000_vector_align[V2DImode] = align64;
1985 /* DFmode, see if we want to use the VSX unit. */
1986 if (TARGET_VSX && TARGET_VSX_SCALAR_DOUBLE)
1988 rs6000_vector_unit[DFmode] = VECTOR_VSX;
1989 rs6000_vector_mem[DFmode]
1990 = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
1991 rs6000_vector_align[DFmode] = align64;
1994 /* TODO add SPE and paired floating point vector support. */
1996 /* Register class constaints for the constraints that depend on compile
1998 if (TARGET_HARD_FLOAT && TARGET_FPRS)
1999 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
2001 if (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
2002 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS;
2006 /* At present, we just use VSX_REGS, but we have different constraints
2007 based on the use, in case we want to fine tune the default register
2008 class used. wa = any VSX register, wf = register class to use for
2009 V4SF, wd = register class to use for V2DF, and ws = register classs to
2010 use for DF scalars. */
2011 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
2012 rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
2013 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
2014 if (TARGET_VSX_SCALAR_DOUBLE)
2015 rs6000_constraints[RS6000_CONSTRAINT_ws] = VSX_REGS;
2019 rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
2021 /* Set up the reload helper functions. */
2022 if (TARGET_VSX || TARGET_ALTIVEC)
2026 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
2027 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
2028 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_di_store;
2029 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_di_load;
2030 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_di_store;
2031 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_di_load;
2032 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_di_store;
2033 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_di_load;
2034 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_di_store;
2035 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_di_load;
2036 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_di_store;
2037 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_di_load;
2041 rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
2042 rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
2043 rs6000_vector_reload[V8HImode][0] = CODE_FOR_reload_v8hi_si_store;
2044 rs6000_vector_reload[V8HImode][1] = CODE_FOR_reload_v8hi_si_load;
2045 rs6000_vector_reload[V4SImode][0] = CODE_FOR_reload_v4si_si_store;
2046 rs6000_vector_reload[V4SImode][1] = CODE_FOR_reload_v4si_si_load;
2047 rs6000_vector_reload[V2DImode][0] = CODE_FOR_reload_v2di_si_store;
2048 rs6000_vector_reload[V2DImode][1] = CODE_FOR_reload_v2di_si_load;
2049 rs6000_vector_reload[V4SFmode][0] = CODE_FOR_reload_v4sf_si_store;
2050 rs6000_vector_reload[V4SFmode][1] = CODE_FOR_reload_v4sf_si_load;
2051 rs6000_vector_reload[V2DFmode][0] = CODE_FOR_reload_v2df_si_store;
2052 rs6000_vector_reload[V2DFmode][1] = CODE_FOR_reload_v2df_si_load;
2056 /* Precalculate HARD_REGNO_NREGS. */
2057 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2058 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2059 rs6000_hard_regno_nregs[m][r]
2060 = rs6000_hard_regno_nregs_internal (r, (enum machine_mode)m);
2062 /* Precalculate HARD_REGNO_MODE_OK. */
2063 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
2064 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2065 if (rs6000_hard_regno_mode_ok (r, (enum machine_mode)m))
2066 rs6000_hard_regno_mode_ok_p[m][r] = true;
2068 /* Precalculate CLASS_MAX_NREGS sizes. */
2069 for (c = 0; c < LIM_REG_CLASSES; ++c)
2073 if (TARGET_VSX && VSX_REG_CLASS_P (c))
2074 reg_size = UNITS_PER_VSX_WORD;
2076 else if (c == ALTIVEC_REGS)
2077 reg_size = UNITS_PER_ALTIVEC_WORD;
2079 else if (c == FLOAT_REGS)
2080 reg_size = UNITS_PER_FP_WORD;
2083 reg_size = UNITS_PER_WORD;
2085 for (m = 0; m < NUM_MACHINE_MODES; ++m)
2086 rs6000_class_max_nregs[m][c]
2087 = (GET_MODE_SIZE (m) + reg_size - 1) / reg_size;
2090 if (TARGET_E500_DOUBLE)
2091 rs6000_class_max_nregs[DFmode][GENERAL_REGS] = 1;
2093 if (TARGET_DEBUG_REG)
2094 rs6000_debug_reg_global ();
2098 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
2101 darwin_rs6000_override_options (void)
2103 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
2105 rs6000_altivec_abi = 1;
2106 TARGET_ALTIVEC_VRSAVE = 1;
2107 if (DEFAULT_ABI == ABI_DARWIN)
2109 if (MACHO_DYNAMIC_NO_PIC_P)
2112 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
2115 else if (flag_pic == 1)
2120 if (TARGET_64BIT && ! TARGET_POWERPC64)
2122 target_flags |= MASK_POWERPC64;
2123 warning (0, "-m64 requires PowerPC64 architecture, enabling");
2127 rs6000_default_long_calls = 1;
2128 target_flags |= MASK_SOFT_FLOAT;
2131 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
2133 if (!flag_mkernel && !flag_apple_kext
2135 && ! (target_flags_explicit & MASK_ALTIVEC))
2136 target_flags |= MASK_ALTIVEC;
2138 /* Unless the user (not the configurer) has explicitly overridden
2139 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
2140 G4 unless targetting the kernel. */
2143 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
2144 && ! (target_flags_explicit & MASK_ALTIVEC)
2145 && ! rs6000_select[1].string)
2147 target_flags |= MASK_ALTIVEC;
2152 /* If not otherwise specified by a target, make 'long double' equivalent to
2155 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
2156 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
2159 /* Override command line options. Mostly we process the processor
2160 type and sometimes adjust other TARGET_ options. */
2163 rs6000_override_options (const char *default_cpu)
2166 struct rs6000_cpu_select *ptr;
2169 /* Simplifications for entries below. */
2172 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
2173 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
2176 /* This table occasionally claims that a processor does not support
2177 a particular feature even though it does, but the feature is slower
2178 than the alternative. Thus, it shouldn't be relied on as a
2179 complete description of the processor's support.
2181 Please keep this list in order, and don't forget to update the
2182 documentation in invoke.texi when adding a new processor or
2186 const char *const name; /* Canonical processor name. */
2187 const enum processor_type processor; /* Processor type enum value. */
2188 const int target_enable; /* Target flags to enable. */
2189 } const processor_target_table[]
2190 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2191 {"403", PROCESSOR_PPC403,
2192 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
2193 {"405", PROCESSOR_PPC405,
2194 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2195 {"405fp", PROCESSOR_PPC405,
2196 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2197 {"440", PROCESSOR_PPC440,
2198 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2199 {"440fp", PROCESSOR_PPC440,
2200 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2201 {"464", PROCESSOR_PPC440,
2202 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
2203 {"464fp", PROCESSOR_PPC440,
2204 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
2205 {"476", PROCESSOR_PPC476,
2206 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_PPC_GFXOPT | MASK_MFCRF
2207 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2208 {"476fp", PROCESSOR_PPC476,
2209 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB
2210 | MASK_FPRND | MASK_CMPB | MASK_MULHW | MASK_DLMZB},
2211 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
2212 {"601", PROCESSOR_PPC601,
2213 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
2214 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2215 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2216 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2217 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2218 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2219 {"620", PROCESSOR_PPC620,
2220 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2221 {"630", PROCESSOR_PPC630,
2222 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2223 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2224 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
2225 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2226 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2227 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2228 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2229 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2230 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2232 /* 8548 has a dummy entry for now. */
2233 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN
2235 {"a2", PROCESSOR_PPCA2,
2236 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_POPCNTB
2237 | MASK_CMPB | MASK_NO_UPDATE },
2238 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2239 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
2240 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT
2242 {"e500mc64", PROCESSOR_PPCE500MC64, POWERPC_BASE_MASK | MASK_POWERPC64
2243 | MASK_PPC_GFXOPT | MASK_ISEL},
2244 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2245 {"970", PROCESSOR_POWER4,
2246 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2247 {"cell", PROCESSOR_CELL,
2248 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2249 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
2250 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
2251 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
2252 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
2253 {"G5", PROCESSOR_POWER4,
2254 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
2255 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2256 {"power2", PROCESSOR_POWER,
2257 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2258 {"power3", PROCESSOR_PPC630,
2259 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2260 {"power4", PROCESSOR_POWER4,
2261 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2263 {"power5", PROCESSOR_POWER5,
2264 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2265 | MASK_MFCRF | MASK_POPCNTB},
2266 {"power5+", PROCESSOR_POWER5,
2267 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2268 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
2269 {"power6", PROCESSOR_POWER6,
2270 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2271 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP},
2272 {"power6x", PROCESSOR_POWER6,
2273 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
2274 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
2276 {"power7", PROCESSOR_POWER7,
2277 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
2278 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
2279 | MASK_VSX}, /* Don't add MASK_ISEL by default */
2280 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
2281 {"powerpc64", PROCESSOR_POWERPC64,
2282 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
2283 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2284 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2285 {"rios2", PROCESSOR_RIOS2,
2286 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
2287 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2288 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
2289 {"rs64", PROCESSOR_RS64A,
2290 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
2293 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
2295 /* Some OSs don't support saving the high part of 64-bit registers on
2296 context switch. Other OSs don't support saving Altivec registers.
2297 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
2298 settings; if the user wants either, the user must explicitly specify
2299 them and we won't interfere with the user's specification. */
2302 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
2303 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
2304 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
2305 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
2306 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP
2307 | MASK_POPCNTD | MASK_VSX | MASK_ISEL | MASK_NO_UPDATE)
2310 /* Numerous experiment shows that IRA based loop pressure
2311 calculation works better for RTL loop invariant motion on targets
2312 with enough (>= 32) registers. It is an expensive optimization.
2313 So it is on only for peak performance. */
2315 flag_ira_loop_pressure = 1;
2317 /* Set the pointer size. */
2320 rs6000_pmode = (int)DImode;
2321 rs6000_pointer_size = 64;
2325 rs6000_pmode = (int)SImode;
2326 rs6000_pointer_size = 32;
2329 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
2330 #ifdef OS_MISSING_POWERPC64
2331 if (OS_MISSING_POWERPC64)
2332 set_masks &= ~MASK_POWERPC64;
2334 #ifdef OS_MISSING_ALTIVEC
2335 if (OS_MISSING_ALTIVEC)
2336 set_masks &= ~MASK_ALTIVEC;
2339 /* Don't override by the processor default if given explicitly. */
2340 set_masks &= ~target_flags_explicit;
2342 /* Identify the processor type. */
2343 rs6000_select[0].string = default_cpu;
2344 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
2346 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2348 ptr = &rs6000_select[i];
2349 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2351 for (j = 0; j < ptt_size; j++)
2352 if (! strcmp (ptr->string, processor_target_table[j].name))
2354 if (ptr->set_tune_p)
2355 rs6000_cpu = processor_target_table[j].processor;
2357 if (ptr->set_arch_p)
2359 target_flags &= ~set_masks;
2360 target_flags |= (processor_target_table[j].target_enable
2367 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
2371 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
2372 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64)
2375 error ("AltiVec not supported in this target");
2377 error ("Spe not supported in this target");
2380 /* Disable Cell microcode if we are optimizing for the Cell
2381 and not optimizing for size. */
2382 if (rs6000_gen_cell_microcode == -1)
2383 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
2386 /* If we are optimizing big endian systems for space and it's OK to
2387 use instructions that would be microcoded on the Cell, use the
2388 load/store multiple and string instructions. */
2389 if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode)
2390 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
2392 /* Don't allow -mmultiple or -mstring on little endian systems
2393 unless the cpu is a 750, because the hardware doesn't support the
2394 instructions used in little endian mode, and causes an alignment
2395 trap. The 750 does not cause an alignment trap (except when the
2396 target is unaligned). */
2398 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
2400 if (TARGET_MULTIPLE)
2402 target_flags &= ~MASK_MULTIPLE;
2403 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
2404 warning (0, "-mmultiple is not supported on little endian systems");
2409 target_flags &= ~MASK_STRING;
2410 if ((target_flags_explicit & MASK_STRING) != 0)
2411 warning (0, "-mstring is not supported on little endian systems");
2415 /* Add some warnings for VSX. */
2418 const char *msg = NULL;
2419 if (!TARGET_HARD_FLOAT || !TARGET_FPRS
2420 || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
2422 if (target_flags_explicit & MASK_VSX)
2423 msg = N_("-mvsx requires hardware floating point");
2425 target_flags &= ~ MASK_VSX;
2427 else if (TARGET_PAIRED_FLOAT)
2428 msg = N_("-mvsx and -mpaired are incompatible");
2429 /* The hardware will allow VSX and little endian, but until we make sure
2430 things like vector select, etc. work don't allow VSX on little endian
2431 systems at this point. */
2432 else if (!BYTES_BIG_ENDIAN)
2433 msg = N_("-mvsx used with little endian code");
2434 else if (TARGET_AVOID_XFORM > 0)
2435 msg = N_("-mvsx needs indexed addressing");
2436 else if (!TARGET_ALTIVEC && (target_flags_explicit & MASK_ALTIVEC))
2438 if (target_flags_explicit & MASK_VSX)
2439 msg = N_("-mvsx and -mno-altivec are incompatible");
2441 msg = N_("-mno-altivec disables vsx");
2447 target_flags &= ~ MASK_VSX;
2449 else if (TARGET_VSX && !TARGET_ALTIVEC)
2450 target_flags |= MASK_ALTIVEC;
2453 /* Set debug flags */
2454 if (rs6000_debug_name)
2456 if (! strcmp (rs6000_debug_name, "all"))
2457 rs6000_debug_stack = rs6000_debug_arg = rs6000_debug_reg
2458 = rs6000_debug_addr = rs6000_debug_cost = 1;
2459 else if (! strcmp (rs6000_debug_name, "stack"))
2460 rs6000_debug_stack = 1;
2461 else if (! strcmp (rs6000_debug_name, "arg"))
2462 rs6000_debug_arg = 1;
2463 else if (! strcmp (rs6000_debug_name, "reg"))
2464 rs6000_debug_reg = 1;
2465 else if (! strcmp (rs6000_debug_name, "addr"))
2466 rs6000_debug_addr = 1;
2467 else if (! strcmp (rs6000_debug_name, "cost"))
2468 rs6000_debug_cost = 1;
2470 error ("unknown -mdebug-%s switch", rs6000_debug_name);
2472 /* If the appropriate debug option is enabled, replace the target hooks
2473 with debug versions that call the real version and then prints
2474 debugging information. */
2475 if (TARGET_DEBUG_COST)
2477 targetm.rtx_costs = rs6000_debug_rtx_costs;
2478 targetm.address_cost = rs6000_debug_address_cost;
2479 targetm.sched.adjust_cost = rs6000_debug_adjust_cost;
2482 if (TARGET_DEBUG_ADDR)
2484 targetm.legitimate_address_p = rs6000_debug_legitimate_address_p;
2485 targetm.legitimize_address = rs6000_debug_legitimize_address;
2486 rs6000_secondary_reload_class_ptr
2487 = rs6000_debug_secondary_reload_class;
2488 rs6000_secondary_memory_needed_ptr
2489 = rs6000_debug_secondary_memory_needed;
2490 rs6000_cannot_change_mode_class_ptr
2491 = rs6000_debug_cannot_change_mode_class;
2492 rs6000_preferred_reload_class_ptr
2493 = rs6000_debug_preferred_reload_class;
2494 rs6000_legitimize_reload_address_ptr
2495 = rs6000_debug_legitimize_reload_address;
2496 rs6000_mode_dependent_address_ptr
2497 = rs6000_debug_mode_dependent_address;
2501 if (rs6000_traceback_name)
2503 if (! strncmp (rs6000_traceback_name, "full", 4))
2504 rs6000_traceback = traceback_full;
2505 else if (! strncmp (rs6000_traceback_name, "part", 4))
2506 rs6000_traceback = traceback_part;
2507 else if (! strncmp (rs6000_traceback_name, "no", 2))
2508 rs6000_traceback = traceback_none;
2510 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
2511 rs6000_traceback_name);
2514 if (!rs6000_explicit_options.long_double)
2515 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2517 #ifndef POWERPC_LINUX
2518 if (!rs6000_explicit_options.ieee)
2519 rs6000_ieeequad = 1;
2522 /* Enable Altivec ABI for AIX -maltivec. */
2523 if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX))
2524 rs6000_altivec_abi = 1;
2526 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
2527 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
2528 be explicitly overridden in either case. */
2531 if (!rs6000_explicit_options.altivec_abi
2532 && (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX))
2533 rs6000_altivec_abi = 1;
2535 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
2536 if (!rs6000_explicit_options.vrsave)
2537 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
2540 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
2541 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2543 rs6000_darwin64_abi = 1;
2545 darwin_one_byte_bool = 1;
2547 /* Default to natural alignment, for better performance. */
2548 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2551 /* Place FP constants in the constant pool instead of TOC
2552 if section anchors enabled. */
2553 if (flag_section_anchors)
2554 TARGET_NO_FP_IN_TOC = 1;
2556 /* Handle -mtls-size option. */
2557 rs6000_parse_tls_size_option ();
2559 #ifdef SUBTARGET_OVERRIDE_OPTIONS
2560 SUBTARGET_OVERRIDE_OPTIONS;
2562 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2563 SUBSUBTARGET_OVERRIDE_OPTIONS;
2565 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
2566 SUB3TARGET_OVERRIDE_OPTIONS;
2569 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC
2570 || rs6000_cpu == PROCESSOR_PPCE500MC64)
2572 /* The e500 and e500mc do not have string instructions, and we set
2573 MASK_STRING above when optimizing for size. */
2574 if ((target_flags & MASK_STRING) != 0)
2575 target_flags = target_flags & ~MASK_STRING;
2577 else if (rs6000_select[1].string != NULL)
2579 /* For the powerpc-eabispe configuration, we set all these by
2580 default, so let's unset them if we manually set another
2581 CPU that is not the E500. */
2582 if (!rs6000_explicit_options.spe_abi)
2584 if (!rs6000_explicit_options.spe)
2586 if (!rs6000_explicit_options.float_gprs)
2587 rs6000_float_gprs = 0;
2588 if (!(target_flags_explicit & MASK_ISEL))
2589 target_flags &= ~MASK_ISEL;
2592 /* Detect invalid option combinations with E500. */
2595 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
2596 && rs6000_cpu != PROCESSOR_POWER5
2597 && rs6000_cpu != PROCESSOR_POWER6
2598 && rs6000_cpu != PROCESSOR_POWER7
2599 && rs6000_cpu != PROCESSOR_PPCA2
2600 && rs6000_cpu != PROCESSOR_CELL);
2601 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
2602 || rs6000_cpu == PROCESSOR_POWER5
2603 || rs6000_cpu == PROCESSOR_POWER7);
2604 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
2605 || rs6000_cpu == PROCESSOR_POWER5
2606 || rs6000_cpu == PROCESSOR_POWER6
2607 || rs6000_cpu == PROCESSOR_POWER7
2608 || rs6000_cpu == PROCESSOR_PPCE500MC
2609 || rs6000_cpu == PROCESSOR_PPCE500MC64);
2611 /* Allow debug switches to override the above settings. */
2612 if (TARGET_ALWAYS_HINT > 0)
2613 rs6000_always_hint = TARGET_ALWAYS_HINT;
2615 if (TARGET_SCHED_GROUPS > 0)
2616 rs6000_sched_groups = TARGET_SCHED_GROUPS;
2618 if (TARGET_ALIGN_BRANCH_TARGETS > 0)
2619 rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS;
2621 rs6000_sched_restricted_insns_priority
2622 = (rs6000_sched_groups ? 1 : 0);
2624 /* Handle -msched-costly-dep option. */
2625 rs6000_sched_costly_dep
2626 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
2628 if (rs6000_sched_costly_dep_str)
2630 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
2631 rs6000_sched_costly_dep = no_dep_costly;
2632 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
2633 rs6000_sched_costly_dep = all_deps_costly;
2634 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
2635 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
2636 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
2637 rs6000_sched_costly_dep = store_to_load_dep_costly;
2639 rs6000_sched_costly_dep = ((enum rs6000_dependence_cost)
2640 atoi (rs6000_sched_costly_dep_str));
2643 /* Handle -minsert-sched-nops option. */
2644 rs6000_sched_insert_nops
2645 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
2647 if (rs6000_sched_insert_nops_str)
2649 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
2650 rs6000_sched_insert_nops = sched_finish_none;
2651 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
2652 rs6000_sched_insert_nops = sched_finish_pad_groups;
2653 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
2654 rs6000_sched_insert_nops = sched_finish_regroup_exact;
2656 rs6000_sched_insert_nops = ((enum rs6000_nop_insertion)
2657 atoi (rs6000_sched_insert_nops_str));
2660 #ifdef TARGET_REGNAMES
2661 /* If the user desires alternate register names, copy in the
2662 alternate names now. */
2663 if (TARGET_REGNAMES)
2664 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
2667 /* Set aix_struct_return last, after the ABI is determined.
2668 If -maix-struct-return or -msvr4-struct-return was explicitly
2669 used, don't override with the ABI default. */
2670 if (!rs6000_explicit_options.aix_struct_ret)
2671 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
2673 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
2674 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
2677 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
2679 /* We can only guarantee the availability of DI pseudo-ops when
2680 assembling for 64-bit targets. */
2683 targetm.asm_out.aligned_op.di = NULL;
2684 targetm.asm_out.unaligned_op.di = NULL;
2687 /* Set branch target alignment, if not optimizing for size. */
2690 /* Cell wants to be aligned 8byte for dual issue. */
2691 if (rs6000_cpu == PROCESSOR_CELL)
2693 if (align_functions <= 0)
2694 align_functions = 8;
2695 if (align_jumps <= 0)
2697 if (align_loops <= 0)
2700 if (rs6000_align_branch_targets)
2702 if (align_functions <= 0)
2703 align_functions = 16;
2704 if (align_jumps <= 0)
2706 if (align_loops <= 0)
2709 if (align_jumps_max_skip <= 0)
2710 align_jumps_max_skip = 15;
2711 if (align_loops_max_skip <= 0)
2712 align_loops_max_skip = 15;
2715 /* Arrange to save and restore machine status around nested functions. */
2716 init_machine_status = rs6000_init_machine_status;
2718 /* We should always be splitting complex arguments, but we can't break
2719 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
2720 if (DEFAULT_ABI != ABI_AIX)
2721 targetm.calls.split_complex_arg = NULL;
2723 /* Initialize rs6000_cost with the appropriate target costs. */
2725 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
2729 case PROCESSOR_RIOS1:
2730 rs6000_cost = &rios1_cost;
2733 case PROCESSOR_RIOS2:
2734 rs6000_cost = &rios2_cost;
2737 case PROCESSOR_RS64A:
2738 rs6000_cost = &rs64a_cost;
2741 case PROCESSOR_MPCCORE:
2742 rs6000_cost = &mpccore_cost;
2745 case PROCESSOR_PPC403:
2746 rs6000_cost = &ppc403_cost;
2749 case PROCESSOR_PPC405:
2750 rs6000_cost = &ppc405_cost;
2753 case PROCESSOR_PPC440:
2754 rs6000_cost = &ppc440_cost;
2757 case PROCESSOR_PPC476:
2758 rs6000_cost = &ppc476_cost;
2761 case PROCESSOR_PPC601:
2762 rs6000_cost = &ppc601_cost;
2765 case PROCESSOR_PPC603:
2766 rs6000_cost = &ppc603_cost;
2769 case PROCESSOR_PPC604:
2770 rs6000_cost = &ppc604_cost;
2773 case PROCESSOR_PPC604e:
2774 rs6000_cost = &ppc604e_cost;
2777 case PROCESSOR_PPC620:
2778 rs6000_cost = &ppc620_cost;
2781 case PROCESSOR_PPC630:
2782 rs6000_cost = &ppc630_cost;
2785 case PROCESSOR_CELL:
2786 rs6000_cost = &ppccell_cost;
2789 case PROCESSOR_PPC750:
2790 case PROCESSOR_PPC7400:
2791 rs6000_cost = &ppc750_cost;
2794 case PROCESSOR_PPC7450:
2795 rs6000_cost = &ppc7450_cost;
2798 case PROCESSOR_PPC8540:
2799 rs6000_cost = &ppc8540_cost;
2802 case PROCESSOR_PPCE300C2:
2803 case PROCESSOR_PPCE300C3:
2804 rs6000_cost = &ppce300c2c3_cost;
2807 case PROCESSOR_PPCE500MC:
2808 rs6000_cost = &ppce500mc_cost;
2811 case PROCESSOR_PPCE500MC64:
2812 rs6000_cost = &ppce500mc64_cost;
2815 case PROCESSOR_POWER4:
2816 case PROCESSOR_POWER5:
2817 rs6000_cost = &power4_cost;
2820 case PROCESSOR_POWER6:
2821 rs6000_cost = &power6_cost;
2824 case PROCESSOR_POWER7:
2825 rs6000_cost = &power7_cost;
2828 case PROCESSOR_PPCA2:
2829 rs6000_cost = &ppca2_cost;
2836 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
2837 set_param_value ("simultaneous-prefetches",
2838 rs6000_cost->simultaneous_prefetches);
2839 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
2840 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
2841 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
2842 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
2843 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
2844 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
2846 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2847 can be optimized to ap = __builtin_next_arg (0). */
2848 if (DEFAULT_ABI != ABI_V4)
2849 targetm.expand_builtin_va_start = NULL;
2851 /* Set up single/double float flags.
2852 If TARGET_HARD_FLOAT is set, but neither single or double is set,
2853 then set both flags. */
2854 if (TARGET_HARD_FLOAT && TARGET_FPRS
2855 && rs6000_single_float == 0 && rs6000_double_float == 0)
2856 rs6000_single_float = rs6000_double_float = 1;
2858 /* Reset single and double FP flags if target is E500. */
2861 rs6000_single_float = rs6000_double_float = 0;
2862 if (TARGET_E500_SINGLE)
2863 rs6000_single_float = 1;
2864 if (TARGET_E500_DOUBLE)
2865 rs6000_single_float = rs6000_double_float = 1;
2868 /* If not explicitly specified via option, decide whether to generate indexed
2869 load/store instructions. */
2870 if (TARGET_AVOID_XFORM == -1)
2871 /* Avoid indexed addressing when targeting Power6 in order to avoid
2872 the DERAT mispredict penalty. */
2873 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB);
2875 rs6000_init_hard_regno_mode_ok ();
2878 /* Implement targetm.vectorize.builtin_mask_for_load. */
2880 rs6000_builtin_mask_for_load (void)
2882 if (TARGET_ALTIVEC || TARGET_VSX)
2883 return altivec_builtin_mask_for_load;
2888 /* Implement targetm.vectorize.builtin_conversion.
2889 Returns a decl of a function that implements conversion of an integer vector
2890 into a floating-point vector, or vice-versa. DEST_TYPE is the
2891 destination type and SRC_TYPE the source type of the conversion.
2892 Return NULL_TREE if it is not available. */
2894 rs6000_builtin_conversion (unsigned int tcode, tree dest_type, tree src_type)
2896 enum tree_code code = (enum tree_code) tcode;
2900 case FIX_TRUNC_EXPR:
2901 switch (TYPE_MODE (dest_type))
2904 if (!VECTOR_UNIT_VSX_P (V2DFmode))
2907 return TYPE_UNSIGNED (dest_type)
2908 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVDPUXDS_UNS]
2909 : rs6000_builtin_decls[VSX_BUILTIN_XVCVDPSXDS];
2912 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
2915 return TYPE_UNSIGNED (dest_type)
2916 ? rs6000_builtin_decls[VECTOR_BUILTIN_FIXUNS_V4SF_V4SI]
2917 : rs6000_builtin_decls[VECTOR_BUILTIN_FIX_V4SF_V4SI];
2924 switch (TYPE_MODE (src_type))
2927 if (!VECTOR_UNIT_VSX_P (V2DFmode))
2930 return TYPE_UNSIGNED (src_type)
2931 ? rs6000_builtin_decls[VSX_BUILTIN_XVCVUXDDP]
2932 : rs6000_builtin_decls[VSX_BUILTIN_XVCVSXDDP];
2935 if (VECTOR_UNIT_NONE_P (V4SImode) || VECTOR_UNIT_NONE_P (V4SFmode))
2938 return TYPE_UNSIGNED (src_type)
2939 ? rs6000_builtin_decls[VECTOR_BUILTIN_UNSFLOAT_V4SI_V4SF]
2940 : rs6000_builtin_decls[VECTOR_BUILTIN_FLOAT_V4SI_V4SF];
2951 /* Implement targetm.vectorize.builtin_mul_widen_even. */
2953 rs6000_builtin_mul_widen_even (tree type)
2955 if (!TARGET_ALTIVEC)
2958 switch (TYPE_MODE (type))
2961 return TYPE_UNSIGNED (type)
2962 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH_UNS]
2963 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
2966 return TYPE_UNSIGNED (type)
2967 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB_UNS]
2968 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
2974 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
2976 rs6000_builtin_mul_widen_odd (tree type)
2978 if (!TARGET_ALTIVEC)
2981 switch (TYPE_MODE (type))
2984 return TYPE_UNSIGNED (type)
2985 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH_UNS]
2986 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
2989 return TYPE_UNSIGNED (type)
2990 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB_UNS]
2991 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
2998 /* Return true iff, data reference of TYPE can reach vector alignment (16)
2999 after applying N number of iterations. This routine does not determine
3000 how may iterations are required to reach desired alignment. */
3003 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
3010 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
3013 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
3023 /* Assuming that all other types are naturally aligned. CHECKME! */
3028 /* Return true if the vector misalignment factor is supported by the
3031 rs6000_builtin_support_vector_misalignment (enum machine_mode mode,
3038 /* Return if movmisalign pattern is not supported for this mode. */
3039 if (optab_handler (movmisalign_optab, mode)->insn_code ==
3043 if (misalignment == -1)
3045 /* misalignment factor is unknown at compile time but we know
3046 it's word aligned. */
3047 if (rs6000_vector_alignment_reachable (type, is_packed))
3051 /* VSX supports word-aligned vector. */
3052 if (misalignment % 4 == 0)
3058 /* Implement targetm.vectorize.builtin_vec_perm. */
3060 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
3062 tree inner_type = TREE_TYPE (type);
3063 bool uns_p = TYPE_UNSIGNED (inner_type);
3066 *mask_element_type = unsigned_char_type_node;
3068 switch (TYPE_MODE (type))
3072 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI_UNS]
3073 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI]);
3078 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI_UNS]
3079 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI]);
3084 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI_UNS]
3085 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI]);
3089 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
3093 if (!TARGET_ALLOW_DF_PERMUTE)
3096 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DF];
3100 if (!TARGET_ALLOW_DF_PERMUTE)
3104 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI_UNS]
3105 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_2DI]);
3116 /* Handle generic options of the form -mfoo=yes/no.
3117 NAME is the option name.
3118 VALUE is the option value.
3119 FLAG is the pointer to the flag where to store a 1 or 0, depending on
3120 whether the option value is 'yes' or 'no' respectively. */
3122 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
3126 else if (!strcmp (value, "yes"))
3128 else if (!strcmp (value, "no"))
3131 error ("unknown -m%s= option specified: '%s'", name, value);
3134 /* Validate and record the size specified with the -mtls-size option. */
3137 rs6000_parse_tls_size_option (void)
3139 if (rs6000_tls_size_string == 0)
3141 else if (strcmp (rs6000_tls_size_string, "16") == 0)
3142 rs6000_tls_size = 16;
3143 else if (strcmp (rs6000_tls_size_string, "32") == 0)
3144 rs6000_tls_size = 32;
3145 else if (strcmp (rs6000_tls_size_string, "64") == 0)
3146 rs6000_tls_size = 64;
3148 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
3152 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
3154 if (DEFAULT_ABI == ABI_DARWIN)
3155 /* The Darwin libraries never set errno, so we might as well
3156 avoid calling them when that's the only reason we would. */
3157 flag_errno_math = 0;
3159 /* Double growth factor to counter reduced min jump length. */
3160 set_param_value ("max-grow-copy-bb-insns", 16);
3162 /* Enable section anchors by default.
3163 Skip section anchors for Objective C and Objective C++
3164 until front-ends fixed. */
3165 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
3166 flag_section_anchors = 2;
3169 static enum fpu_type_t
3170 rs6000_parse_fpu_option (const char *option)
3172 if (!strcmp("none", option)) return FPU_NONE;
3173 if (!strcmp("sp_lite", option)) return FPU_SF_LITE;
3174 if (!strcmp("dp_lite", option)) return FPU_DF_LITE;
3175 if (!strcmp("sp_full", option)) return FPU_SF_FULL;
3176 if (!strcmp("dp_full", option)) return FPU_DF_FULL;
3177 error("unknown value %s for -mfpu", option);
3181 /* Returns a function decl for a vectorized version of the builtin function
3182 with builtin function code FN and the result vector type TYPE, or NULL_TREE
3183 if it is not available. */
3186 rs6000_builtin_vectorized_function (tree fndecl, tree type_out,
3189 enum machine_mode in_mode, out_mode;
3191 enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
3193 if (TREE_CODE (type_out) != VECTOR_TYPE
3194 || TREE_CODE (type_in) != VECTOR_TYPE
3195 || !TARGET_VECTORIZE_BUILTINS
3196 || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
3199 out_mode = TYPE_MODE (TREE_TYPE (type_out));
3200 out_n = TYPE_VECTOR_SUBPARTS (type_out);
3201 in_mode = TYPE_MODE (TREE_TYPE (type_in));
3202 in_n = TYPE_VECTOR_SUBPARTS (type_in);
3206 case BUILT_IN_COPYSIGN:
3207 if (VECTOR_UNIT_VSX_P (V2DFmode)
3208 && out_mode == DFmode && out_n == 2
3209 && in_mode == DFmode && in_n == 2)
3210 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNDP];
3212 case BUILT_IN_COPYSIGNF:
3213 if (out_mode != SFmode || out_n != 4
3214 || in_mode != SFmode || in_n != 4)
3216 if (VECTOR_UNIT_VSX_P (V4SFmode))
3217 return rs6000_builtin_decls[VSX_BUILTIN_CPSGNSP];
3218 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3219 return rs6000_builtin_decls[ALTIVEC_BUILTIN_COPYSIGN_V4SF];
3222 if (VECTOR_UNIT_VSX_P (V2DFmode)
3223 && out_mode == DFmode && out_n == 2
3224 && in_mode == DFmode && in_n == 2)
3225 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTDP];
3227 case BUILT_IN_SQRTF:
3228 if (VECTOR_UNIT_VSX_P (V4SFmode)
3229 && out_mode == SFmode && out_n == 4
3230 && in_mode == SFmode && in_n == 4)
3231 return rs6000_builtin_decls[VSX_BUILTIN_XVSQRTSP];
3234 if (VECTOR_UNIT_VSX_P (V2DFmode)
3235 && out_mode == DFmode && out_n == 2
3236 && in_mode == DFmode && in_n == 2)
3237 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIP];
3239 case BUILT_IN_CEILF:
3240 if (out_mode != SFmode || out_n != 4
3241 || in_mode != SFmode || in_n != 4)
3243 if (VECTOR_UNIT_VSX_P (V4SFmode))
3244 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIP];
3245 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3246 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIP];
3248 case BUILT_IN_FLOOR:
3249 if (VECTOR_UNIT_VSX_P (V2DFmode)
3250 && out_mode == DFmode && out_n == 2
3251 && in_mode == DFmode && in_n == 2)
3252 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIM];
3254 case BUILT_IN_FLOORF:
3255 if (out_mode != SFmode || out_n != 4
3256 || in_mode != SFmode || in_n != 4)
3258 if (VECTOR_UNIT_VSX_P (V4SFmode))
3259 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIM];
3260 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3261 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIM];
3263 case BUILT_IN_TRUNC:
3264 if (VECTOR_UNIT_VSX_P (V2DFmode)
3265 && out_mode == DFmode && out_n == 2
3266 && in_mode == DFmode && in_n == 2)
3267 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIZ];
3269 case BUILT_IN_TRUNCF:
3270 if (out_mode != SFmode || out_n != 4
3271 || in_mode != SFmode || in_n != 4)
3273 if (VECTOR_UNIT_VSX_P (V4SFmode))
3274 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIZ];
3275 if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
3276 return rs6000_builtin_decls[ALTIVEC_BUILTIN_VRFIZ];
3278 case BUILT_IN_NEARBYINT:
3279 if (VECTOR_UNIT_VSX_P (V2DFmode)
3280 && flag_unsafe_math_optimizations
3281 && out_mode == DFmode && out_n == 2
3282 && in_mode == DFmode && in_n == 2)
3283 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPI];
3285 case BUILT_IN_NEARBYINTF:
3286 if (VECTOR_UNIT_VSX_P (V4SFmode)
3287 && flag_unsafe_math_optimizations
3288 && out_mode == SFmode && out_n == 4
3289 && in_mode == SFmode && in_n == 4)
3290 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPI];
3293 if (VECTOR_UNIT_VSX_P (V2DFmode)
3294 && !flag_trapping_math
3295 && out_mode == DFmode && out_n == 2
3296 && in_mode == DFmode && in_n == 2)
3297 return rs6000_builtin_decls[VSX_BUILTIN_XVRDPIC];
3299 case BUILT_IN_RINTF:
3300 if (VECTOR_UNIT_VSX_P (V4SFmode)
3301 && !flag_trapping_math
3302 && out_mode == SFmode && out_n == 4
3303 && in_mode == SFmode && in_n == 4)
3304 return rs6000_builtin_decls[VSX_BUILTIN_XVRSPIC];
3313 /* Implement TARGET_HANDLE_OPTION. */
3316 rs6000_handle_option (size_t code, const char *arg, int value)
3318 enum fpu_type_t fpu_type = FPU_NONE;
3324 target_flags &= ~(MASK_POWER | MASK_POWER2
3325 | MASK_MULTIPLE | MASK_STRING);
3326 target_flags_explicit |= (MASK_POWER | MASK_POWER2
3327 | MASK_MULTIPLE | MASK_STRING);
3329 case OPT_mno_powerpc:
3330 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
3331 | MASK_PPC_GFXOPT | MASK_POWERPC64);
3332 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
3333 | MASK_PPC_GFXOPT | MASK_POWERPC64);
3336 target_flags &= ~MASK_MINIMAL_TOC;
3337 TARGET_NO_FP_IN_TOC = 0;
3338 TARGET_NO_SUM_IN_TOC = 0;
3339 target_flags_explicit |= MASK_MINIMAL_TOC;
3340 #ifdef TARGET_USES_SYSV4_OPT
3341 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
3342 just the same as -mminimal-toc. */
3343 target_flags |= MASK_MINIMAL_TOC;
3344 target_flags_explicit |= MASK_MINIMAL_TOC;
3348 #ifdef TARGET_USES_SYSV4_OPT
3350 /* Make -mtoc behave like -mminimal-toc. */
3351 target_flags |= MASK_MINIMAL_TOC;
3352 target_flags_explicit |= MASK_MINIMAL_TOC;
3356 #ifdef TARGET_USES_AIX64_OPT
3361 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
3362 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
3363 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
3366 #ifdef TARGET_USES_AIX64_OPT
3371 target_flags &= ~MASK_POWERPC64;
3372 target_flags_explicit |= MASK_POWERPC64;
3375 case OPT_minsert_sched_nops_:
3376 rs6000_sched_insert_nops_str = arg;
3379 case OPT_mminimal_toc:
3382 TARGET_NO_FP_IN_TOC = 0;
3383 TARGET_NO_SUM_IN_TOC = 0;
3390 target_flags |= (MASK_MULTIPLE | MASK_STRING);
3391 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
3398 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
3399 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
3403 case OPT_mpowerpc_gpopt:
3404 case OPT_mpowerpc_gfxopt:
3407 target_flags |= MASK_POWERPC;
3408 target_flags_explicit |= MASK_POWERPC;
3412 case OPT_maix_struct_return:
3413 case OPT_msvr4_struct_return:
3414 rs6000_explicit_options.aix_struct_ret = true;
3418 rs6000_explicit_options.vrsave = true;
3419 TARGET_ALTIVEC_VRSAVE = value;
3423 rs6000_explicit_options.vrsave = true;
3424 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
3428 target_flags_explicit |= MASK_ISEL;
3430 rs6000_parse_yes_no_option ("isel", arg, &isel);
3432 target_flags |= MASK_ISEL;
3434 target_flags &= ~MASK_ISEL;
3438 rs6000_explicit_options.spe = true;
3443 rs6000_explicit_options.spe = true;
3444 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
3448 rs6000_debug_name = arg;
3451 #ifdef TARGET_USES_SYSV4_OPT
3453 rs6000_abi_name = arg;
3457 rs6000_sdata_name = arg;
3460 case OPT_mtls_size_:
3461 rs6000_tls_size_string = arg;
3464 case OPT_mrelocatable:
3467 target_flags |= MASK_MINIMAL_TOC;
3468 target_flags_explicit |= MASK_MINIMAL_TOC;
3469 TARGET_NO_FP_IN_TOC = 1;
3473 case OPT_mrelocatable_lib:
3476 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
3477 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
3478 TARGET_NO_FP_IN_TOC = 1;
3482 target_flags &= ~MASK_RELOCATABLE;
3483 target_flags_explicit |= MASK_RELOCATABLE;
3489 if (!strcmp (arg, "altivec"))
3491 rs6000_explicit_options.altivec_abi = true;
3492 rs6000_altivec_abi = 1;
3494 /* Enabling the AltiVec ABI turns off the SPE ABI. */
3497 else if (! strcmp (arg, "no-altivec"))
3499 rs6000_explicit_options.altivec_abi = true;
3500 rs6000_altivec_abi = 0;
3502 else if (! strcmp (arg, "spe"))
3504 rs6000_explicit_options.spe_abi = true;
3506 rs6000_altivec_abi = 0;
3507 if (!TARGET_SPE_ABI)
3508 error ("not configured for ABI: '%s'", arg);
3510 else if (! strcmp (arg, "no-spe"))
3512 rs6000_explicit_options.spe_abi = true;
3516 /* These are here for testing during development only, do not
3517 document in the manual please. */
3518 else if (! strcmp (arg, "d64"))
3520 rs6000_darwin64_abi = 1;
3521 warning (0, "Using darwin64 ABI");
3523 else if (! strcmp (arg, "d32"))
3525 rs6000_darwin64_abi = 0;
3526 warning (0, "Using old darwin ABI");
3529 else if (! strcmp (arg, "ibmlongdouble"))
3531 rs6000_explicit_options.ieee = true;
3532 rs6000_ieeequad = 0;
3533 warning (0, "Using IBM extended precision long double");
3535 else if (! strcmp (arg, "ieeelongdouble"))
3537 rs6000_explicit_options.ieee = true;
3538 rs6000_ieeequad = 1;
3539 warning (0, "Using IEEE extended precision long double");
3544 error ("unknown ABI specified: '%s'", arg);
3550 rs6000_select[1].string = arg;
3554 rs6000_select[2].string = arg;
3557 case OPT_mtraceback_:
3558 rs6000_traceback_name = arg;
3561 case OPT_mfloat_gprs_:
3562 rs6000_explicit_options.float_gprs = true;
3563 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
3564 rs6000_float_gprs = 1;
3565 else if (! strcmp (arg, "double"))
3566 rs6000_float_gprs = 2;
3567 else if (! strcmp (arg, "no"))
3568 rs6000_float_gprs = 0;
3571 error ("invalid option for -mfloat-gprs: '%s'", arg);
3576 case OPT_mlong_double_:
3577 rs6000_explicit_options.long_double = true;
3578 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
3579 if (value != 64 && value != 128)
3581 error ("Unknown switch -mlong-double-%s", arg);
3582 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
3586 rs6000_long_double_type_size = value;
3589 case OPT_msched_costly_dep_:
3590 rs6000_sched_costly_dep_str = arg;
3594 rs6000_explicit_options.alignment = true;
3595 if (! strcmp (arg, "power"))
3597 /* On 64-bit Darwin, power alignment is ABI-incompatible with
3598 some C library functions, so warn about it. The flag may be
3599 useful for performance studies from time to time though, so
3600 don't disable it entirely. */
3601 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
3602 warning (0, "-malign-power is not supported for 64-bit Darwin;"
3603 " it is incompatible with the installed C and C++ libraries");
3604 rs6000_alignment_flags = MASK_ALIGN_POWER;
3606 else if (! strcmp (arg, "natural"))
3607 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
3610 error ("unknown -malign-XXXXX option specified: '%s'", arg);
3615 case OPT_msingle_float:
3616 if (!TARGET_SINGLE_FPU)
3617 warning (0, "-msingle-float option equivalent to -mhard-float");
3618 /* -msingle-float implies -mno-double-float and TARGET_HARD_FLOAT. */
3619 rs6000_double_float = 0;
3620 target_flags &= ~MASK_SOFT_FLOAT;
3621 target_flags_explicit |= MASK_SOFT_FLOAT;
3624 case OPT_mdouble_float:
3625 /* -mdouble-float implies -msingle-float and TARGET_HARD_FLOAT. */
3626 rs6000_single_float = 1;
3627 target_flags &= ~MASK_SOFT_FLOAT;
3628 target_flags_explicit |= MASK_SOFT_FLOAT;
3631 case OPT_msimple_fpu:
3632 if (!TARGET_SINGLE_FPU)
3633 warning (0, "-msimple-fpu option ignored");
3636 case OPT_mhard_float:
3637 /* -mhard_float implies -msingle-float and -mdouble-float. */
3638 rs6000_single_float = rs6000_double_float = 1;
3641 case OPT_msoft_float:
3642 /* -msoft_float implies -mnosingle-float and -mnodouble-float. */
3643 rs6000_single_float = rs6000_double_float = 0;
3647 fpu_type = rs6000_parse_fpu_option(arg);
3648 if (fpu_type != FPU_NONE)
3649 /* If -mfpu is not none, then turn off SOFT_FLOAT, turn on HARD_FLOAT. */
3651 target_flags &= ~MASK_SOFT_FLOAT;
3652 target_flags_explicit |= MASK_SOFT_FLOAT;
3653 rs6000_xilinx_fpu = 1;
3654 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_SF_FULL)
3655 rs6000_single_float = 1;
3656 if (fpu_type == FPU_DF_LITE || fpu_type == FPU_DF_FULL)
3657 rs6000_single_float = rs6000_double_float = 1;
3658 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_DF_LITE)
3659 rs6000_simple_fpu = 1;
3663 /* -mfpu=none is equivalent to -msoft-float */
3664 target_flags |= MASK_SOFT_FLOAT;
3665 target_flags_explicit |= MASK_SOFT_FLOAT;
3666 rs6000_single_float = rs6000_double_float = 0;
3673 /* Do anything needed at the start of the asm file. */
3676 rs6000_file_start (void)
3680 const char *start = buffer;
3681 struct rs6000_cpu_select *ptr;
3682 const char *default_cpu = TARGET_CPU_DEFAULT;
3683 FILE *file = asm_out_file;
3685 default_file_start ();
3687 #ifdef TARGET_BI_ARCH
3688 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
3692 if (flag_verbose_asm)
3694 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
3695 rs6000_select[0].string = default_cpu;
3697 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
3699 ptr = &rs6000_select[i];
3700 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
3702 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
3707 if (PPC405_ERRATUM77)
3709 fprintf (file, "%s PPC405CR_ERRATUM77", start);
3713 #ifdef USING_ELFOS_H
3714 switch (rs6000_sdata)
3716 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
3717 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
3718 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
3719 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
3722 if (rs6000_sdata && g_switch_value)
3724 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
3734 #ifdef HAVE_AS_GNU_ATTRIBUTE
3735 if (TARGET_32BIT && DEFAULT_ABI == ABI_V4)
3737 fprintf (file, "\t.gnu_attribute 4, %d\n",
3738 ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT) ? 1
3739 : (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT) ? 3
3741 fprintf (file, "\t.gnu_attribute 8, %d\n",
3742 (TARGET_ALTIVEC_ABI ? 2
3743 : TARGET_SPE_ABI ? 3
3745 fprintf (file, "\t.gnu_attribute 12, %d\n",
3746 aix_struct_return ? 2 : 1);
3751 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
3753 switch_to_section (toc_section);
3754 switch_to_section (text_section);
3759 /* Return nonzero if this function is known to have a null epilogue. */
3762 direct_return (void)
3764 if (reload_completed)
3766 rs6000_stack_t *info = rs6000_stack_info ();
3768 if (info->first_gp_reg_save == 32
3769 && info->first_fp_reg_save == 64
3770 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
3771 && ! info->lr_save_p
3772 && ! info->cr_save_p
3773 && info->vrsave_mask == 0
3781 /* Return the number of instructions it takes to form a constant in an
3782 integer register. */
3785 num_insns_constant_wide (HOST_WIDE_INT value)
3787 /* signed constant loadable with {cal|addi} */
3788 if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000)
3791 /* constant loadable with {cau|addis} */
3792 else if ((value & 0xffff) == 0
3793 && (value >> 31 == -1 || value >> 31 == 0))
3796 #if HOST_BITS_PER_WIDE_INT == 64
3797 else if (TARGET_POWERPC64)
3799 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
3800 HOST_WIDE_INT high = value >> 31;
3802 if (high == 0 || high == -1)
3808 return num_insns_constant_wide (high) + 1;
3810 return num_insns_constant_wide (low) + 1;
3812 return (num_insns_constant_wide (high)
3813 + num_insns_constant_wide (low) + 1);
3822 num_insns_constant (rtx op, enum machine_mode mode)
3824 HOST_WIDE_INT low, high;
3826 switch (GET_CODE (op))
3829 #if HOST_BITS_PER_WIDE_INT == 64
3830 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
3831 && mask64_operand (op, mode))
3835 return num_insns_constant_wide (INTVAL (op));
3838 if (mode == SFmode || mode == SDmode)
3843 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
3844 if (DECIMAL_FLOAT_MODE_P (mode))
3845 REAL_VALUE_TO_TARGET_DECIMAL32 (rv, l);
3847 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
3848 return num_insns_constant_wide ((HOST_WIDE_INT) l);
3851 if (mode == VOIDmode || mode == DImode)
3853 high = CONST_DOUBLE_HIGH (op);
3854 low = CONST_DOUBLE_LOW (op);
3861 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
3862 if (DECIMAL_FLOAT_MODE_P (mode))
3863 REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
3865 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
3866 high = l[WORDS_BIG_ENDIAN == 0];
3867 low = l[WORDS_BIG_ENDIAN != 0];
3871 return (num_insns_constant_wide (low)
3872 + num_insns_constant_wide (high));
3875 if ((high == 0 && low >= 0)
3876 || (high == -1 && low < 0))
3877 return num_insns_constant_wide (low);
3879 else if (mask64_operand (op, mode))
3883 return num_insns_constant_wide (high) + 1;
3886 return (num_insns_constant_wide (high)
3887 + num_insns_constant_wide (low) + 1);
3895 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
3896 If the mode of OP is MODE_VECTOR_INT, this simply returns the
3897 corresponding element of the vector, but for V4SFmode and V2SFmode,
3898 the corresponding "float" is interpreted as an SImode integer. */
3901 const_vector_elt_as_int (rtx op, unsigned int elt)
3903 rtx tmp = CONST_VECTOR_ELT (op, elt);
3904 if (GET_MODE (op) == V4SFmode
3905 || GET_MODE (op) == V2SFmode)
3906 tmp = gen_lowpart (SImode, tmp);
3907 return INTVAL (tmp);
3910 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
3911 or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used
3912 depends on STEP and COPIES, one of which will be 1. If COPIES > 1,
3913 all items are set to the same value and contain COPIES replicas of the
3914 vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's
3915 operand and the others are set to the value of the operand's msb. */
3918 vspltis_constant (rtx op, unsigned step, unsigned copies)
3920 enum machine_mode mode = GET_MODE (op);
3921 enum machine_mode inner = GET_MODE_INNER (mode);
3924 unsigned nunits = GET_MODE_NUNITS (mode);
3925 unsigned bitsize = GET_MODE_BITSIZE (inner);
3926 unsigned mask = GET_MODE_MASK (inner);
3928 HOST_WIDE_INT val = const_vector_elt_as_int (op, nunits - 1);
3929 HOST_WIDE_INT splat_val = val;
3930 HOST_WIDE_INT msb_val = val > 0 ? 0 : -1;
3932 /* Construct the value to be splatted, if possible. If not, return 0. */
3933 for (i = 2; i <= copies; i *= 2)
3935 HOST_WIDE_INT small_val;
3937 small_val = splat_val >> bitsize;
3939 if (splat_val != ((small_val << bitsize) | (small_val & mask)))
3941 splat_val = small_val;
3944 /* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */
3945 if (EASY_VECTOR_15 (splat_val))
3948 /* Also check if we can splat, and then add the result to itself. Do so if
3949 the value is positive, of if the splat instruction is using OP's mode;
3950 for splat_val < 0, the splat and the add should use the same mode. */
3951 else if (EASY_VECTOR_15_ADD_SELF (splat_val)
3952 && (splat_val >= 0 || (step == 1 && copies == 1)))
3955 /* Also check if are loading up the most significant bit which can be done by
3956 loading up -1 and shifting the value left by -1. */
3957 else if (EASY_VECTOR_MSB (splat_val, inner))
3963 /* Check if VAL is present in every STEP-th element, and the
3964 other elements are filled with its most significant bit. */
3965 for (i = 0; i < nunits - 1; ++i)
3967 HOST_WIDE_INT desired_val;
3968 if (((i + 1) & (step - 1)) == 0)
3971 desired_val = msb_val;
3973 if (desired_val != const_vector_elt_as_int (op, i))
3981 /* Return true if OP is of the given MODE and can be synthesized
3982 with a vspltisb, vspltish or vspltisw. */
3985 easy_altivec_constant (rtx op, enum machine_mode mode)