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
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"
55 #include "tree-gimple.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 machine_function GTY(())
118 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
119 int ra_needs_full_frame;
120 /* Some local-dynamic symbol. */
121 const char *some_ld_name;
122 /* Whether the instruction chain has been scanned already. */
123 int insn_chain_scanned_p;
124 /* Flags if __builtin_return_address (0) was used. */
126 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
127 varargs save area. */
128 HOST_WIDE_INT varargs_save_offset;
129 /* Temporary stack slot to use for SDmode copies. This slot is
130 64-bits wide and is allocated early enough so that the offset
131 does not overflow the 16-bit load/store offset field. */
132 rtx sdmode_stack_slot;
135 /* Target cpu type */
137 enum processor_type rs6000_cpu;
138 struct rs6000_cpu_select rs6000_select[3] =
140 /* switch name, tune arch */
141 { (const char *)0, "--with-cpu=", 1, 1 },
142 { (const char *)0, "-mcpu=", 1, 1 },
143 { (const char *)0, "-mtune=", 1, 0 },
146 static GTY(()) bool rs6000_cell_dont_microcode;
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 ABI extensions. */
180 /* Nonzero if floating point operations are done in the GPRs. */
181 int rs6000_float_gprs = 0;
183 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
184 int rs6000_darwin64_abi;
186 /* Set to nonzero once AIX common-mode calls have been defined. */
187 static GTY(()) int common_mode_defined;
189 /* Save information from a "cmpxx" operation until the branch or scc is
191 rtx rs6000_compare_op0, rs6000_compare_op1;
192 int rs6000_compare_fp_p;
194 /* Label number of label created for -mrelocatable, to call to so we can
195 get the address of the GOT section */
196 int rs6000_pic_labelno;
199 /* Which abi to adhere to */
200 const char *rs6000_abi_name;
202 /* Semantics of the small data area */
203 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
205 /* Which small data model to use */
206 const char *rs6000_sdata_name = (char *)0;
208 /* Counter for labels which are to be placed in .fixup. */
209 int fixuplabelno = 0;
212 /* Bit size of immediate TLS offsets and string from which it is decoded. */
213 int rs6000_tls_size = 32;
214 const char *rs6000_tls_size_string;
216 /* ABI enumeration available for subtarget to use. */
217 enum rs6000_abi rs6000_current_abi;
219 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
223 const char *rs6000_debug_name;
224 int rs6000_debug_stack; /* debug stack applications */
225 int rs6000_debug_arg; /* debug argument handling */
227 /* Value is TRUE if register/mode pair is acceptable. */
228 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
230 /* Built in types. */
232 tree rs6000_builtin_types[RS6000_BTI_MAX];
233 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
235 const char *rs6000_traceback_name;
237 traceback_default = 0,
243 /* Flag to say the TOC is initialized */
245 char toc_label_name[10];
247 /* Cached value of rs6000_variable_issue. This is cached in
248 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
249 static short cached_can_issue_more;
251 static GTY(()) section *read_only_data_section;
252 static GTY(()) section *private_data_section;
253 static GTY(()) section *read_only_private_data_section;
254 static GTY(()) section *sdata2_section;
255 static GTY(()) section *toc_section;
257 /* Control alignment for fields within structures. */
258 /* String from -malign-XXXXX. */
259 int rs6000_alignment_flags;
261 /* True for any options that were explicitly set. */
263 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
264 bool alignment; /* True if -malign- was used. */
265 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
266 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
267 bool spe; /* True if -mspe= was used. */
268 bool float_gprs; /* True if -mfloat-gprs= was used. */
269 bool isel; /* True if -misel was used. */
270 bool long_double; /* True if -mlong-double- was used. */
271 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
272 bool vrsave; /* True if -mvrsave was used. */
273 } rs6000_explicit_options;
275 struct builtin_description
277 /* mask is not const because we're going to alter it below. This
278 nonsense will go away when we rewrite the -march infrastructure
279 to give us more target flag bits. */
281 const enum insn_code icode;
282 const char *const name;
283 const enum rs6000_builtins code;
286 /* Target cpu costs. */
288 struct processor_costs {
289 const int mulsi; /* cost of SImode multiplication. */
290 const int mulsi_const; /* cost of SImode multiplication by constant. */
291 const int mulsi_const9; /* cost of SImode mult by short constant. */
292 const int muldi; /* cost of DImode multiplication. */
293 const int divsi; /* cost of SImode division. */
294 const int divdi; /* cost of DImode division. */
295 const int fp; /* cost of simple SFmode and DFmode insns. */
296 const int dmul; /* cost of DFmode multiplication (and fmadd). */
297 const int sdiv; /* cost of SFmode division (fdivs). */
298 const int ddiv; /* cost of DFmode division (fdiv). */
299 const int cache_line_size; /* cache line size in bytes. */
300 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
301 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
302 const int simultaneous_prefetches; /* number of parallel prefetch
306 const struct processor_costs *rs6000_cost;
308 /* Processor costs (relative to an add) */
310 /* Instruction size costs on 32bit processors. */
312 struct processor_costs size32_cost = {
313 COSTS_N_INSNS (1), /* mulsi */
314 COSTS_N_INSNS (1), /* mulsi_const */
315 COSTS_N_INSNS (1), /* mulsi_const9 */
316 COSTS_N_INSNS (1), /* muldi */
317 COSTS_N_INSNS (1), /* divsi */
318 COSTS_N_INSNS (1), /* divdi */
319 COSTS_N_INSNS (1), /* fp */
320 COSTS_N_INSNS (1), /* dmul */
321 COSTS_N_INSNS (1), /* sdiv */
322 COSTS_N_INSNS (1), /* ddiv */
329 /* Instruction size costs on 64bit processors. */
331 struct processor_costs size64_cost = {
332 COSTS_N_INSNS (1), /* mulsi */
333 COSTS_N_INSNS (1), /* mulsi_const */
334 COSTS_N_INSNS (1), /* mulsi_const9 */
335 COSTS_N_INSNS (1), /* muldi */
336 COSTS_N_INSNS (1), /* divsi */
337 COSTS_N_INSNS (1), /* divdi */
338 COSTS_N_INSNS (1), /* fp */
339 COSTS_N_INSNS (1), /* dmul */
340 COSTS_N_INSNS (1), /* sdiv */
341 COSTS_N_INSNS (1), /* ddiv */
348 /* Instruction costs on RIOS1 processors. */
350 struct processor_costs rios1_cost = {
351 COSTS_N_INSNS (5), /* mulsi */
352 COSTS_N_INSNS (4), /* mulsi_const */
353 COSTS_N_INSNS (3), /* mulsi_const9 */
354 COSTS_N_INSNS (5), /* muldi */
355 COSTS_N_INSNS (19), /* divsi */
356 COSTS_N_INSNS (19), /* divdi */
357 COSTS_N_INSNS (2), /* fp */
358 COSTS_N_INSNS (2), /* dmul */
359 COSTS_N_INSNS (19), /* sdiv */
360 COSTS_N_INSNS (19), /* ddiv */
361 128, /* cache line size */
367 /* Instruction costs on RIOS2 processors. */
369 struct processor_costs rios2_cost = {
370 COSTS_N_INSNS (2), /* mulsi */
371 COSTS_N_INSNS (2), /* mulsi_const */
372 COSTS_N_INSNS (2), /* mulsi_const9 */
373 COSTS_N_INSNS (2), /* muldi */
374 COSTS_N_INSNS (13), /* divsi */
375 COSTS_N_INSNS (13), /* divdi */
376 COSTS_N_INSNS (2), /* fp */
377 COSTS_N_INSNS (2), /* dmul */
378 COSTS_N_INSNS (17), /* sdiv */
379 COSTS_N_INSNS (17), /* ddiv */
380 256, /* cache line size */
386 /* Instruction costs on RS64A processors. */
388 struct processor_costs rs64a_cost = {
389 COSTS_N_INSNS (20), /* mulsi */
390 COSTS_N_INSNS (12), /* mulsi_const */
391 COSTS_N_INSNS (8), /* mulsi_const9 */
392 COSTS_N_INSNS (34), /* muldi */
393 COSTS_N_INSNS (65), /* divsi */
394 COSTS_N_INSNS (67), /* divdi */
395 COSTS_N_INSNS (4), /* fp */
396 COSTS_N_INSNS (4), /* dmul */
397 COSTS_N_INSNS (31), /* sdiv */
398 COSTS_N_INSNS (31), /* ddiv */
399 128, /* cache line size */
405 /* Instruction costs on MPCCORE processors. */
407 struct processor_costs mpccore_cost = {
408 COSTS_N_INSNS (2), /* mulsi */
409 COSTS_N_INSNS (2), /* mulsi_const */
410 COSTS_N_INSNS (2), /* mulsi_const9 */
411 COSTS_N_INSNS (2), /* muldi */
412 COSTS_N_INSNS (6), /* divsi */
413 COSTS_N_INSNS (6), /* divdi */
414 COSTS_N_INSNS (4), /* fp */
415 COSTS_N_INSNS (5), /* dmul */
416 COSTS_N_INSNS (10), /* sdiv */
417 COSTS_N_INSNS (17), /* ddiv */
418 32, /* cache line size */
424 /* Instruction costs on PPC403 processors. */
426 struct processor_costs ppc403_cost = {
427 COSTS_N_INSNS (4), /* mulsi */
428 COSTS_N_INSNS (4), /* mulsi_const */
429 COSTS_N_INSNS (4), /* mulsi_const9 */
430 COSTS_N_INSNS (4), /* muldi */
431 COSTS_N_INSNS (33), /* divsi */
432 COSTS_N_INSNS (33), /* divdi */
433 COSTS_N_INSNS (11), /* fp */
434 COSTS_N_INSNS (11), /* dmul */
435 COSTS_N_INSNS (11), /* sdiv */
436 COSTS_N_INSNS (11), /* ddiv */
437 32, /* cache line size */
443 /* Instruction costs on PPC405 processors. */
445 struct processor_costs ppc405_cost = {
446 COSTS_N_INSNS (5), /* mulsi */
447 COSTS_N_INSNS (4), /* mulsi_const */
448 COSTS_N_INSNS (3), /* mulsi_const9 */
449 COSTS_N_INSNS (5), /* muldi */
450 COSTS_N_INSNS (35), /* divsi */
451 COSTS_N_INSNS (35), /* divdi */
452 COSTS_N_INSNS (11), /* fp */
453 COSTS_N_INSNS (11), /* dmul */
454 COSTS_N_INSNS (11), /* sdiv */
455 COSTS_N_INSNS (11), /* ddiv */
456 32, /* cache line size */
462 /* Instruction costs on PPC440 processors. */
464 struct processor_costs ppc440_cost = {
465 COSTS_N_INSNS (3), /* mulsi */
466 COSTS_N_INSNS (2), /* mulsi_const */
467 COSTS_N_INSNS (2), /* mulsi_const9 */
468 COSTS_N_INSNS (3), /* muldi */
469 COSTS_N_INSNS (34), /* divsi */
470 COSTS_N_INSNS (34), /* divdi */
471 COSTS_N_INSNS (5), /* fp */
472 COSTS_N_INSNS (5), /* dmul */
473 COSTS_N_INSNS (19), /* sdiv */
474 COSTS_N_INSNS (33), /* ddiv */
475 32, /* cache line size */
481 /* Instruction costs on PPC601 processors. */
483 struct processor_costs ppc601_cost = {
484 COSTS_N_INSNS (5), /* mulsi */
485 COSTS_N_INSNS (5), /* mulsi_const */
486 COSTS_N_INSNS (5), /* mulsi_const9 */
487 COSTS_N_INSNS (5), /* muldi */
488 COSTS_N_INSNS (36), /* divsi */
489 COSTS_N_INSNS (36), /* divdi */
490 COSTS_N_INSNS (4), /* fp */
491 COSTS_N_INSNS (5), /* dmul */
492 COSTS_N_INSNS (17), /* sdiv */
493 COSTS_N_INSNS (31), /* ddiv */
494 32, /* cache line size */
500 /* Instruction costs on PPC603 processors. */
502 struct processor_costs ppc603_cost = {
503 COSTS_N_INSNS (5), /* mulsi */
504 COSTS_N_INSNS (3), /* mulsi_const */
505 COSTS_N_INSNS (2), /* mulsi_const9 */
506 COSTS_N_INSNS (5), /* muldi */
507 COSTS_N_INSNS (37), /* divsi */
508 COSTS_N_INSNS (37), /* divdi */
509 COSTS_N_INSNS (3), /* fp */
510 COSTS_N_INSNS (4), /* dmul */
511 COSTS_N_INSNS (18), /* sdiv */
512 COSTS_N_INSNS (33), /* ddiv */
513 32, /* cache line size */
519 /* Instruction costs on PPC604 processors. */
521 struct processor_costs ppc604_cost = {
522 COSTS_N_INSNS (4), /* mulsi */
523 COSTS_N_INSNS (4), /* mulsi_const */
524 COSTS_N_INSNS (4), /* mulsi_const9 */
525 COSTS_N_INSNS (4), /* muldi */
526 COSTS_N_INSNS (20), /* divsi */
527 COSTS_N_INSNS (20), /* divdi */
528 COSTS_N_INSNS (3), /* fp */
529 COSTS_N_INSNS (3), /* dmul */
530 COSTS_N_INSNS (18), /* sdiv */
531 COSTS_N_INSNS (32), /* ddiv */
532 32, /* cache line size */
538 /* Instruction costs on PPC604e processors. */
540 struct processor_costs ppc604e_cost = {
541 COSTS_N_INSNS (2), /* mulsi */
542 COSTS_N_INSNS (2), /* mulsi_const */
543 COSTS_N_INSNS (2), /* mulsi_const9 */
544 COSTS_N_INSNS (2), /* muldi */
545 COSTS_N_INSNS (20), /* divsi */
546 COSTS_N_INSNS (20), /* divdi */
547 COSTS_N_INSNS (3), /* fp */
548 COSTS_N_INSNS (3), /* dmul */
549 COSTS_N_INSNS (18), /* sdiv */
550 COSTS_N_INSNS (32), /* ddiv */
551 32, /* cache line size */
557 /* Instruction costs on PPC620 processors. */
559 struct processor_costs ppc620_cost = {
560 COSTS_N_INSNS (5), /* mulsi */
561 COSTS_N_INSNS (4), /* mulsi_const */
562 COSTS_N_INSNS (3), /* mulsi_const9 */
563 COSTS_N_INSNS (7), /* muldi */
564 COSTS_N_INSNS (21), /* divsi */
565 COSTS_N_INSNS (37), /* divdi */
566 COSTS_N_INSNS (3), /* fp */
567 COSTS_N_INSNS (3), /* dmul */
568 COSTS_N_INSNS (18), /* sdiv */
569 COSTS_N_INSNS (32), /* ddiv */
570 128, /* cache line size */
576 /* Instruction costs on PPC630 processors. */
578 struct processor_costs ppc630_cost = {
579 COSTS_N_INSNS (5), /* mulsi */
580 COSTS_N_INSNS (4), /* mulsi_const */
581 COSTS_N_INSNS (3), /* mulsi_const9 */
582 COSTS_N_INSNS (7), /* muldi */
583 COSTS_N_INSNS (21), /* divsi */
584 COSTS_N_INSNS (37), /* divdi */
585 COSTS_N_INSNS (3), /* fp */
586 COSTS_N_INSNS (3), /* dmul */
587 COSTS_N_INSNS (17), /* sdiv */
588 COSTS_N_INSNS (21), /* ddiv */
589 128, /* cache line size */
595 /* Instruction costs on Cell processor. */
596 /* COSTS_N_INSNS (1) ~ one add. */
598 struct processor_costs ppccell_cost = {
599 COSTS_N_INSNS (9/2)+2, /* mulsi */
600 COSTS_N_INSNS (6/2), /* mulsi_const */
601 COSTS_N_INSNS (6/2), /* mulsi_const9 */
602 COSTS_N_INSNS (15/2)+2, /* muldi */
603 COSTS_N_INSNS (38/2), /* divsi */
604 COSTS_N_INSNS (70/2), /* divdi */
605 COSTS_N_INSNS (10/2), /* fp */
606 COSTS_N_INSNS (10/2), /* dmul */
607 COSTS_N_INSNS (74/2), /* sdiv */
608 COSTS_N_INSNS (74/2), /* ddiv */
609 128, /* cache line size */
615 /* Instruction costs on PPC750 and PPC7400 processors. */
617 struct processor_costs ppc750_cost = {
618 COSTS_N_INSNS (5), /* mulsi */
619 COSTS_N_INSNS (3), /* mulsi_const */
620 COSTS_N_INSNS (2), /* mulsi_const9 */
621 COSTS_N_INSNS (5), /* muldi */
622 COSTS_N_INSNS (17), /* divsi */
623 COSTS_N_INSNS (17), /* divdi */
624 COSTS_N_INSNS (3), /* fp */
625 COSTS_N_INSNS (3), /* dmul */
626 COSTS_N_INSNS (17), /* sdiv */
627 COSTS_N_INSNS (31), /* ddiv */
628 32, /* cache line size */
634 /* Instruction costs on PPC7450 processors. */
636 struct processor_costs ppc7450_cost = {
637 COSTS_N_INSNS (4), /* mulsi */
638 COSTS_N_INSNS (3), /* mulsi_const */
639 COSTS_N_INSNS (3), /* mulsi_const9 */
640 COSTS_N_INSNS (4), /* muldi */
641 COSTS_N_INSNS (23), /* divsi */
642 COSTS_N_INSNS (23), /* divdi */
643 COSTS_N_INSNS (5), /* fp */
644 COSTS_N_INSNS (5), /* dmul */
645 COSTS_N_INSNS (21), /* sdiv */
646 COSTS_N_INSNS (35), /* ddiv */
647 32, /* cache line size */
653 /* Instruction costs on PPC8540 processors. */
655 struct processor_costs ppc8540_cost = {
656 COSTS_N_INSNS (4), /* mulsi */
657 COSTS_N_INSNS (4), /* mulsi_const */
658 COSTS_N_INSNS (4), /* mulsi_const9 */
659 COSTS_N_INSNS (4), /* muldi */
660 COSTS_N_INSNS (19), /* divsi */
661 COSTS_N_INSNS (19), /* divdi */
662 COSTS_N_INSNS (4), /* fp */
663 COSTS_N_INSNS (4), /* dmul */
664 COSTS_N_INSNS (29), /* sdiv */
665 COSTS_N_INSNS (29), /* ddiv */
666 32, /* cache line size */
669 1, /* prefetch streams /*/
672 /* Instruction costs on E300C2 and E300C3 cores. */
674 struct processor_costs ppce300c2c3_cost = {
675 COSTS_N_INSNS (4), /* mulsi */
676 COSTS_N_INSNS (4), /* mulsi_const */
677 COSTS_N_INSNS (4), /* mulsi_const9 */
678 COSTS_N_INSNS (4), /* muldi */
679 COSTS_N_INSNS (19), /* divsi */
680 COSTS_N_INSNS (19), /* divdi */
681 COSTS_N_INSNS (3), /* fp */
682 COSTS_N_INSNS (4), /* dmul */
683 COSTS_N_INSNS (18), /* sdiv */
684 COSTS_N_INSNS (33), /* ddiv */
688 1, /* prefetch streams /*/
691 /* Instruction costs on POWER4 and POWER5 processors. */
693 struct processor_costs power4_cost = {
694 COSTS_N_INSNS (3), /* mulsi */
695 COSTS_N_INSNS (2), /* mulsi_const */
696 COSTS_N_INSNS (2), /* mulsi_const9 */
697 COSTS_N_INSNS (4), /* muldi */
698 COSTS_N_INSNS (18), /* divsi */
699 COSTS_N_INSNS (34), /* divdi */
700 COSTS_N_INSNS (3), /* fp */
701 COSTS_N_INSNS (3), /* dmul */
702 COSTS_N_INSNS (17), /* sdiv */
703 COSTS_N_INSNS (17), /* ddiv */
704 128, /* cache line size */
707 8, /* prefetch streams /*/
710 /* Instruction costs on POWER6 processors. */
712 struct processor_costs power6_cost = {
713 COSTS_N_INSNS (8), /* mulsi */
714 COSTS_N_INSNS (8), /* mulsi_const */
715 COSTS_N_INSNS (8), /* mulsi_const9 */
716 COSTS_N_INSNS (8), /* muldi */
717 COSTS_N_INSNS (22), /* divsi */
718 COSTS_N_INSNS (28), /* divdi */
719 COSTS_N_INSNS (3), /* fp */
720 COSTS_N_INSNS (3), /* dmul */
721 COSTS_N_INSNS (13), /* sdiv */
722 COSTS_N_INSNS (16), /* ddiv */
723 128, /* cache line size */
726 16, /* prefetch streams */
730 static bool rs6000_function_ok_for_sibcall (tree, tree);
731 static const char *rs6000_invalid_within_doloop (const_rtx);
732 static rtx rs6000_generate_compare (enum rtx_code);
733 static void rs6000_emit_stack_tie (void);
734 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
735 static bool spe_func_has_64bit_regs_p (void);
736 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
738 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
739 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int);
740 static unsigned rs6000_hash_constant (rtx);
741 static unsigned toc_hash_function (const void *);
742 static int toc_hash_eq (const void *, const void *);
743 static int constant_pool_expr_1 (rtx, int *, int *);
744 static bool constant_pool_expr_p (rtx);
745 static bool legitimate_small_data_p (enum machine_mode, rtx);
746 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
747 static struct machine_function * rs6000_init_machine_status (void);
748 static bool rs6000_assemble_integer (rtx, unsigned int, int);
749 static bool no_global_regs_above (int);
750 #ifdef HAVE_GAS_HIDDEN
751 static void rs6000_assemble_visibility (tree, int);
753 static int rs6000_ra_ever_killed (void);
754 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
755 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
756 static bool rs6000_ms_bitfield_layout_p (const_tree);
757 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
758 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
759 static const char *rs6000_mangle_type (const_tree);
760 extern const struct attribute_spec rs6000_attribute_table[];
761 static void rs6000_set_default_type_attributes (tree);
762 static bool rs6000_reg_live_or_pic_offset_p (int);
763 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
764 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
765 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
767 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
768 static bool rs6000_return_in_memory (const_tree, const_tree);
769 static void rs6000_file_start (void);
771 static int rs6000_elf_reloc_rw_mask (void);
772 static void rs6000_elf_asm_out_constructor (rtx, int);
773 static void rs6000_elf_asm_out_destructor (rtx, int);
774 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
775 static void rs6000_elf_asm_init_sections (void);
776 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
777 unsigned HOST_WIDE_INT);
778 static void rs6000_elf_encode_section_info (tree, rtx, int)
781 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
782 static void rs6000_alloc_sdmode_stack_slot (void);
783 static void rs6000_instantiate_decls (void);
785 static void rs6000_xcoff_asm_output_anchor (rtx);
786 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
787 static void rs6000_xcoff_asm_init_sections (void);
788 static int rs6000_xcoff_reloc_rw_mask (void);
789 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
790 static section *rs6000_xcoff_select_section (tree, int,
791 unsigned HOST_WIDE_INT);
792 static void rs6000_xcoff_unique_section (tree, int);
793 static section *rs6000_xcoff_select_rtx_section
794 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
795 static const char * rs6000_xcoff_strip_name_encoding (const char *);
796 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
797 static void rs6000_xcoff_file_start (void);
798 static void rs6000_xcoff_file_end (void);
800 static int rs6000_variable_issue (FILE *, int, rtx, int);
801 static bool rs6000_rtx_costs (rtx, int, int, int *);
802 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
803 static void rs6000_sched_init (FILE *, int, int);
804 static bool is_microcoded_insn (rtx);
805 static bool is_nonpipeline_insn (rtx);
806 static bool is_cracked_insn (rtx);
807 static bool is_branch_slot_insn (rtx);
808 static bool is_load_insn (rtx);
809 static rtx get_store_dest (rtx pat);
810 static bool is_store_insn (rtx);
811 static bool set_to_load_agen (rtx,rtx);
812 static bool adjacent_mem_locations (rtx,rtx);
813 static int rs6000_adjust_priority (rtx, int);
814 static int rs6000_issue_rate (void);
815 static bool rs6000_is_costly_dependence (dep_t, int, int);
816 static rtx get_next_active_insn (rtx, rtx);
817 static bool insn_terminates_group_p (rtx , enum group_termination);
818 static bool insn_must_be_first_in_group (rtx);
819 static bool insn_must_be_last_in_group (rtx);
820 static bool is_costly_group (rtx *, rtx);
821 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
822 static int redefine_groups (FILE *, int, rtx, rtx);
823 static int pad_groups (FILE *, int, rtx, rtx);
824 static void rs6000_sched_finish (FILE *, int);
825 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
826 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
827 static int rs6000_use_sched_lookahead (void);
828 static int rs6000_use_sched_lookahead_guard (rtx);
829 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
830 static tree rs6000_builtin_mask_for_load (void);
831 static tree rs6000_builtin_mul_widen_even (tree);
832 static tree rs6000_builtin_mul_widen_odd (tree);
833 static tree rs6000_builtin_conversion (enum tree_code, tree);
835 static void def_builtin (int, const char *, tree, int);
836 static bool rs6000_vector_alignment_reachable (const_tree, bool);
837 static void rs6000_init_builtins (void);
838 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
839 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
840 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
841 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
842 static void altivec_init_builtins (void);
843 static void rs6000_common_init_builtins (void);
844 static void rs6000_init_libfuncs (void);
846 static void paired_init_builtins (void);
847 static rtx paired_expand_builtin (tree, rtx, bool *);
848 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
849 static rtx paired_expand_stv_builtin (enum insn_code, tree);
850 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
852 static void enable_mask_for_builtins (struct builtin_description *, int,
853 enum rs6000_builtins,
854 enum rs6000_builtins);
855 static tree build_opaque_vector_type (tree, int);
856 static void spe_init_builtins (void);
857 static rtx spe_expand_builtin (tree, rtx, bool *);
858 static rtx spe_expand_stv_builtin (enum insn_code, tree);
859 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
860 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
861 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
862 static rs6000_stack_t *rs6000_stack_info (void);
863 static void debug_stack_info (rs6000_stack_t *);
865 static rtx altivec_expand_builtin (tree, rtx, bool *);
866 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
867 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
868 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
869 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
870 static rtx altivec_expand_predicate_builtin (enum insn_code,
871 const char *, tree, rtx);
872 static rtx altivec_expand_lv_builtin (enum insn_code, tree, rtx);
873 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
874 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
875 static rtx altivec_expand_vec_set_builtin (tree);
876 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
877 static int get_element_number (tree, tree);
878 static bool rs6000_handle_option (size_t, const char *, int);
879 static void rs6000_parse_tls_size_option (void);
880 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
881 static int first_altivec_reg_to_save (void);
882 static unsigned int compute_vrsave_mask (void);
883 static void compute_save_world_info (rs6000_stack_t *info_ptr);
884 static void is_altivec_return_reg (rtx, void *);
885 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
886 int easy_vector_constant (rtx, enum machine_mode);
887 static bool rs6000_is_opaque_type (const_tree);
888 static rtx rs6000_dwarf_register_span (rtx);
889 static void rs6000_init_dwarf_reg_sizes_extra (tree);
890 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
891 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
892 static rtx rs6000_tls_get_addr (void);
893 static rtx rs6000_got_sym (void);
894 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
895 static const char *rs6000_get_some_local_dynamic_name (void);
896 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
897 static rtx rs6000_complex_function_value (enum machine_mode);
898 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
899 enum machine_mode, tree);
900 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
902 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
903 tree, HOST_WIDE_INT);
904 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
907 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
908 const_tree, HOST_WIDE_INT,
910 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
911 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
912 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
913 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
914 enum machine_mode, tree,
916 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
918 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
920 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
922 static void macho_branch_islands (void);
923 static int no_previous_def (tree function_name);
924 static tree get_prev_label (tree function_name);
925 static void rs6000_darwin_file_start (void);
928 static tree rs6000_build_builtin_va_list (void);
929 static void rs6000_va_start (tree, rtx);
930 static tree rs6000_gimplify_va_arg (tree, tree, tree *, tree *);
931 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
932 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
933 static bool rs6000_vector_mode_supported_p (enum machine_mode);
934 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
936 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
938 static int get_vsel_insn (enum machine_mode);
939 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
940 static tree rs6000_stack_protect_fail (void);
942 const int INSN_NOT_AVAILABLE = -1;
943 static enum machine_mode rs6000_eh_return_filter_mode (void);
945 /* Hash table stuff for keeping track of TOC entries. */
947 struct toc_hash_struct GTY(())
949 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
950 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
952 enum machine_mode key_mode;
956 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
958 /* Default register names. */
959 char rs6000_reg_names[][8] =
961 "0", "1", "2", "3", "4", "5", "6", "7",
962 "8", "9", "10", "11", "12", "13", "14", "15",
963 "16", "17", "18", "19", "20", "21", "22", "23",
964 "24", "25", "26", "27", "28", "29", "30", "31",
965 "0", "1", "2", "3", "4", "5", "6", "7",
966 "8", "9", "10", "11", "12", "13", "14", "15",
967 "16", "17", "18", "19", "20", "21", "22", "23",
968 "24", "25", "26", "27", "28", "29", "30", "31",
969 "mq", "lr", "ctr","ap",
970 "0", "1", "2", "3", "4", "5", "6", "7",
972 /* AltiVec registers. */
973 "0", "1", "2", "3", "4", "5", "6", "7",
974 "8", "9", "10", "11", "12", "13", "14", "15",
975 "16", "17", "18", "19", "20", "21", "22", "23",
976 "24", "25", "26", "27", "28", "29", "30", "31",
979 "spe_acc", "spefscr",
980 /* Soft frame pointer. */
984 #ifdef TARGET_REGNAMES
985 static const char alt_reg_names[][8] =
987 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
988 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
989 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
990 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
991 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
992 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
993 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
994 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
995 "mq", "lr", "ctr", "ap",
996 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
998 /* AltiVec registers. */
999 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1000 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1001 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1002 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1004 /* SPE registers. */
1005 "spe_acc", "spefscr",
1006 /* Soft frame pointer. */
1011 #ifndef MASK_STRICT_ALIGN
1012 #define MASK_STRICT_ALIGN 0
1014 #ifndef TARGET_PROFILE_KERNEL
1015 #define TARGET_PROFILE_KERNEL 0
1018 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1019 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1021 /* Initialize the GCC target structure. */
1022 #undef TARGET_ATTRIBUTE_TABLE
1023 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1024 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1025 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1027 #undef TARGET_ASM_ALIGNED_DI_OP
1028 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1030 /* Default unaligned ops are only provided for ELF. Find the ops needed
1031 for non-ELF systems. */
1032 #ifndef OBJECT_FORMAT_ELF
1034 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1036 #undef TARGET_ASM_UNALIGNED_HI_OP
1037 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1038 #undef TARGET_ASM_UNALIGNED_SI_OP
1039 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1040 #undef TARGET_ASM_UNALIGNED_DI_OP
1041 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1044 #undef TARGET_ASM_UNALIGNED_HI_OP
1045 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1046 #undef TARGET_ASM_UNALIGNED_SI_OP
1047 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1048 #undef TARGET_ASM_UNALIGNED_DI_OP
1049 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1050 #undef TARGET_ASM_ALIGNED_DI_OP
1051 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1055 /* This hook deals with fixups for relocatable code and DI-mode objects
1057 #undef TARGET_ASM_INTEGER
1058 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1060 #ifdef HAVE_GAS_HIDDEN
1061 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1062 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1065 #undef TARGET_HAVE_TLS
1066 #define TARGET_HAVE_TLS HAVE_AS_TLS
1068 #undef TARGET_CANNOT_FORCE_CONST_MEM
1069 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1071 #undef TARGET_ASM_FUNCTION_PROLOGUE
1072 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1073 #undef TARGET_ASM_FUNCTION_EPILOGUE
1074 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1076 #undef TARGET_SCHED_VARIABLE_ISSUE
1077 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1079 #undef TARGET_SCHED_ISSUE_RATE
1080 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1081 #undef TARGET_SCHED_ADJUST_COST
1082 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1083 #undef TARGET_SCHED_ADJUST_PRIORITY
1084 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1085 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1086 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1087 #undef TARGET_SCHED_INIT
1088 #define TARGET_SCHED_INIT rs6000_sched_init
1089 #undef TARGET_SCHED_FINISH
1090 #define TARGET_SCHED_FINISH rs6000_sched_finish
1091 #undef TARGET_SCHED_REORDER
1092 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1093 #undef TARGET_SCHED_REORDER2
1094 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1096 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1097 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1099 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1100 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1102 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1103 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1104 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1105 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1106 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1107 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1108 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1109 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1111 #undef TARGET_VECTOR_ALIGNMENT_REACHABLE
1112 #define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1114 #undef TARGET_INIT_BUILTINS
1115 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1117 #undef TARGET_EXPAND_BUILTIN
1118 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1120 #undef TARGET_MANGLE_TYPE
1121 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1123 #undef TARGET_INIT_LIBFUNCS
1124 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1127 #undef TARGET_BINDS_LOCAL_P
1128 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1131 #undef TARGET_MS_BITFIELD_LAYOUT_P
1132 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1134 #undef TARGET_ASM_OUTPUT_MI_THUNK
1135 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1137 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1138 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1140 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1141 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1143 #undef TARGET_INVALID_WITHIN_DOLOOP
1144 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1146 #undef TARGET_RTX_COSTS
1147 #define TARGET_RTX_COSTS rs6000_rtx_costs
1148 #undef TARGET_ADDRESS_COST
1149 #define TARGET_ADDRESS_COST hook_int_rtx_0
1151 #undef TARGET_VECTOR_OPAQUE_P
1152 #define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
1154 #undef TARGET_DWARF_REGISTER_SPAN
1155 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1157 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1158 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1160 /* On rs6000, function arguments are promoted, as are function return
1162 #undef TARGET_PROMOTE_FUNCTION_ARGS
1163 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true
1164 #undef TARGET_PROMOTE_FUNCTION_RETURN
1165 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true
1167 #undef TARGET_RETURN_IN_MEMORY
1168 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1170 #undef TARGET_SETUP_INCOMING_VARARGS
1171 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1173 /* Always strict argument naming on rs6000. */
1174 #undef TARGET_STRICT_ARGUMENT_NAMING
1175 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1176 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1177 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1178 #undef TARGET_SPLIT_COMPLEX_ARG
1179 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1180 #undef TARGET_MUST_PASS_IN_STACK
1181 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1182 #undef TARGET_PASS_BY_REFERENCE
1183 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1184 #undef TARGET_ARG_PARTIAL_BYTES
1185 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1187 #undef TARGET_BUILD_BUILTIN_VA_LIST
1188 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1190 #undef TARGET_EXPAND_BUILTIN_VA_START
1191 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1193 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1194 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1196 #undef TARGET_EH_RETURN_FILTER_MODE
1197 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1199 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1200 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1202 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1203 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1205 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1206 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1208 #undef TARGET_HANDLE_OPTION
1209 #define TARGET_HANDLE_OPTION rs6000_handle_option
1211 #undef TARGET_DEFAULT_TARGET_FLAGS
1212 #define TARGET_DEFAULT_TARGET_FLAGS \
1215 #undef TARGET_STACK_PROTECT_FAIL
1216 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1218 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1219 The PowerPC architecture requires only weak consistency among
1220 processors--that is, memory accesses between processors need not be
1221 sequentially consistent and memory accesses among processors can occur
1222 in any order. The ability to order memory accesses weakly provides
1223 opportunities for more efficient use of the system bus. Unless a
1224 dependency exists, the 604e allows read operations to precede store
1226 #undef TARGET_RELAXED_ORDERING
1227 #define TARGET_RELAXED_ORDERING true
1230 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1231 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1234 /* Use a 32-bit anchor range. This leads to sequences like:
1236 addis tmp,anchor,high
1239 where tmp itself acts as an anchor, and can be shared between
1240 accesses to the same 64k page. */
1241 #undef TARGET_MIN_ANCHOR_OFFSET
1242 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1243 #undef TARGET_MAX_ANCHOR_OFFSET
1244 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1245 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1246 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1248 #undef TARGET_BUILTIN_RECIPROCAL
1249 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1251 #undef TARGET_EXPAND_TO_RTL_HOOK
1252 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1254 #undef TARGET_INSTANTIATE_DECLS
1255 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1257 struct gcc_target targetm = TARGET_INITIALIZER;
1260 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1263 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1265 /* The GPRs can hold any mode, but values bigger than one register
1266 cannot go past R31. */
1267 if (INT_REGNO_P (regno))
1268 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1270 /* The float registers can only hold floating modes and DImode.
1271 This excludes the 32-bit decimal float mode for now. */
1272 if (FP_REGNO_P (regno))
1274 ((SCALAR_FLOAT_MODE_P (mode)
1275 && (mode != TDmode || (regno % 2) == 0)
1276 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1277 || (GET_MODE_CLASS (mode) == MODE_INT
1278 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1279 || (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1280 && PAIRED_VECTOR_MODE (mode)));
1282 /* The CR register can only hold CC modes. */
1283 if (CR_REGNO_P (regno))
1284 return GET_MODE_CLASS (mode) == MODE_CC;
1286 if (XER_REGNO_P (regno))
1287 return mode == PSImode;
1289 /* AltiVec only in AldyVec registers. */
1290 if (ALTIVEC_REGNO_P (regno))
1291 return ALTIVEC_VECTOR_MODE (mode);
1293 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1294 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1297 /* We cannot put TImode anywhere except general register and it must be
1298 able to fit within the register set. */
1300 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1303 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1305 rs6000_init_hard_regno_mode_ok (void)
1309 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1310 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1311 if (rs6000_hard_regno_mode_ok (r, m))
1312 rs6000_hard_regno_mode_ok_p[m][r] = true;
1316 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
1319 darwin_rs6000_override_options (void)
1321 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
1323 rs6000_altivec_abi = 1;
1324 TARGET_ALTIVEC_VRSAVE = 1;
1325 if (DEFAULT_ABI == ABI_DARWIN)
1327 if (MACHO_DYNAMIC_NO_PIC_P)
1330 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
1333 else if (flag_pic == 1)
1338 if (TARGET_64BIT && ! TARGET_POWERPC64)
1340 target_flags |= MASK_POWERPC64;
1341 warning (0, "-m64 requires PowerPC64 architecture, enabling");
1345 rs6000_default_long_calls = 1;
1346 target_flags |= MASK_SOFT_FLOAT;
1349 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
1351 if (!flag_mkernel && !flag_apple_kext
1353 && ! (target_flags_explicit & MASK_ALTIVEC))
1354 target_flags |= MASK_ALTIVEC;
1356 /* Unless the user (not the configurer) has explicitly overridden
1357 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
1358 G4 unless targetting the kernel. */
1361 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
1362 && ! (target_flags_explicit & MASK_ALTIVEC)
1363 && ! rs6000_select[1].string)
1365 target_flags |= MASK_ALTIVEC;
1370 /* If not otherwise specified by a target, make 'long double' equivalent to
1373 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1374 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1377 /* Override command line options. Mostly we process the processor
1378 type and sometimes adjust other TARGET_ options. */
1381 rs6000_override_options (const char *default_cpu)
1384 struct rs6000_cpu_select *ptr;
1387 /* Simplifications for entries below. */
1390 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1391 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1394 /* This table occasionally claims that a processor does not support
1395 a particular feature even though it does, but the feature is slower
1396 than the alternative. Thus, it shouldn't be relied on as a
1397 complete description of the processor's support.
1399 Please keep this list in order, and don't forget to update the
1400 documentation in invoke.texi when adding a new processor or
1404 const char *const name; /* Canonical processor name. */
1405 const enum processor_type processor; /* Processor type enum value. */
1406 const int target_enable; /* Target flags to enable. */
1407 } const processor_target_table[]
1408 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1409 {"403", PROCESSOR_PPC403,
1410 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1411 {"405", PROCESSOR_PPC405,
1412 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1413 {"405fp", PROCESSOR_PPC405,
1414 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1415 {"440", PROCESSOR_PPC440,
1416 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1417 {"440fp", PROCESSOR_PPC440,
1418 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1419 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1420 {"601", PROCESSOR_PPC601,
1421 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1422 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1423 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1424 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1425 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1426 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1427 {"620", PROCESSOR_PPC620,
1428 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1429 {"630", PROCESSOR_PPC630,
1430 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1431 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1432 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1433 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1434 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1435 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1436 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1437 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1438 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
1439 /* 8548 has a dummy entry for now. */
1440 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
1441 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1442 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
1443 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1444 {"970", PROCESSOR_POWER4,
1445 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1446 {"cell", PROCESSOR_CELL,
1447 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1448 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1449 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1450 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1451 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1452 {"G5", PROCESSOR_POWER4,
1453 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1454 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1455 {"power2", PROCESSOR_POWER,
1456 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1457 {"power3", PROCESSOR_PPC630,
1458 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1459 {"power4", PROCESSOR_POWER4,
1460 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1461 {"power5", PROCESSOR_POWER5,
1462 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1463 | MASK_MFCRF | MASK_POPCNTB},
1464 {"power5+", PROCESSOR_POWER5,
1465 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1466 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1467 {"power6", PROCESSOR_POWER6,
1468 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1469 | MASK_FPRND | MASK_CMPB | MASK_DFP },
1470 {"power6x", PROCESSOR_POWER6,
1471 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1472 | MASK_FPRND | MASK_CMPB | MASK_MFPGPR | MASK_DFP },
1473 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1474 {"powerpc64", PROCESSOR_POWERPC64,
1475 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1476 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1477 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1478 {"rios2", PROCESSOR_RIOS2,
1479 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1480 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1481 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1482 {"rs64", PROCESSOR_RS64A,
1483 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1486 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1488 /* Some OSs don't support saving the high part of 64-bit registers on
1489 context switch. Other OSs don't support saving Altivec registers.
1490 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1491 settings; if the user wants either, the user must explicitly specify
1492 them and we won't interfere with the user's specification. */
1495 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1496 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1497 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1498 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1499 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP)
1502 rs6000_init_hard_regno_mode_ok ();
1504 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1505 #ifdef OS_MISSING_POWERPC64
1506 if (OS_MISSING_POWERPC64)
1507 set_masks &= ~MASK_POWERPC64;
1509 #ifdef OS_MISSING_ALTIVEC
1510 if (OS_MISSING_ALTIVEC)
1511 set_masks &= ~MASK_ALTIVEC;
1514 /* Don't override by the processor default if given explicitly. */
1515 set_masks &= ~target_flags_explicit;
1517 /* Identify the processor type. */
1518 rs6000_select[0].string = default_cpu;
1519 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1521 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1523 ptr = &rs6000_select[i];
1524 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1526 for (j = 0; j < ptt_size; j++)
1527 if (! strcmp (ptr->string, processor_target_table[j].name))
1529 if (ptr->set_tune_p)
1530 rs6000_cpu = processor_target_table[j].processor;
1532 if (ptr->set_arch_p)
1534 target_flags &= ~set_masks;
1535 target_flags |= (processor_target_table[j].target_enable
1542 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1549 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3)
1552 error ("AltiVec not supported in this target");
1554 error ("Spe not supported in this target");
1557 /* If we are optimizing big endian systems for space, use the load/store
1558 multiple and string instructions. */
1559 if (BYTES_BIG_ENDIAN && optimize_size)
1560 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1562 /* Don't allow -mmultiple or -mstring on little endian systems
1563 unless the cpu is a 750, because the hardware doesn't support the
1564 instructions used in little endian mode, and causes an alignment
1565 trap. The 750 does not cause an alignment trap (except when the
1566 target is unaligned). */
1568 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1570 if (TARGET_MULTIPLE)
1572 target_flags &= ~MASK_MULTIPLE;
1573 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1574 warning (0, "-mmultiple is not supported on little endian systems");
1579 target_flags &= ~MASK_STRING;
1580 if ((target_flags_explicit & MASK_STRING) != 0)
1581 warning (0, "-mstring is not supported on little endian systems");
1585 /* Set debug flags */
1586 if (rs6000_debug_name)
1588 if (! strcmp (rs6000_debug_name, "all"))
1589 rs6000_debug_stack = rs6000_debug_arg = 1;
1590 else if (! strcmp (rs6000_debug_name, "stack"))
1591 rs6000_debug_stack = 1;
1592 else if (! strcmp (rs6000_debug_name, "arg"))
1593 rs6000_debug_arg = 1;
1595 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1598 if (rs6000_traceback_name)
1600 if (! strncmp (rs6000_traceback_name, "full", 4))
1601 rs6000_traceback = traceback_full;
1602 else if (! strncmp (rs6000_traceback_name, "part", 4))
1603 rs6000_traceback = traceback_part;
1604 else if (! strncmp (rs6000_traceback_name, "no", 2))
1605 rs6000_traceback = traceback_none;
1607 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1608 rs6000_traceback_name);
1611 if (!rs6000_explicit_options.long_double)
1612 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1614 #ifndef POWERPC_LINUX
1615 if (!rs6000_explicit_options.ieee)
1616 rs6000_ieeequad = 1;
1619 /* Enable Altivec ABI for AIX -maltivec. */
1620 if (TARGET_XCOFF && TARGET_ALTIVEC)
1621 rs6000_altivec_abi = 1;
1623 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
1624 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
1625 be explicitly overridden in either case. */
1628 if (!rs6000_explicit_options.altivec_abi
1629 && (TARGET_64BIT || TARGET_ALTIVEC))
1630 rs6000_altivec_abi = 1;
1632 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
1633 if (!rs6000_explicit_options.vrsave)
1634 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
1637 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1638 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1640 rs6000_darwin64_abi = 1;
1642 darwin_one_byte_bool = 1;
1644 /* Default to natural alignment, for better performance. */
1645 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1648 /* Place FP constants in the constant pool instead of TOC
1649 if section anchors enabled. */
1650 if (flag_section_anchors)
1651 TARGET_NO_FP_IN_TOC = 1;
1653 /* Handle -mtls-size option. */
1654 rs6000_parse_tls_size_option ();
1656 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1657 SUBTARGET_OVERRIDE_OPTIONS;
1659 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1660 SUBSUBTARGET_OVERRIDE_OPTIONS;
1662 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1663 SUB3TARGET_OVERRIDE_OPTIONS;
1668 /* The e500 does not have string instructions, and we set
1669 MASK_STRING above when optimizing for size. */
1670 if ((target_flags & MASK_STRING) != 0)
1671 target_flags = target_flags & ~MASK_STRING;
1673 else if (rs6000_select[1].string != NULL)
1675 /* For the powerpc-eabispe configuration, we set all these by
1676 default, so let's unset them if we manually set another
1677 CPU that is not the E500. */
1678 if (!rs6000_explicit_options.spe_abi)
1680 if (!rs6000_explicit_options.spe)
1682 if (!rs6000_explicit_options.float_gprs)
1683 rs6000_float_gprs = 0;
1684 if (!rs6000_explicit_options.isel)
1688 /* Detect invalid option combinations with E500. */
1691 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1692 && rs6000_cpu != PROCESSOR_POWER5
1693 && rs6000_cpu != PROCESSOR_POWER6
1694 && rs6000_cpu != PROCESSOR_CELL);
1695 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1696 || rs6000_cpu == PROCESSOR_POWER5);
1697 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
1698 || rs6000_cpu == PROCESSOR_POWER5
1699 || rs6000_cpu == PROCESSOR_POWER6);
1701 rs6000_sched_restricted_insns_priority
1702 = (rs6000_sched_groups ? 1 : 0);
1704 /* Handle -msched-costly-dep option. */
1705 rs6000_sched_costly_dep
1706 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1708 if (rs6000_sched_costly_dep_str)
1710 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1711 rs6000_sched_costly_dep = no_dep_costly;
1712 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1713 rs6000_sched_costly_dep = all_deps_costly;
1714 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1715 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1716 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1717 rs6000_sched_costly_dep = store_to_load_dep_costly;
1719 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1722 /* Handle -minsert-sched-nops option. */
1723 rs6000_sched_insert_nops
1724 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1726 if (rs6000_sched_insert_nops_str)
1728 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1729 rs6000_sched_insert_nops = sched_finish_none;
1730 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1731 rs6000_sched_insert_nops = sched_finish_pad_groups;
1732 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1733 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1735 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1738 #ifdef TARGET_REGNAMES
1739 /* If the user desires alternate register names, copy in the
1740 alternate names now. */
1741 if (TARGET_REGNAMES)
1742 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1745 /* Set aix_struct_return last, after the ABI is determined.
1746 If -maix-struct-return or -msvr4-struct-return was explicitly
1747 used, don't override with the ABI default. */
1748 if (!rs6000_explicit_options.aix_struct_ret)
1749 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
1751 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
1752 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1755 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1757 /* We can only guarantee the availability of DI pseudo-ops when
1758 assembling for 64-bit targets. */
1761 targetm.asm_out.aligned_op.di = NULL;
1762 targetm.asm_out.unaligned_op.di = NULL;
1765 /* Set branch target alignment, if not optimizing for size. */
1768 /* Cell wants to be aligned 8byte for dual issue. */
1769 if (rs6000_cpu == PROCESSOR_CELL)
1771 if (align_functions <= 0)
1772 align_functions = 8;
1773 if (align_jumps <= 0)
1775 if (align_loops <= 0)
1778 if (rs6000_align_branch_targets)
1780 if (align_functions <= 0)
1781 align_functions = 16;
1782 if (align_jumps <= 0)
1784 if (align_loops <= 0)
1787 if (align_jumps_max_skip <= 0)
1788 align_jumps_max_skip = 15;
1789 if (align_loops_max_skip <= 0)
1790 align_loops_max_skip = 15;
1793 /* Arrange to save and restore machine status around nested functions. */
1794 init_machine_status = rs6000_init_machine_status;
1796 /* We should always be splitting complex arguments, but we can't break
1797 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1798 if (DEFAULT_ABI != ABI_AIX)
1799 targetm.calls.split_complex_arg = NULL;
1801 /* Initialize rs6000_cost with the appropriate target costs. */
1803 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1807 case PROCESSOR_RIOS1:
1808 rs6000_cost = &rios1_cost;
1811 case PROCESSOR_RIOS2:
1812 rs6000_cost = &rios2_cost;
1815 case PROCESSOR_RS64A:
1816 rs6000_cost = &rs64a_cost;
1819 case PROCESSOR_MPCCORE:
1820 rs6000_cost = &mpccore_cost;
1823 case PROCESSOR_PPC403:
1824 rs6000_cost = &ppc403_cost;
1827 case PROCESSOR_PPC405:
1828 rs6000_cost = &ppc405_cost;
1831 case PROCESSOR_PPC440:
1832 rs6000_cost = &ppc440_cost;
1835 case PROCESSOR_PPC601:
1836 rs6000_cost = &ppc601_cost;
1839 case PROCESSOR_PPC603:
1840 rs6000_cost = &ppc603_cost;
1843 case PROCESSOR_PPC604:
1844 rs6000_cost = &ppc604_cost;
1847 case PROCESSOR_PPC604e:
1848 rs6000_cost = &ppc604e_cost;
1851 case PROCESSOR_PPC620:
1852 rs6000_cost = &ppc620_cost;
1855 case PROCESSOR_PPC630:
1856 rs6000_cost = &ppc630_cost;
1859 case PROCESSOR_CELL:
1860 rs6000_cost = &ppccell_cost;
1863 case PROCESSOR_PPC750:
1864 case PROCESSOR_PPC7400:
1865 rs6000_cost = &ppc750_cost;
1868 case PROCESSOR_PPC7450:
1869 rs6000_cost = &ppc7450_cost;
1872 case PROCESSOR_PPC8540:
1873 rs6000_cost = &ppc8540_cost;
1876 case PROCESSOR_PPCE300C2:
1877 case PROCESSOR_PPCE300C3:
1878 rs6000_cost = &ppce300c2c3_cost;
1881 case PROCESSOR_POWER4:
1882 case PROCESSOR_POWER5:
1883 rs6000_cost = &power4_cost;
1886 case PROCESSOR_POWER6:
1887 rs6000_cost = &power6_cost;
1894 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
1895 set_param_value ("simultaneous-prefetches",
1896 rs6000_cost->simultaneous_prefetches);
1897 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
1898 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
1899 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
1900 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
1901 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
1902 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
1904 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
1905 can be optimized to ap = __builtin_next_arg (0). */
1906 if (DEFAULT_ABI != ABI_V4)
1907 targetm.expand_builtin_va_start = NULL;
1910 /* Implement targetm.vectorize.builtin_mask_for_load. */
1912 rs6000_builtin_mask_for_load (void)
1915 return altivec_builtin_mask_for_load;
1920 /* Implement targetm.vectorize.builtin_conversion. */
1922 rs6000_builtin_conversion (enum tree_code code, tree type)
1924 if (!TARGET_ALTIVEC)
1930 switch (TYPE_MODE (type))
1933 return TYPE_UNSIGNED (type) ?
1934 rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFUX] :
1935 rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFSX];
1944 /* Implement targetm.vectorize.builtin_mul_widen_even. */
1946 rs6000_builtin_mul_widen_even (tree type)
1948 if (!TARGET_ALTIVEC)
1951 switch (TYPE_MODE (type))
1954 return TYPE_UNSIGNED (type) ?
1955 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH] :
1956 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
1959 return TYPE_UNSIGNED (type) ?
1960 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB] :
1961 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
1967 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
1969 rs6000_builtin_mul_widen_odd (tree type)
1971 if (!TARGET_ALTIVEC)
1974 switch (TYPE_MODE (type))
1977 return TYPE_UNSIGNED (type) ?
1978 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH] :
1979 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
1982 return TYPE_UNSIGNED (type) ?
1983 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB] :
1984 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
1991 /* Return true iff, data reference of TYPE can reach vector alignment (16)
1992 after applying N number of iterations. This routine does not determine
1993 how may iterations are required to reach desired alignment. */
1996 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
2003 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
2006 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
2016 /* Assuming that all other types are naturally aligned. CHECKME! */
2021 /* Handle generic options of the form -mfoo=yes/no.
2022 NAME is the option name.
2023 VALUE is the option value.
2024 FLAG is the pointer to the flag where to store a 1 or 0, depending on
2025 whether the option value is 'yes' or 'no' respectively. */
2027 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
2031 else if (!strcmp (value, "yes"))
2033 else if (!strcmp (value, "no"))
2036 error ("unknown -m%s= option specified: '%s'", name, value);
2039 /* Validate and record the size specified with the -mtls-size option. */
2042 rs6000_parse_tls_size_option (void)
2044 if (rs6000_tls_size_string == 0)
2046 else if (strcmp (rs6000_tls_size_string, "16") == 0)
2047 rs6000_tls_size = 16;
2048 else if (strcmp (rs6000_tls_size_string, "32") == 0)
2049 rs6000_tls_size = 32;
2050 else if (strcmp (rs6000_tls_size_string, "64") == 0)
2051 rs6000_tls_size = 64;
2053 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
2057 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
2059 if (DEFAULT_ABI == ABI_DARWIN)
2060 /* The Darwin libraries never set errno, so we might as well
2061 avoid calling them when that's the only reason we would. */
2062 flag_errno_math = 0;
2064 /* Double growth factor to counter reduced min jump length. */
2065 set_param_value ("max-grow-copy-bb-insns", 16);
2067 /* Enable section anchors by default.
2068 Skip section anchors for Objective C and Objective C++
2069 until front-ends fixed. */
2070 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
2071 flag_section_anchors = 1;
2074 /* Implement TARGET_HANDLE_OPTION. */
2077 rs6000_handle_option (size_t code, const char *arg, int value)
2082 target_flags &= ~(MASK_POWER | MASK_POWER2
2083 | MASK_MULTIPLE | MASK_STRING);
2084 target_flags_explicit |= (MASK_POWER | MASK_POWER2
2085 | MASK_MULTIPLE | MASK_STRING);
2087 case OPT_mno_powerpc:
2088 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
2089 | MASK_PPC_GFXOPT | MASK_POWERPC64);
2090 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
2091 | MASK_PPC_GFXOPT | MASK_POWERPC64);
2094 target_flags &= ~MASK_MINIMAL_TOC;
2095 TARGET_NO_FP_IN_TOC = 0;
2096 TARGET_NO_SUM_IN_TOC = 0;
2097 target_flags_explicit |= MASK_MINIMAL_TOC;
2098 #ifdef TARGET_USES_SYSV4_OPT
2099 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
2100 just the same as -mminimal-toc. */
2101 target_flags |= MASK_MINIMAL_TOC;
2102 target_flags_explicit |= MASK_MINIMAL_TOC;
2106 #ifdef TARGET_USES_SYSV4_OPT
2108 /* Make -mtoc behave like -mminimal-toc. */
2109 target_flags |= MASK_MINIMAL_TOC;
2110 target_flags_explicit |= MASK_MINIMAL_TOC;
2114 #ifdef TARGET_USES_AIX64_OPT
2119 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
2120 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
2121 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
2124 #ifdef TARGET_USES_AIX64_OPT
2129 target_flags &= ~MASK_POWERPC64;
2130 target_flags_explicit |= MASK_POWERPC64;
2133 case OPT_minsert_sched_nops_:
2134 rs6000_sched_insert_nops_str = arg;
2137 case OPT_mminimal_toc:
2140 TARGET_NO_FP_IN_TOC = 0;
2141 TARGET_NO_SUM_IN_TOC = 0;
2148 target_flags |= (MASK_MULTIPLE | MASK_STRING);
2149 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
2156 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
2157 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
2161 case OPT_mpowerpc_gpopt:
2162 case OPT_mpowerpc_gfxopt:
2165 target_flags |= MASK_POWERPC;
2166 target_flags_explicit |= MASK_POWERPC;
2170 case OPT_maix_struct_return:
2171 case OPT_msvr4_struct_return:
2172 rs6000_explicit_options.aix_struct_ret = true;
2176 rs6000_explicit_options.vrsave = true;
2177 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
2181 rs6000_explicit_options.isel = true;
2182 rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
2186 rs6000_explicit_options.spe = true;
2187 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
2191 rs6000_debug_name = arg;
2194 #ifdef TARGET_USES_SYSV4_OPT
2196 rs6000_abi_name = arg;
2200 rs6000_sdata_name = arg;
2203 case OPT_mtls_size_:
2204 rs6000_tls_size_string = arg;
2207 case OPT_mrelocatable:
2210 target_flags |= MASK_MINIMAL_TOC;
2211 target_flags_explicit |= MASK_MINIMAL_TOC;
2212 TARGET_NO_FP_IN_TOC = 1;
2216 case OPT_mrelocatable_lib:
2219 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2220 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2221 TARGET_NO_FP_IN_TOC = 1;
2225 target_flags &= ~MASK_RELOCATABLE;
2226 target_flags_explicit |= MASK_RELOCATABLE;
2232 if (!strcmp (arg, "altivec"))
2234 rs6000_explicit_options.altivec_abi = true;
2235 rs6000_altivec_abi = 1;
2237 /* Enabling the AltiVec ABI turns off the SPE ABI. */
2240 else if (! strcmp (arg, "no-altivec"))
2242 rs6000_explicit_options.altivec_abi = true;
2243 rs6000_altivec_abi = 0;
2245 else if (! strcmp (arg, "spe"))
2247 rs6000_explicit_options.spe_abi = true;
2249 rs6000_altivec_abi = 0;
2250 if (!TARGET_SPE_ABI)
2251 error ("not configured for ABI: '%s'", arg);
2253 else if (! strcmp (arg, "no-spe"))
2255 rs6000_explicit_options.spe_abi = true;
2259 /* These are here for testing during development only, do not
2260 document in the manual please. */
2261 else if (! strcmp (arg, "d64"))
2263 rs6000_darwin64_abi = 1;
2264 warning (0, "Using darwin64 ABI");
2266 else if (! strcmp (arg, "d32"))
2268 rs6000_darwin64_abi = 0;
2269 warning (0, "Using old darwin ABI");
2272 else if (! strcmp (arg, "ibmlongdouble"))
2274 rs6000_explicit_options.ieee = true;
2275 rs6000_ieeequad = 0;
2276 warning (0, "Using IBM extended precision long double");
2278 else if (! strcmp (arg, "ieeelongdouble"))
2280 rs6000_explicit_options.ieee = true;
2281 rs6000_ieeequad = 1;
2282 warning (0, "Using IEEE extended precision long double");
2287 error ("unknown ABI specified: '%s'", arg);
2293 rs6000_select[1].string = arg;
2297 rs6000_select[2].string = arg;
2300 case OPT_mtraceback_:
2301 rs6000_traceback_name = arg;
2304 case OPT_mfloat_gprs_:
2305 rs6000_explicit_options.float_gprs = true;
2306 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
2307 rs6000_float_gprs = 1;
2308 else if (! strcmp (arg, "double"))
2309 rs6000_float_gprs = 2;
2310 else if (! strcmp (arg, "no"))
2311 rs6000_float_gprs = 0;
2314 error ("invalid option for -mfloat-gprs: '%s'", arg);
2319 case OPT_mlong_double_:
2320 rs6000_explicit_options.long_double = true;
2321 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2322 if (value != 64 && value != 128)
2324 error ("Unknown switch -mlong-double-%s", arg);
2325 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2329 rs6000_long_double_type_size = value;
2332 case OPT_msched_costly_dep_:
2333 rs6000_sched_costly_dep_str = arg;
2337 rs6000_explicit_options.alignment = true;
2338 if (! strcmp (arg, "power"))
2340 /* On 64-bit Darwin, power alignment is ABI-incompatible with
2341 some C library functions, so warn about it. The flag may be
2342 useful for performance studies from time to time though, so
2343 don't disable it entirely. */
2344 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2345 warning (0, "-malign-power is not supported for 64-bit Darwin;"
2346 " it is incompatible with the installed C and C++ libraries");
2347 rs6000_alignment_flags = MASK_ALIGN_POWER;
2349 else if (! strcmp (arg, "natural"))
2350 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2353 error ("unknown -malign-XXXXX option specified: '%s'", arg);
2361 /* Do anything needed at the start of the asm file. */
2364 rs6000_file_start (void)
2368 const char *start = buffer;
2369 struct rs6000_cpu_select *ptr;
2370 const char *default_cpu = TARGET_CPU_DEFAULT;
2371 FILE *file = asm_out_file;
2373 default_file_start ();
2375 #ifdef TARGET_BI_ARCH
2376 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
2380 if (flag_verbose_asm)
2382 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
2383 rs6000_select[0].string = default_cpu;
2385 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2387 ptr = &rs6000_select[i];
2388 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2390 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
2395 if (PPC405_ERRATUM77)
2397 fprintf (file, "%s PPC405CR_ERRATUM77", start);
2401 #ifdef USING_ELFOS_H
2402 switch (rs6000_sdata)
2404 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
2405 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
2406 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
2407 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
2410 if (rs6000_sdata && g_switch_value)
2412 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
2422 #ifdef HAVE_AS_GNU_ATTRIBUTE
2423 if (TARGET_32BIT && DEFAULT_ABI == ABI_V4)
2425 fprintf (file, "\t.gnu_attribute 4, %d\n",
2426 (TARGET_HARD_FLOAT && TARGET_FPRS) ? 1 : 2);
2427 fprintf (file, "\t.gnu_attribute 8, %d\n",
2428 (TARGET_ALTIVEC_ABI ? 2
2429 : TARGET_SPE_ABI ? 3
2434 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
2436 switch_to_section (toc_section);
2437 switch_to_section (text_section);
2442 /* Return nonzero if this function is known to have a null epilogue. */
2445 direct_return (void)
2447 if (reload_completed)
2449 rs6000_stack_t *info = rs6000_stack_info ();
2451 if (info->first_gp_reg_save == 32
2452 && info->first_fp_reg_save == 64
2453 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
2454 && ! info->lr_save_p
2455 && ! info->cr_save_p
2456 && info->vrsave_mask == 0
2464 /* Return the number of instructions it takes to form a constant in an
2465 integer register. */
2468 num_insns_constant_wide (HOST_WIDE_INT value)
2470 /* signed constant loadable with {cal|addi} */
2471 if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000)
2474 /* constant loadable with {cau|addis} */
2475 else if ((value & 0xffff) == 0
2476 && (value >> 31 == -1 || value >> 31 == 0))
2479 #if HOST_BITS_PER_WIDE_INT == 64
2480 else if (TARGET_POWERPC64)
2482 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
2483 HOST_WIDE_INT high = value >> 31;
2485 if (high == 0 || high == -1)
2491 return num_insns_constant_wide (high) + 1;
2493 return (num_insns_constant_wide (high)
2494 + num_insns_constant_wide (low) + 1);
2503 num_insns_constant (rtx op, enum machine_mode mode)
2505 HOST_WIDE_INT low, high;
2507 switch (GET_CODE (op))
2510 #if HOST_BITS_PER_WIDE_INT == 64
2511 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
2512 && mask64_operand (op, mode))
2516 return num_insns_constant_wide (INTVAL (op));
2519 if (mode == SFmode || mode == SDmode)
2524 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2525 if (DECIMAL_FLOAT_MODE_P (mode))
2526 REAL_VALUE_TO_TARGET_DECIMAL32 (rv, l);
2528 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
2529 return num_insns_constant_wide ((HOST_WIDE_INT) l);
2532 if (mode == VOIDmode || mode == DImode)
2534 high = CONST_DOUBLE_HIGH (op);
2535 low = CONST_DOUBLE_LOW (op);
2542 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2543 if (DECIMAL_FLOAT_MODE_P (mode))
2544 REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
2546 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
2547 high = l[WORDS_BIG_ENDIAN == 0];
2548 low = l[WORDS_BIG_ENDIAN != 0];
2552 return (num_insns_constant_wide (low)
2553 + num_insns_constant_wide (high));
2556 if ((high == 0 && low >= 0)
2557 || (high == -1 && low < 0))
2558 return num_insns_constant_wide (low);
2560 else if (mask64_operand (op, mode))
2564 return num_insns_constant_wide (high) + 1;
2567 return (num_insns_constant_wide (high)
2568 + num_insns_constant_wide (low) + 1);
2576 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
2577 If the mode of OP is MODE_VECTOR_INT, this simply returns the
2578 corresponding element of the vector, but for V4SFmode and V2SFmode,
2579 the corresponding "float" is interpreted as an SImode integer. */
2581 static HOST_WIDE_INT
2582 const_vector_elt_as_int (rtx op, unsigned int elt)
2584 rtx tmp = CONST_VECTOR_ELT (op, elt);
2585 if (GET_MODE (op) == V4SFmode
2586 || GET_MODE (op) == V2SFmode)
2587 tmp = gen_lowpart (SImode, tmp);
2588 return INTVAL (tmp);
2591 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
2592 or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used
2593 depends on STEP and COPIES, one of which will be 1. If COPIES > 1,
2594 all items are set to the same value and contain COPIES replicas of the
2595 vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's
2596 operand and the others are set to the value of the operand's msb. */
2599 vspltis_constant (rtx op, unsigned step, unsigned copies)
2601 enum machine_mode mode = GET_MODE (op);
2602 enum machine_mode inner = GET_MODE_INNER (mode);
2605 unsigned nunits = GET_MODE_NUNITS (mode);
2606 unsigned bitsize = GET_MODE_BITSIZE (inner);
2607 unsigned mask = GET_MODE_MASK (inner);
2609 HOST_WIDE_INT val = const_vector_elt_as_int (op, nunits - 1);
2610 HOST_WIDE_INT splat_val = val;
2611 HOST_WIDE_INT msb_val = val > 0 ? 0 : -1;
2613 /* Construct the value to be splatted, if possible. If not, return 0. */
2614 for (i = 2; i <= copies; i *= 2)
2616 HOST_WIDE_INT small_val;
2618 small_val = splat_val >> bitsize;
2620 if (splat_val != ((small_val << bitsize) | (small_val & mask)))
2622 splat_val = small_val;
2625 /* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */
2626 if (EASY_VECTOR_15 (splat_val))
2629 /* Also check if we can splat, and then add the result to itself. Do so if
2630 the value is positive, of if the splat instruction is using OP's mode;
2631 for splat_val < 0, the splat and the add should use the same mode. */
2632 else if (EASY_VECTOR_15_ADD_SELF (splat_val)
2633 && (splat_val >= 0 || (step == 1 && copies == 1)))
2639 /* Check if VAL is present in every STEP-th element, and the
2640 other elements are filled with its most significant bit. */
2641 for (i = 0; i < nunits - 1; ++i)
2643 HOST_WIDE_INT desired_val;
2644 if (((i + 1) & (step - 1)) == 0)
2647 desired_val = msb_val;
2649 if (desired_val != const_vector_elt_as_int (op, i))
2657 /* Return true if OP is of the given MODE and can be synthesized
2658 with a vspltisb, vspltish or vspltisw. */
2661 easy_altivec_constant (rtx op, enum machine_mode mode)
2663 unsigned step, copies;
2665 if (mode == VOIDmode)
2666 mode = GET_MODE (op);
2667 else if (mode != GET_MODE (op))
2670 /* Start with a vspltisw. */
2671 step = GET_MODE_NUNITS (mode) / 4;
2674 if (vspltis_constant (op, step, copies))
2677 /* Then try with a vspltish. */
2683 if (vspltis_constant (op, step, copies))
2686 /* And finally a vspltisb. */
2692 if (vspltis_constant (op, step, copies))
2698 /* Generate a VEC_DUPLICATE representing a vspltis[bhw] instruction whose
2699 result is OP. Abort if it is not possible. */
2702 gen_easy_altivec_constant (rtx op)
2704 enum machine_mode mode = GET_MODE (op);
2705 int nunits = GET_MODE_NUNITS (mode);
2706 rtx last = CONST_VECTOR_ELT (op, nunits - 1);
2707 unsigned step = nunits / 4;
2708 unsigned copies = 1;
2710 /* Start with a vspltisw. */
2711 if (vspltis_constant (op, step, copies))
2712 return gen_rtx_VEC_DUPLICATE (V4SImode, gen_lowpart (SImode, last));
2714 /* Then try with a vspltish. */
2720 if (vspltis_constant (op, step, copies))
2721 return gen_rtx_VEC_DUPLICATE (V8HImode, gen_lowpart (HImode, last));
2723 /* And finally a vspltisb. */
2729 if (vspltis_constant (op, step, copies))
2730 return gen_rtx_VEC_DUPLICATE (V16QImode, gen_lowpart (QImode, last));
2736 output_vec_const_move (rtx *operands)
2739 enum machine_mode mode;
2744 mode = GET_MODE (dest);
2749 if (zero_constant (vec, mode))
2750 return "vxor %0,%0,%0";
2752 splat_vec = gen_easy_altivec_constant (vec);
2753 gcc_assert (GET_CODE (splat_vec) == VEC_DUPLICATE);
2754 operands[1] = XEXP (splat_vec, 0);
2755 if (!EASY_VECTOR_15 (INTVAL (operands[1])))
2758 switch (GET_MODE (splat_vec))
2761 return "vspltisw %0,%1";
2764 return "vspltish %0,%1";
2767 return "vspltisb %0,%1";
2774 gcc_assert (TARGET_SPE);
2776 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2777 pattern of V1DI, V4HI, and V2SF.
2779 FIXME: We should probably return # and add post reload
2780 splitters for these, but this way is so easy ;-). */
2781 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2782 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
2783 operands[1] = CONST_VECTOR_ELT (vec, 0);
2784 operands[2] = CONST_VECTOR_ELT (vec, 1);
2786 return "li %0,%1\n\tevmergelo %0,%0,%0";
2788 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
2791 /* Initialize TARGET of vector PAIRED to VALS. */
2794 paired_expand_vector_init (rtx target, rtx vals)
2796 enum machine_mode mode = GET_MODE (target);
2797 int n_elts = GET_MODE_NUNITS (mode);
2799 rtx x, new, tmp, constant_op, op1, op2;
2802 for (i = 0; i < n_elts; ++i)
2804 x = XVECEXP (vals, 0, i);
2805 if (!CONSTANT_P (x))
2810 /* Load from constant pool. */
2811 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
2817 /* The vector is initialized only with non-constants. */
2818 new = gen_rtx_VEC_CONCAT (V2SFmode, XVECEXP (vals, 0, 0),
2819 XVECEXP (vals, 0, 1));
2821 emit_move_insn (target, new);
2825 /* One field is non-constant and the other one is a constant. Load the
2826 constant from the constant pool and use ps_merge instruction to
2827 construct the whole vector. */
2828 op1 = XVECEXP (vals, 0, 0);
2829 op2 = XVECEXP (vals, 0, 1);
2831 constant_op = (CONSTANT_P (op1)) ? op1 : op2;
2833 tmp = gen_reg_rtx (GET_MODE (constant_op));
2834 emit_move_insn (tmp, constant_op);
2836 if (CONSTANT_P (op1))
2837 new = gen_rtx_VEC_CONCAT (V2SFmode, tmp, op2);
2839 new = gen_rtx_VEC_CONCAT (V2SFmode, op1, tmp);
2841 emit_move_insn (target, new);
2845 paired_expand_vector_move (rtx operands[])
2847 rtx op0 = operands[0], op1 = operands[1];
2849 emit_move_insn (op0, op1);
2852 /* Emit vector compare for code RCODE. DEST is destination, OP1 and
2853 OP2 are two VEC_COND_EXPR operands, CC_OP0 and CC_OP1 are the two
2854 operands for the relation operation COND. This is a recursive
2858 paired_emit_vector_compare (enum rtx_code rcode,
2859 rtx dest, rtx op0, rtx op1,
2860 rtx cc_op0, rtx cc_op1)
2862 rtx tmp = gen_reg_rtx (V2SFmode);
2863 rtx tmp1, max, min, equal_zero;
2865 gcc_assert (TARGET_PAIRED_FLOAT);
2866 gcc_assert (GET_MODE (op0) == GET_MODE (op1));
2872 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
2876 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
2877 emit_insn (gen_selv2sf4 (dest, tmp, op0, op1, CONST0_RTX (SFmode)));
2881 paired_emit_vector_compare (GE, dest, op0, op1, cc_op1, cc_op0);
2884 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
2887 tmp1 = gen_reg_rtx (V2SFmode);
2888 max = gen_reg_rtx (V2SFmode);
2889 min = gen_reg_rtx (V2SFmode);
2890 equal_zero = gen_reg_rtx (V2SFmode);
2892 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
2893 emit_insn (gen_selv2sf4
2894 (max, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
2895 emit_insn (gen_subv2sf3 (tmp, cc_op1, cc_op0));
2896 emit_insn (gen_selv2sf4
2897 (min, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
2898 emit_insn (gen_subv2sf3 (tmp1, min, max));
2899 emit_insn (gen_selv2sf4 (dest, tmp1, op0, op1, CONST0_RTX (SFmode)));
2902 paired_emit_vector_compare (EQ, dest, op1, op0, cc_op0, cc_op1);
2905 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
2908 paired_emit_vector_compare (LT, dest, op1, op0, cc_op0, cc_op1);
2911 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
2914 paired_emit_vector_compare (GT, dest, op1, op0, cc_op0, cc_op1);
2923 /* Emit vector conditional expression.
2924 DEST is destination. OP1 and OP2 are two VEC_COND_EXPR operands.
2925 CC_OP0 and CC_OP1 are the two operands for the relation operation COND. */
2928 paired_emit_vector_cond_expr (rtx dest, rtx op1, rtx op2,
2929 rtx cond, rtx cc_op0, rtx cc_op1)
2931 enum rtx_code rcode = GET_CODE (cond);
2933 if (!TARGET_PAIRED_FLOAT)
2936 paired_emit_vector_compare (rcode, dest, op1, op2, cc_op0, cc_op1);
2941 /* Initialize vector TARGET to VALS. */
2944 rs6000_expand_vector_init (rtx target, rtx vals)
2946 enum machine_mode mode = GET_MODE (target);
2947 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2948 int n_elts = GET_MODE_NUNITS (mode);
2949 int n_var = 0, one_var = -1;
2950 bool all_same = true, all_const_zero = true;
2954 for (i = 0; i < n_elts; ++i)
2956 x = XVECEXP (vals, 0, i);
2957 if (!CONSTANT_P (x))
2958 ++n_var, one_var = i;
2959 else if (x != CONST0_RTX (inner_mode))
2960 all_const_zero = false;
2962 if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0)))
2968 rtx const_vec = gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0));
2969 if (mode != V4SFmode && all_const_zero)
2971 /* Zero register. */
2972 emit_insn (gen_rtx_SET (VOIDmode, target,
2973 gen_rtx_XOR (mode, target, target)));
2976 else if (mode != V4SFmode && easy_vector_constant (const_vec, mode))
2978 /* Splat immediate. */
2979 emit_insn (gen_rtx_SET (VOIDmode, target, const_vec));
2983 ; /* Splat vector element. */
2986 /* Load from constant pool. */
2987 emit_move_insn (target, const_vec);
2992 /* Store value to stack temp. Load vector element. Splat. */
2995 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2996 emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
2997 XVECEXP (vals, 0, 0));
2998 x = gen_rtx_UNSPEC (VOIDmode,
2999 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
3000 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3002 gen_rtx_SET (VOIDmode,
3005 x = gen_rtx_VEC_SELECT (inner_mode, target,
3006 gen_rtx_PARALLEL (VOIDmode,
3007 gen_rtvec (1, const0_rtx)));
3008 emit_insn (gen_rtx_SET (VOIDmode, target,
3009 gen_rtx_VEC_DUPLICATE (mode, x)));
3013 /* One field is non-constant. Load constant then overwrite
3017 rtx copy = copy_rtx (vals);
3019 /* Load constant part of vector, substitute neighboring value for
3021 XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts);
3022 rs6000_expand_vector_init (target, copy);
3024 /* Insert variable. */
3025 rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), one_var);
3029 /* Construct the vector in memory one field at a time
3030 and load the whole vector. */
3031 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
3032 for (i = 0; i < n_elts; i++)
3033 emit_move_insn (adjust_address_nv (mem, inner_mode,
3034 i * GET_MODE_SIZE (inner_mode)),
3035 XVECEXP (vals, 0, i));
3036 emit_move_insn (target, mem);
3039 /* Set field ELT of TARGET to VAL. */
3042 rs6000_expand_vector_set (rtx target, rtx val, int elt)
3044 enum machine_mode mode = GET_MODE (target);
3045 enum machine_mode inner_mode = GET_MODE_INNER (mode);
3046 rtx reg = gen_reg_rtx (mode);
3048 int width = GET_MODE_SIZE (inner_mode);
3051 /* Load single variable value. */
3052 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
3053 emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val);
3054 x = gen_rtx_UNSPEC (VOIDmode,
3055 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
3056 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3058 gen_rtx_SET (VOIDmode,
3062 /* Linear sequence. */
3063 mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
3064 for (i = 0; i < 16; ++i)
3065 XVECEXP (mask, 0, i) = GEN_INT (i);
3067 /* Set permute mask to insert element into target. */
3068 for (i = 0; i < width; ++i)
3069 XVECEXP (mask, 0, elt*width + i)
3070 = GEN_INT (i + 0x10);
3071 x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
3072 x = gen_rtx_UNSPEC (mode,
3073 gen_rtvec (3, target, reg,
3074 force_reg (V16QImode, x)),
3076 emit_insn (gen_rtx_SET (VOIDmode, target, x));
3079 /* Extract field ELT from VEC into TARGET. */
3082 rs6000_expand_vector_extract (rtx target, rtx vec, int elt)
3084 enum machine_mode mode = GET_MODE (vec);
3085 enum machine_mode inner_mode = GET_MODE_INNER (mode);
3088 /* Allocate mode-sized buffer. */
3089 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
3091 /* Add offset to field within buffer matching vector element. */
3092 mem = adjust_address_nv (mem, mode, elt * GET_MODE_SIZE (inner_mode));
3094 /* Store single field into mode-sized buffer. */
3095 x = gen_rtx_UNSPEC (VOIDmode,
3096 gen_rtvec (1, const0_rtx), UNSPEC_STVE);
3097 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3099 gen_rtx_SET (VOIDmode,
3102 emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0));
3105 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
3106 implement ANDing by the mask IN. */
3108 build_mask64_2_operands (rtx in, rtx *out)
3110 #if HOST_BITS_PER_WIDE_INT >= 64
3111 unsigned HOST_WIDE_INT c, lsb, m1, m2;
3114 gcc_assert (GET_CODE (in) == CONST_INT);
3119 /* Assume c initially something like 0x00fff000000fffff. The idea
3120 is to rotate the word so that the middle ^^^^^^ group of zeros
3121 is at the MS end and can be cleared with an rldicl mask. We then
3122 rotate back and clear off the MS ^^ group of zeros with a
3124 c = ~c; /* c == 0xff000ffffff00000 */
3125 lsb = c & -c; /* lsb == 0x0000000000100000 */
3126 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
3127 c = ~c; /* c == 0x00fff000000fffff */
3128 c &= -lsb; /* c == 0x00fff00000000000 */
3129 lsb = c & -c; /* lsb == 0x0000100000000000 */
3130 c = ~c; /* c == 0xff000fffffffffff */
3131 c &= -lsb; /* c == 0xff00000000000000 */
3133 while ((lsb >>= 1) != 0)
3134 shift++; /* shift == 44 on exit from loop */
3135 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
3136 m1 = ~m1; /* m1 == 0x000000ffffffffff */
3137 m2 = ~c; /* m2 == 0x00ffffffffffffff */
3141 /* Assume c initially something like 0xff000f0000000000. The idea
3142 is to rotate the word so that the ^^^ middle group of zeros
3143 is at the LS end and can be cleared with an rldicr mask. We then
3144 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
3146 lsb = c & -c; /* lsb == 0x0000010000000000 */
3147 m2 = -lsb; /* m2 == 0xffffff0000000000 */
3148 c = ~c; /* c == 0x00fff0ffffffffff */
3149 c &= -lsb; /* c == 0x00fff00000000000 */
3150 lsb = c & -c; /* lsb == 0x0000100000000000 */
3151 c = ~c; /* c == 0xff000fffffffffff */
3152 c &= -lsb; /* c == 0xff00000000000000 */
3154 while ((lsb >>= 1) != 0)
3155 shift++; /* shift == 44 on exit from loop */
3156 m1 = ~c; /* m1 == 0x00ffffffffffffff */
3157 m1 >>= shift; /* m1 == 0x0000000000000fff */
3158 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
3161 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
3162 masks will be all 1's. We are guaranteed more than one transition. */
3163 out[0] = GEN_INT (64 - shift);
3164 out[1] = GEN_INT (m1);
3165 out[2] = GEN_INT (shift);
3166 out[3] = GEN_INT (m2);
3174 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
3177 invalid_e500_subreg (rtx op, enum machine_mode mode)
3179 if (TARGET_E500_DOUBLE)
3181 /* Reject (subreg:SI (reg:DF)); likewise with subreg:DI or
3182 subreg:TI and reg:TF. */
3183 if (GET_CODE (op) == SUBREG
3184 && (mode == SImode || mode == DImode || mode == TImode)
3185 && REG_P (SUBREG_REG (op))
3186 && (GET_MODE (SUBREG_REG (op)) == DFmode
3187 || GET_MODE (SUBREG_REG (op)) == TFmode
3188 || GET_MODE (SUBREG_REG (op)) == DDmode
3189 || GET_MODE (SUBREG_REG (op)) == TDmode))
3192 /* Reject (subreg:DF (reg:DI)); likewise with subreg:TF and
3194 if (GET_CODE (op) == SUBREG
3195 && (mode == DFmode || mode == TFmode
3196 || mode == DDmode || mode == TDmode)
3197 && REG_P (SUBREG_REG (op))
3198 && (GET_MODE (SUBREG_REG (op)) == DImode
3199 || GET_MODE (SUBREG_REG (op)) == TImode))
3204 && GET_CODE (op) == SUBREG
3206 && REG_P (SUBREG_REG (op))
3207 && SPE_VECTOR_MODE (GET_MODE (SUBREG_REG (op))))
3213 /* AIX increases natural record alignment to doubleword if the first
3214 field is an FP double while the FP fields remain word aligned. */
3217 rs6000_special_round_type_align (tree type, unsigned int computed,
3218 unsigned int specified)
3220 unsigned int align = MAX (computed, specified);
3221 tree field = TYPE_FIELDS (type);
3223 /* Skip all non field decls */
3224 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
3225 field = TREE_CHAIN (field);
3227 if (field != NULL && field != type)
3229 type = TREE_TYPE (field);
3230 while (TREE_CODE (type) == ARRAY_TYPE)
3231 type = TREE_TYPE (type);
3233 if (type != error_mark_node && TYPE_MODE (type) == DFmode)
3234 align = MAX (align, 64);
3240 /* Darwin increases record alignment to the natural alignment of
3244 darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
3245 unsigned int specified)
3247 unsigned int align = MAX (computed, specified);
3249 if (TYPE_PACKED (type))
3252 /* Find the first field, looking down into aggregates. */
3254 tree field = TYPE_FIELDS (type);
3255 /* Skip all non field decls */
3256 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
3257 field = TREE_CHAIN (field);
3260 type = TREE_TYPE (field);
3261 while (TREE_CODE (type) == ARRAY_TYPE)
3262 type = TREE_TYPE (type);
3263 } while (AGGREGATE_TYPE_P (type));
3265 if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
3266 align = MAX (align, TYPE_ALIGN (type));
3271 /* Return 1 for an operand in small memory on V.4/eabi. */
3274 small_data_operand (rtx op ATTRIBUTE_UNUSED,
3275 enum machine_mode mode ATTRIBUTE_UNUSED)
3280 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
3283 if (DEFAULT_ABI != ABI_V4)
3286 /* Vector and float memory instructions have a limited offset on the
3287 SPE, so using a vector or float variable directly as an operand is
3290 && (SPE_VECTOR_MODE (mode) || FLOAT_MODE_P (mode)))
3293 if (GET_CODE (op) == SYMBOL_REF)
3296 else if (GET_CODE (op) != CONST
3297 || GET_CODE (XEXP (op, 0)) != PLUS
3298 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
3299 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
3304 rtx sum = XEXP (op, 0);
3305 HOST_WIDE_INT summand;
3307 /* We have to be careful here, because it is the referenced address
3308 that must be 32k from _SDA_BASE_, not just the symbol. */
3309 summand = INTVAL (XEXP (sum, 1));
3310 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
3313 sym_ref = XEXP (sum, 0);
3316 return SYMBOL_REF_SMALL_P (sym_ref);
3322 /* Return true if either operand is a general purpose register. */
3325 gpr_or_gpr_p (rtx op0, rtx op1)
3327 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
3328 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
3332 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
3335 constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
3337 switch (GET_CODE (op))
3340 if (RS6000_SYMBOL_REF_TLS_P (op))
3342 else if (CONSTANT_POOL_ADDRESS_P (op))
3344 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
3352 else if (! strcmp (XSTR (op, 0), toc_label_name))
3361 return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
3362 && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
3364 return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
3373 constant_pool_expr_p (rtx op)
3377 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
3381 toc_relative_expr_p (rtx op)
3385 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
3389 legitimate_constant_pool_address_p (rtx x)
3392 && GET_CODE (x) == PLUS
3393 && GET_CODE (XEXP (x, 0)) == REG
3394 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
3395 && constant_pool_expr_p (XEXP (x, 1)));
3399 legitimate_small_data_p (enum machine_mode mode, rtx x)
3401 return (DEFAULT_ABI == ABI_V4
3402 && !flag_pic && !TARGET_TOC
3403 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
3404 && small_data_operand (x, mode));
3407 /* SPE offset addressing is limited to 5-bits worth of double words. */
3408 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
3411 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
3413 unsigned HOST_WIDE_INT offset, extra;
3415 if (GET_CODE (x) != PLUS)
3417 if (GET_CODE (XEXP (x, 0)) != REG)
3419 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3421 if (legitimate_constant_pool_address_p (x))
3423 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3426 offset = INTVAL (XEXP (x, 1));
3434 /* AltiVec vector modes. Only reg+reg addressing is valid and
3435 constant offset zero should not occur due to canonicalization. */
3442 /* Paired vector modes. Only reg+reg addressing is valid and