1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 Free Software Foundation, Inc.
5 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 3, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
54 #include "sched-int.h"
56 #include "tree-flow.h"
59 #include "tm-constrs.h"
61 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
64 #include "gstab.h" /* for N_SLINE */
67 #ifndef TARGET_NO_PROTOTYPE
68 #define TARGET_NO_PROTOTYPE 0
71 #define min(A,B) ((A) < (B) ? (A) : (B))
72 #define max(A,B) ((A) > (B) ? (A) : (B))
74 /* Structure used to define the rs6000 stack */
75 typedef struct rs6000_stack {
76 int first_gp_reg_save; /* first callee saved GP register used */
77 int first_fp_reg_save; /* first callee saved FP register used */
78 int first_altivec_reg_save; /* first callee saved AltiVec register used */
79 int lr_save_p; /* true if the link reg needs to be saved */
80 int cr_save_p; /* true if the CR reg needs to be saved */
81 unsigned int vrsave_mask; /* mask of vec registers to save */
82 int push_p; /* true if we need to allocate stack space */
83 int calls_p; /* true if the function makes any calls */
84 int world_save_p; /* true if we're saving *everything*:
85 r13-r31, cr, f14-f31, vrsave, v20-v31 */
86 enum rs6000_abi abi; /* which ABI to use */
87 int gp_save_offset; /* offset to save GP regs from initial SP */
88 int fp_save_offset; /* offset to save FP regs from initial SP */
89 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
90 int lr_save_offset; /* offset to save LR from initial SP */
91 int cr_save_offset; /* offset to save CR from initial SP */
92 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
93 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
94 int varargs_save_offset; /* offset to save the varargs registers */
95 int ehrd_offset; /* offset to EH return data */
96 int reg_size; /* register size (4 or 8) */
97 HOST_WIDE_INT vars_size; /* variable save area size */
98 int parm_size; /* outgoing parameter size */
99 int save_size; /* save area size */
100 int fixed_size; /* fixed size of stack frame */
101 int gp_size; /* size of saved GP registers */
102 int fp_size; /* size of saved FP registers */
103 int altivec_size; /* size of saved AltiVec registers */
104 int cr_size; /* size to hold CR if not in save_size */
105 int vrsave_size; /* size to hold VRSAVE if not in save_size */
106 int altivec_padding_size; /* size of altivec alignment padding if
108 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
109 int spe_padding_size;
110 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
111 int spe_64bit_regs_used;
114 /* A C structure for machine-specific, per-function data.
115 This is added to the cfun structure. */
116 typedef struct 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 /* Always emit branch hint bits. */
147 static GTY(()) bool rs6000_always_hint;
149 /* Schedule instructions for group formation. */
150 static GTY(()) bool rs6000_sched_groups;
152 /* Align branch targets. */
153 static GTY(()) bool rs6000_align_branch_targets;
155 /* Support for -msched-costly-dep option. */
156 const char *rs6000_sched_costly_dep_str;
157 enum rs6000_dependence_cost rs6000_sched_costly_dep;
159 /* Support for -minsert-sched-nops option. */
160 const char *rs6000_sched_insert_nops_str;
161 enum rs6000_nop_insertion rs6000_sched_insert_nops;
163 /* Support targetm.vectorize.builtin_mask_for_load. */
164 static GTY(()) tree altivec_builtin_mask_for_load;
166 /* Size of long double. */
167 int rs6000_long_double_type_size;
169 /* IEEE quad extended precision long double. */
172 /* Nonzero to use AltiVec ABI. */
173 int rs6000_altivec_abi;
175 /* Nonzero if we want SPE SIMD instructions. */
178 /* Nonzero if we want SPE ABI extensions. */
181 /* Nonzero to use isel instructions. */
184 /* Nonzero if floating point operations are done in the GPRs. */
185 int rs6000_float_gprs = 0;
187 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
188 int rs6000_darwin64_abi;
190 /* Set to nonzero once AIX common-mode calls have been defined. */
191 static GTY(()) int common_mode_defined;
193 /* Save information from a "cmpxx" operation until the branch or scc is
195 rtx rs6000_compare_op0, rs6000_compare_op1;
196 int rs6000_compare_fp_p;
198 /* Label number of label created for -mrelocatable, to call to so we can
199 get the address of the GOT section */
200 int rs6000_pic_labelno;
203 /* Which abi to adhere to */
204 const char *rs6000_abi_name;
206 /* Semantics of the small data area */
207 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
209 /* Which small data model to use */
210 const char *rs6000_sdata_name = (char *)0;
212 /* Counter for labels which are to be placed in .fixup. */
213 int fixuplabelno = 0;
216 /* Bit size of immediate TLS offsets and string from which it is decoded. */
217 int rs6000_tls_size = 32;
218 const char *rs6000_tls_size_string;
220 /* ABI enumeration available for subtarget to use. */
221 enum rs6000_abi rs6000_current_abi;
223 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
227 const char *rs6000_debug_name;
228 int rs6000_debug_stack; /* debug stack applications */
229 int rs6000_debug_arg; /* debug argument handling */
231 /* Value is TRUE if register/mode pair is acceptable. */
232 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
234 /* Built in types. */
236 tree rs6000_builtin_types[RS6000_BTI_MAX];
237 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
239 const char *rs6000_traceback_name;
241 traceback_default = 0,
247 /* Flag to say the TOC is initialized */
249 char toc_label_name[10];
251 /* Cached value of rs6000_variable_issue. This is cached in
252 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
253 static short cached_can_issue_more;
255 static GTY(()) section *read_only_data_section;
256 static GTY(()) section *private_data_section;
257 static GTY(()) section *read_only_private_data_section;
258 static GTY(()) section *sdata2_section;
259 static GTY(()) section *toc_section;
261 /* Control alignment for fields within structures. */
262 /* String from -malign-XXXXX. */
263 int rs6000_alignment_flags;
265 /* True for any options that were explicitly set. */
267 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
268 bool alignment; /* True if -malign- was used. */
269 bool spe_abi; /* True if -mabi=spe/no-spe was used. */
270 bool altivec_abi; /* True if -mabi=altivec/no-altivec used. */
271 bool spe; /* True if -mspe= was used. */
272 bool float_gprs; /* True if -mfloat-gprs= was used. */
273 bool isel; /* True if -misel was used. */
274 bool long_double; /* True if -mlong-double- was used. */
275 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
276 bool vrsave; /* True if -mvrsave was used. */
277 } rs6000_explicit_options;
279 struct builtin_description
281 /* mask is not const because we're going to alter it below. This
282 nonsense will go away when we rewrite the -march infrastructure
283 to give us more target flag bits. */
285 const enum insn_code icode;
286 const char *const name;
287 const enum rs6000_builtins code;
290 /* Target cpu costs. */
292 struct processor_costs {
293 const int mulsi; /* cost of SImode multiplication. */
294 const int mulsi_const; /* cost of SImode multiplication by constant. */
295 const int mulsi_const9; /* cost of SImode mult by short constant. */
296 const int muldi; /* cost of DImode multiplication. */
297 const int divsi; /* cost of SImode division. */
298 const int divdi; /* cost of DImode division. */
299 const int fp; /* cost of simple SFmode and DFmode insns. */
300 const int dmul; /* cost of DFmode multiplication (and fmadd). */
301 const int sdiv; /* cost of SFmode division (fdivs). */
302 const int ddiv; /* cost of DFmode division (fdiv). */
303 const int cache_line_size; /* cache line size in bytes. */
304 const int l1_cache_size; /* size of l1 cache, in kilobytes. */
305 const int l2_cache_size; /* size of l2 cache, in kilobytes. */
306 const int simultaneous_prefetches; /* number of parallel prefetch
310 const struct processor_costs *rs6000_cost;
312 /* Processor costs (relative to an add) */
314 /* Instruction size costs on 32bit processors. */
316 struct processor_costs size32_cost = {
317 COSTS_N_INSNS (1), /* mulsi */
318 COSTS_N_INSNS (1), /* mulsi_const */
319 COSTS_N_INSNS (1), /* mulsi_const9 */
320 COSTS_N_INSNS (1), /* muldi */
321 COSTS_N_INSNS (1), /* divsi */
322 COSTS_N_INSNS (1), /* divdi */
323 COSTS_N_INSNS (1), /* fp */
324 COSTS_N_INSNS (1), /* dmul */
325 COSTS_N_INSNS (1), /* sdiv */
326 COSTS_N_INSNS (1), /* ddiv */
333 /* Instruction size costs on 64bit processors. */
335 struct processor_costs size64_cost = {
336 COSTS_N_INSNS (1), /* mulsi */
337 COSTS_N_INSNS (1), /* mulsi_const */
338 COSTS_N_INSNS (1), /* mulsi_const9 */
339 COSTS_N_INSNS (1), /* muldi */
340 COSTS_N_INSNS (1), /* divsi */
341 COSTS_N_INSNS (1), /* divdi */
342 COSTS_N_INSNS (1), /* fp */
343 COSTS_N_INSNS (1), /* dmul */
344 COSTS_N_INSNS (1), /* sdiv */
345 COSTS_N_INSNS (1), /* ddiv */
352 /* Instruction costs on RIOS1 processors. */
354 struct processor_costs rios1_cost = {
355 COSTS_N_INSNS (5), /* mulsi */
356 COSTS_N_INSNS (4), /* mulsi_const */
357 COSTS_N_INSNS (3), /* mulsi_const9 */
358 COSTS_N_INSNS (5), /* muldi */
359 COSTS_N_INSNS (19), /* divsi */
360 COSTS_N_INSNS (19), /* divdi */
361 COSTS_N_INSNS (2), /* fp */
362 COSTS_N_INSNS (2), /* dmul */
363 COSTS_N_INSNS (19), /* sdiv */
364 COSTS_N_INSNS (19), /* ddiv */
365 128, /* cache line size */
371 /* Instruction costs on RIOS2 processors. */
373 struct processor_costs rios2_cost = {
374 COSTS_N_INSNS (2), /* mulsi */
375 COSTS_N_INSNS (2), /* mulsi_const */
376 COSTS_N_INSNS (2), /* mulsi_const9 */
377 COSTS_N_INSNS (2), /* muldi */
378 COSTS_N_INSNS (13), /* divsi */
379 COSTS_N_INSNS (13), /* divdi */
380 COSTS_N_INSNS (2), /* fp */
381 COSTS_N_INSNS (2), /* dmul */
382 COSTS_N_INSNS (17), /* sdiv */
383 COSTS_N_INSNS (17), /* ddiv */
384 256, /* cache line size */
390 /* Instruction costs on RS64A processors. */
392 struct processor_costs rs64a_cost = {
393 COSTS_N_INSNS (20), /* mulsi */
394 COSTS_N_INSNS (12), /* mulsi_const */
395 COSTS_N_INSNS (8), /* mulsi_const9 */
396 COSTS_N_INSNS (34), /* muldi */
397 COSTS_N_INSNS (65), /* divsi */
398 COSTS_N_INSNS (67), /* divdi */
399 COSTS_N_INSNS (4), /* fp */
400 COSTS_N_INSNS (4), /* dmul */
401 COSTS_N_INSNS (31), /* sdiv */
402 COSTS_N_INSNS (31), /* ddiv */
403 128, /* cache line size */
409 /* Instruction costs on MPCCORE processors. */
411 struct processor_costs mpccore_cost = {
412 COSTS_N_INSNS (2), /* mulsi */
413 COSTS_N_INSNS (2), /* mulsi_const */
414 COSTS_N_INSNS (2), /* mulsi_const9 */
415 COSTS_N_INSNS (2), /* muldi */
416 COSTS_N_INSNS (6), /* divsi */
417 COSTS_N_INSNS (6), /* divdi */
418 COSTS_N_INSNS (4), /* fp */
419 COSTS_N_INSNS (5), /* dmul */
420 COSTS_N_INSNS (10), /* sdiv */
421 COSTS_N_INSNS (17), /* ddiv */
422 32, /* cache line size */
428 /* Instruction costs on PPC403 processors. */
430 struct processor_costs ppc403_cost = {
431 COSTS_N_INSNS (4), /* mulsi */
432 COSTS_N_INSNS (4), /* mulsi_const */
433 COSTS_N_INSNS (4), /* mulsi_const9 */
434 COSTS_N_INSNS (4), /* muldi */
435 COSTS_N_INSNS (33), /* divsi */
436 COSTS_N_INSNS (33), /* divdi */
437 COSTS_N_INSNS (11), /* fp */
438 COSTS_N_INSNS (11), /* dmul */
439 COSTS_N_INSNS (11), /* sdiv */
440 COSTS_N_INSNS (11), /* ddiv */
441 32, /* cache line size */
447 /* Instruction costs on PPC405 processors. */
449 struct processor_costs ppc405_cost = {
450 COSTS_N_INSNS (5), /* mulsi */
451 COSTS_N_INSNS (4), /* mulsi_const */
452 COSTS_N_INSNS (3), /* mulsi_const9 */
453 COSTS_N_INSNS (5), /* muldi */
454 COSTS_N_INSNS (35), /* divsi */
455 COSTS_N_INSNS (35), /* divdi */
456 COSTS_N_INSNS (11), /* fp */
457 COSTS_N_INSNS (11), /* dmul */
458 COSTS_N_INSNS (11), /* sdiv */
459 COSTS_N_INSNS (11), /* ddiv */
460 32, /* cache line size */
466 /* Instruction costs on PPC440 processors. */
468 struct processor_costs ppc440_cost = {
469 COSTS_N_INSNS (3), /* mulsi */
470 COSTS_N_INSNS (2), /* mulsi_const */
471 COSTS_N_INSNS (2), /* mulsi_const9 */
472 COSTS_N_INSNS (3), /* muldi */
473 COSTS_N_INSNS (34), /* divsi */
474 COSTS_N_INSNS (34), /* divdi */
475 COSTS_N_INSNS (5), /* fp */
476 COSTS_N_INSNS (5), /* dmul */
477 COSTS_N_INSNS (19), /* sdiv */
478 COSTS_N_INSNS (33), /* ddiv */
479 32, /* cache line size */
485 /* Instruction costs on PPC601 processors. */
487 struct processor_costs ppc601_cost = {
488 COSTS_N_INSNS (5), /* mulsi */
489 COSTS_N_INSNS (5), /* mulsi_const */
490 COSTS_N_INSNS (5), /* mulsi_const9 */
491 COSTS_N_INSNS (5), /* muldi */
492 COSTS_N_INSNS (36), /* divsi */
493 COSTS_N_INSNS (36), /* divdi */
494 COSTS_N_INSNS (4), /* fp */
495 COSTS_N_INSNS (5), /* dmul */
496 COSTS_N_INSNS (17), /* sdiv */
497 COSTS_N_INSNS (31), /* ddiv */
498 32, /* cache line size */
504 /* Instruction costs on PPC603 processors. */
506 struct processor_costs ppc603_cost = {
507 COSTS_N_INSNS (5), /* mulsi */
508 COSTS_N_INSNS (3), /* mulsi_const */
509 COSTS_N_INSNS (2), /* mulsi_const9 */
510 COSTS_N_INSNS (5), /* muldi */
511 COSTS_N_INSNS (37), /* divsi */
512 COSTS_N_INSNS (37), /* divdi */
513 COSTS_N_INSNS (3), /* fp */
514 COSTS_N_INSNS (4), /* dmul */
515 COSTS_N_INSNS (18), /* sdiv */
516 COSTS_N_INSNS (33), /* ddiv */
517 32, /* cache line size */
523 /* Instruction costs on PPC604 processors. */
525 struct processor_costs ppc604_cost = {
526 COSTS_N_INSNS (4), /* mulsi */
527 COSTS_N_INSNS (4), /* mulsi_const */
528 COSTS_N_INSNS (4), /* mulsi_const9 */
529 COSTS_N_INSNS (4), /* muldi */
530 COSTS_N_INSNS (20), /* divsi */
531 COSTS_N_INSNS (20), /* divdi */
532 COSTS_N_INSNS (3), /* fp */
533 COSTS_N_INSNS (3), /* dmul */
534 COSTS_N_INSNS (18), /* sdiv */
535 COSTS_N_INSNS (32), /* ddiv */
536 32, /* cache line size */
542 /* Instruction costs on PPC604e processors. */
544 struct processor_costs ppc604e_cost = {
545 COSTS_N_INSNS (2), /* mulsi */
546 COSTS_N_INSNS (2), /* mulsi_const */
547 COSTS_N_INSNS (2), /* mulsi_const9 */
548 COSTS_N_INSNS (2), /* muldi */
549 COSTS_N_INSNS (20), /* divsi */
550 COSTS_N_INSNS (20), /* divdi */
551 COSTS_N_INSNS (3), /* fp */
552 COSTS_N_INSNS (3), /* dmul */
553 COSTS_N_INSNS (18), /* sdiv */
554 COSTS_N_INSNS (32), /* ddiv */
555 32, /* cache line size */
561 /* Instruction costs on PPC620 processors. */
563 struct processor_costs ppc620_cost = {
564 COSTS_N_INSNS (5), /* mulsi */
565 COSTS_N_INSNS (4), /* mulsi_const */
566 COSTS_N_INSNS (3), /* mulsi_const9 */
567 COSTS_N_INSNS (7), /* muldi */
568 COSTS_N_INSNS (21), /* divsi */
569 COSTS_N_INSNS (37), /* divdi */
570 COSTS_N_INSNS (3), /* fp */
571 COSTS_N_INSNS (3), /* dmul */
572 COSTS_N_INSNS (18), /* sdiv */
573 COSTS_N_INSNS (32), /* ddiv */
574 128, /* cache line size */
580 /* Instruction costs on PPC630 processors. */
582 struct processor_costs ppc630_cost = {
583 COSTS_N_INSNS (5), /* mulsi */
584 COSTS_N_INSNS (4), /* mulsi_const */
585 COSTS_N_INSNS (3), /* mulsi_const9 */
586 COSTS_N_INSNS (7), /* muldi */
587 COSTS_N_INSNS (21), /* divsi */
588 COSTS_N_INSNS (37), /* divdi */
589 COSTS_N_INSNS (3), /* fp */
590 COSTS_N_INSNS (3), /* dmul */
591 COSTS_N_INSNS (17), /* sdiv */
592 COSTS_N_INSNS (21), /* ddiv */
593 128, /* cache line size */
599 /* Instruction costs on Cell processor. */
600 /* COSTS_N_INSNS (1) ~ one add. */
602 struct processor_costs ppccell_cost = {
603 COSTS_N_INSNS (9/2)+2, /* mulsi */
604 COSTS_N_INSNS (6/2), /* mulsi_const */
605 COSTS_N_INSNS (6/2), /* mulsi_const9 */
606 COSTS_N_INSNS (15/2)+2, /* muldi */
607 COSTS_N_INSNS (38/2), /* divsi */
608 COSTS_N_INSNS (70/2), /* divdi */
609 COSTS_N_INSNS (10/2), /* fp */
610 COSTS_N_INSNS (10/2), /* dmul */
611 COSTS_N_INSNS (74/2), /* sdiv */
612 COSTS_N_INSNS (74/2), /* ddiv */
613 128, /* cache line size */
619 /* Instruction costs on PPC750 and PPC7400 processors. */
621 struct processor_costs ppc750_cost = {
622 COSTS_N_INSNS (5), /* mulsi */
623 COSTS_N_INSNS (3), /* mulsi_const */
624 COSTS_N_INSNS (2), /* mulsi_const9 */
625 COSTS_N_INSNS (5), /* muldi */
626 COSTS_N_INSNS (17), /* divsi */
627 COSTS_N_INSNS (17), /* divdi */
628 COSTS_N_INSNS (3), /* fp */
629 COSTS_N_INSNS (3), /* dmul */
630 COSTS_N_INSNS (17), /* sdiv */
631 COSTS_N_INSNS (31), /* ddiv */
632 32, /* cache line size */
638 /* Instruction costs on PPC7450 processors. */
640 struct processor_costs ppc7450_cost = {
641 COSTS_N_INSNS (4), /* mulsi */
642 COSTS_N_INSNS (3), /* mulsi_const */
643 COSTS_N_INSNS (3), /* mulsi_const9 */
644 COSTS_N_INSNS (4), /* muldi */
645 COSTS_N_INSNS (23), /* divsi */
646 COSTS_N_INSNS (23), /* divdi */
647 COSTS_N_INSNS (5), /* fp */
648 COSTS_N_INSNS (5), /* dmul */
649 COSTS_N_INSNS (21), /* sdiv */
650 COSTS_N_INSNS (35), /* ddiv */
651 32, /* cache line size */
657 /* Instruction costs on PPC8540 processors. */
659 struct processor_costs ppc8540_cost = {
660 COSTS_N_INSNS (4), /* mulsi */
661 COSTS_N_INSNS (4), /* mulsi_const */
662 COSTS_N_INSNS (4), /* mulsi_const9 */
663 COSTS_N_INSNS (4), /* muldi */
664 COSTS_N_INSNS (19), /* divsi */
665 COSTS_N_INSNS (19), /* divdi */
666 COSTS_N_INSNS (4), /* fp */
667 COSTS_N_INSNS (4), /* dmul */
668 COSTS_N_INSNS (29), /* sdiv */
669 COSTS_N_INSNS (29), /* ddiv */
670 32, /* cache line size */
673 1, /* prefetch streams /*/
676 /* Instruction costs on E300C2 and E300C3 cores. */
678 struct processor_costs ppce300c2c3_cost = {
679 COSTS_N_INSNS (4), /* mulsi */
680 COSTS_N_INSNS (4), /* mulsi_const */
681 COSTS_N_INSNS (4), /* mulsi_const9 */
682 COSTS_N_INSNS (4), /* muldi */
683 COSTS_N_INSNS (19), /* divsi */
684 COSTS_N_INSNS (19), /* divdi */
685 COSTS_N_INSNS (3), /* fp */
686 COSTS_N_INSNS (4), /* dmul */
687 COSTS_N_INSNS (18), /* sdiv */
688 COSTS_N_INSNS (33), /* ddiv */
692 1, /* prefetch streams /*/
695 /* Instruction costs on PPCE500MC processors. */
697 struct processor_costs ppce500mc_cost = {
698 COSTS_N_INSNS (4), /* mulsi */
699 COSTS_N_INSNS (4), /* mulsi_const */
700 COSTS_N_INSNS (4), /* mulsi_const9 */
701 COSTS_N_INSNS (4), /* muldi */
702 COSTS_N_INSNS (14), /* divsi */
703 COSTS_N_INSNS (14), /* divdi */
704 COSTS_N_INSNS (8), /* fp */
705 COSTS_N_INSNS (10), /* dmul */
706 COSTS_N_INSNS (36), /* sdiv */
707 COSTS_N_INSNS (66), /* ddiv */
708 64, /* cache line size */
711 1, /* prefetch streams /*/
714 /* Instruction costs on POWER4 and POWER5 processors. */
716 struct processor_costs power4_cost = {
717 COSTS_N_INSNS (3), /* mulsi */
718 COSTS_N_INSNS (2), /* mulsi_const */
719 COSTS_N_INSNS (2), /* mulsi_const9 */
720 COSTS_N_INSNS (4), /* muldi */
721 COSTS_N_INSNS (18), /* divsi */
722 COSTS_N_INSNS (34), /* divdi */
723 COSTS_N_INSNS (3), /* fp */
724 COSTS_N_INSNS (3), /* dmul */
725 COSTS_N_INSNS (17), /* sdiv */
726 COSTS_N_INSNS (17), /* ddiv */
727 128, /* cache line size */
730 8, /* prefetch streams /*/
733 /* Instruction costs on POWER6 processors. */
735 struct processor_costs power6_cost = {
736 COSTS_N_INSNS (8), /* mulsi */
737 COSTS_N_INSNS (8), /* mulsi_const */
738 COSTS_N_INSNS (8), /* mulsi_const9 */
739 COSTS_N_INSNS (8), /* muldi */
740 COSTS_N_INSNS (22), /* divsi */
741 COSTS_N_INSNS (28), /* divdi */
742 COSTS_N_INSNS (3), /* fp */
743 COSTS_N_INSNS (3), /* dmul */
744 COSTS_N_INSNS (13), /* sdiv */
745 COSTS_N_INSNS (16), /* ddiv */
746 128, /* cache line size */
749 16, /* prefetch streams */
753 static bool rs6000_function_ok_for_sibcall (tree, tree);
754 static const char *rs6000_invalid_within_doloop (const_rtx);
755 static rtx rs6000_generate_compare (enum rtx_code);
756 static void rs6000_emit_stack_tie (void);
757 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
758 static bool spe_func_has_64bit_regs_p (void);
759 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
761 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
762 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int, int);
763 static unsigned rs6000_hash_constant (rtx);
764 static unsigned toc_hash_function (const void *);
765 static int toc_hash_eq (const void *, const void *);
766 static bool constant_pool_expr_p (rtx);
767 static bool legitimate_small_data_p (enum machine_mode, rtx);
768 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
769 static struct machine_function * rs6000_init_machine_status (void);
770 static bool rs6000_assemble_integer (rtx, unsigned int, int);
771 static bool no_global_regs_above (int, bool);
772 #ifdef HAVE_GAS_HIDDEN
773 static void rs6000_assemble_visibility (tree, int);
775 static int rs6000_ra_ever_killed (void);
776 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
777 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
778 static bool rs6000_ms_bitfield_layout_p (const_tree);
779 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
780 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
781 static const char *rs6000_mangle_type (const_tree);
782 extern const struct attribute_spec rs6000_attribute_table[];
783 static void rs6000_set_default_type_attributes (tree);
784 static rtx rs6000_savres_routine_sym (rs6000_stack_t *, bool, bool, bool);
785 static void rs6000_emit_stack_reset (rs6000_stack_t *, rtx, rtx, int, bool);
786 static rtx rs6000_make_savres_rtx (rs6000_stack_t *, rtx, int,
787 enum machine_mode, bool, bool, bool);
788 static bool rs6000_reg_live_or_pic_offset_p (int);
789 static int rs6000_savres_strategy (rs6000_stack_t *, bool, int, int);
790 static void rs6000_restore_saved_cr (rtx, int);
791 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
792 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
793 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
795 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
796 static bool rs6000_return_in_memory (const_tree, const_tree);
797 static void rs6000_file_start (void);
799 static int rs6000_elf_reloc_rw_mask (void);
800 static void rs6000_elf_asm_out_constructor (rtx, int);
801 static void rs6000_elf_asm_out_destructor (rtx, int);
802 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
803 static void rs6000_elf_asm_init_sections (void);
804 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
805 unsigned HOST_WIDE_INT);
806 static void rs6000_elf_encode_section_info (tree, rtx, int)
809 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, const_rtx);
810 static void rs6000_alloc_sdmode_stack_slot (void);
811 static void rs6000_instantiate_decls (void);
813 static void rs6000_xcoff_asm_output_anchor (rtx);
814 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
815 static void rs6000_xcoff_asm_init_sections (void);
816 static int rs6000_xcoff_reloc_rw_mask (void);
817 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
818 static section *rs6000_xcoff_select_section (tree, int,
819 unsigned HOST_WIDE_INT);
820 static void rs6000_xcoff_unique_section (tree, int);
821 static section *rs6000_xcoff_select_rtx_section
822 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
823 static const char * rs6000_xcoff_strip_name_encoding (const char *);
824 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
825 static void rs6000_xcoff_file_start (void);
826 static void rs6000_xcoff_file_end (void);
828 static int rs6000_variable_issue (FILE *, int, rtx, int);
829 static bool rs6000_rtx_costs (rtx, int, int, int *, bool);
830 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
831 static void rs6000_sched_init (FILE *, int, int);
832 static bool is_microcoded_insn (rtx);
833 static bool is_nonpipeline_insn (rtx);
834 static bool is_cracked_insn (rtx);
835 static bool is_branch_slot_insn (rtx);
836 static bool is_load_insn (rtx);
837 static rtx get_store_dest (rtx pat);
838 static bool is_store_insn (rtx);
839 static bool set_to_load_agen (rtx,rtx);
840 static bool adjacent_mem_locations (rtx,rtx);
841 static int rs6000_adjust_priority (rtx, int);
842 static int rs6000_issue_rate (void);
843 static bool rs6000_is_costly_dependence (dep_t, int, int);
844 static rtx get_next_active_insn (rtx, rtx);
845 static bool insn_terminates_group_p (rtx , enum group_termination);
846 static bool insn_must_be_first_in_group (rtx);
847 static bool insn_must_be_last_in_group (rtx);
848 static bool is_costly_group (rtx *, rtx);
849 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
850 static int redefine_groups (FILE *, int, rtx, rtx);
851 static int pad_groups (FILE *, int, rtx, rtx);
852 static void rs6000_sched_finish (FILE *, int);
853 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
854 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
855 static int rs6000_use_sched_lookahead (void);
856 static int rs6000_use_sched_lookahead_guard (rtx);
857 static void * rs6000_alloc_sched_context (void);
858 static void rs6000_init_sched_context (void *, bool);
859 static void rs6000_set_sched_context (void *);
860 static void rs6000_free_sched_context (void *);
861 static tree rs6000_builtin_reciprocal (unsigned int, bool, bool);
862 static tree rs6000_builtin_mask_for_load (void);
863 static tree rs6000_builtin_mul_widen_even (tree);
864 static tree rs6000_builtin_mul_widen_odd (tree);
865 static tree rs6000_builtin_conversion (enum tree_code, tree);
866 static tree rs6000_builtin_vec_perm (tree, tree *);
868 static void def_builtin (int, const char *, tree, int);
869 static bool rs6000_vector_alignment_reachable (const_tree, bool);
870 static void rs6000_init_builtins (void);
871 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
872 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
873 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
874 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
875 static void altivec_init_builtins (void);
876 static void rs6000_common_init_builtins (void);
877 static void rs6000_init_libfuncs (void);
879 static void paired_init_builtins (void);
880 static rtx paired_expand_builtin (tree, rtx, bool *);
881 static rtx paired_expand_lv_builtin (enum insn_code, tree, rtx);
882 static rtx paired_expand_stv_builtin (enum insn_code, tree);
883 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
885 static void enable_mask_for_builtins (struct builtin_description *, int,
886 enum rs6000_builtins,
887 enum rs6000_builtins);
888 static tree build_opaque_vector_type (tree, int);
889 static void spe_init_builtins (void);
890 static rtx spe_expand_builtin (tree, rtx, bool *);
891 static rtx spe_expand_stv_builtin (enum insn_code, tree);
892 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
893 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
894 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
895 static rs6000_stack_t *rs6000_stack_info (void);
896 static void debug_stack_info (rs6000_stack_t *);
898 static rtx altivec_expand_builtin (tree, rtx, bool *);
899 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
900 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
901 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
902 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
903 static rtx altivec_expand_predicate_builtin (enum insn_code,
904 const char *, tree, rtx);
905 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
906 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
907 static rtx altivec_expand_vec_set_builtin (tree);
908 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
909 static int get_element_number (tree, tree);
910 static bool rs6000_handle_option (size_t, const char *, int);
911 static void rs6000_parse_tls_size_option (void);
912 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
913 static int first_altivec_reg_to_save (void);
914 static unsigned int compute_vrsave_mask (void);
915 static void compute_save_world_info (rs6000_stack_t *info_ptr);
916 static void is_altivec_return_reg (rtx, void *);
917 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
918 int easy_vector_constant (rtx, enum machine_mode);
919 static bool rs6000_is_opaque_type (const_tree);
920 static rtx rs6000_dwarf_register_span (rtx);
921 static void rs6000_init_dwarf_reg_sizes_extra (tree);
922 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
923 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
924 static rtx rs6000_tls_get_addr (void);
925 static rtx rs6000_got_sym (void);
926 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
927 static const char *rs6000_get_some_local_dynamic_name (void);
928 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
929 static rtx rs6000_complex_function_value (enum machine_mode);
930 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
931 enum machine_mode, tree);
932 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
934 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
935 tree, HOST_WIDE_INT);
936 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
939 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
940 const_tree, HOST_WIDE_INT,
942 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
943 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
944 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
945 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
946 enum machine_mode, tree,
948 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
950 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
952 static const char *invalid_arg_for_unprototyped_fn (const_tree, const_tree, const_tree);
954 static void macho_branch_islands (void);
955 static int no_previous_def (tree function_name);
956 static tree get_prev_label (tree function_name);
957 static void rs6000_darwin_file_start (void);
960 static tree rs6000_build_builtin_va_list (void);
961 static void rs6000_va_start (tree, rtx);
962 static tree rs6000_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *);
963 static bool rs6000_must_pass_in_stack (enum machine_mode, const_tree);
964 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
965 static bool rs6000_vector_mode_supported_p (enum machine_mode);
966 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
968 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
970 static int get_vsel_insn (enum machine_mode);
971 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
972 static tree rs6000_stack_protect_fail (void);
974 const int INSN_NOT_AVAILABLE = -1;
975 static enum machine_mode rs6000_eh_return_filter_mode (void);
977 /* Hash table stuff for keeping track of TOC entries. */
979 struct toc_hash_struct GTY(())
981 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
982 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
984 enum machine_mode key_mode;
988 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
990 /* Default register names. */
991 char rs6000_reg_names[][8] =
993 "0", "1", "2", "3", "4", "5", "6", "7",
994 "8", "9", "10", "11", "12", "13", "14", "15",
995 "16", "17", "18", "19", "20", "21", "22", "23",
996 "24", "25", "26", "27", "28", "29", "30", "31",
997 "0", "1", "2", "3", "4", "5", "6", "7",
998 "8", "9", "10", "11", "12", "13", "14", "15",
999 "16", "17", "18", "19", "20", "21", "22", "23",
1000 "24", "25", "26", "27", "28", "29", "30", "31",
1001 "mq", "lr", "ctr","ap",
1002 "0", "1", "2", "3", "4", "5", "6", "7",
1004 /* AltiVec registers. */
1005 "0", "1", "2", "3", "4", "5", "6", "7",
1006 "8", "9", "10", "11", "12", "13", "14", "15",
1007 "16", "17", "18", "19", "20", "21", "22", "23",
1008 "24", "25", "26", "27", "28", "29", "30", "31",
1010 /* SPE registers. */
1011 "spe_acc", "spefscr",
1012 /* Soft frame pointer. */
1016 #ifdef TARGET_REGNAMES
1017 static const char alt_reg_names[][8] =
1019 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
1020 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
1021 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
1022 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
1023 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
1024 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
1025 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
1026 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
1027 "mq", "lr", "ctr", "ap",
1028 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
1030 /* AltiVec registers. */
1031 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
1032 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
1033 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
1034 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
1036 /* SPE registers. */
1037 "spe_acc", "spefscr",
1038 /* Soft frame pointer. */
1043 #ifndef MASK_STRICT_ALIGN
1044 #define MASK_STRICT_ALIGN 0
1046 #ifndef TARGET_PROFILE_KERNEL
1047 #define TARGET_PROFILE_KERNEL 0
1050 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
1051 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
1053 /* Initialize the GCC target structure. */
1054 #undef TARGET_ATTRIBUTE_TABLE
1055 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
1056 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
1057 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
1059 #undef TARGET_ASM_ALIGNED_DI_OP
1060 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
1062 /* Default unaligned ops are only provided for ELF. Find the ops needed
1063 for non-ELF systems. */
1064 #ifndef OBJECT_FORMAT_ELF
1066 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
1068 #undef TARGET_ASM_UNALIGNED_HI_OP
1069 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
1070 #undef TARGET_ASM_UNALIGNED_SI_OP
1071 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
1072 #undef TARGET_ASM_UNALIGNED_DI_OP
1073 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
1076 #undef TARGET_ASM_UNALIGNED_HI_OP
1077 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
1078 #undef TARGET_ASM_UNALIGNED_SI_OP
1079 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
1080 #undef TARGET_ASM_UNALIGNED_DI_OP
1081 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
1082 #undef TARGET_ASM_ALIGNED_DI_OP
1083 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
1087 /* This hook deals with fixups for relocatable code and DI-mode objects
1089 #undef TARGET_ASM_INTEGER
1090 #define TARGET_ASM_INTEGER rs6000_assemble_integer
1092 #ifdef HAVE_GAS_HIDDEN
1093 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
1094 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
1097 #undef TARGET_HAVE_TLS
1098 #define TARGET_HAVE_TLS HAVE_AS_TLS
1100 #undef TARGET_CANNOT_FORCE_CONST_MEM
1101 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
1103 #undef TARGET_ASM_FUNCTION_PROLOGUE
1104 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
1105 #undef TARGET_ASM_FUNCTION_EPILOGUE
1106 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
1108 #undef TARGET_SCHED_VARIABLE_ISSUE
1109 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
1111 #undef TARGET_SCHED_ISSUE_RATE
1112 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
1113 #undef TARGET_SCHED_ADJUST_COST
1114 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
1115 #undef TARGET_SCHED_ADJUST_PRIORITY
1116 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
1117 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
1118 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
1119 #undef TARGET_SCHED_INIT
1120 #define TARGET_SCHED_INIT rs6000_sched_init
1121 #undef TARGET_SCHED_FINISH
1122 #define TARGET_SCHED_FINISH rs6000_sched_finish
1123 #undef TARGET_SCHED_REORDER
1124 #define TARGET_SCHED_REORDER rs6000_sched_reorder
1125 #undef TARGET_SCHED_REORDER2
1126 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
1128 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
1129 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
1131 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
1132 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard
1134 #undef TARGET_SCHED_ALLOC_SCHED_CONTEXT
1135 #define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context
1136 #undef TARGET_SCHED_INIT_SCHED_CONTEXT
1137 #define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context
1138 #undef TARGET_SCHED_SET_SCHED_CONTEXT
1139 #define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context
1140 #undef TARGET_SCHED_FREE_SCHED_CONTEXT
1141 #define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context
1143 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
1144 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
1145 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
1146 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
1147 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
1148 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
1149 #undef TARGET_VECTORIZE_BUILTIN_CONVERSION
1150 #define TARGET_VECTORIZE_BUILTIN_CONVERSION rs6000_builtin_conversion
1151 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM
1152 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM rs6000_builtin_vec_perm
1154 #undef TARGET_VECTOR_ALIGNMENT_REACHABLE
1155 #define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
1157 #undef TARGET_INIT_BUILTINS
1158 #define TARGET_INIT_BUILTINS rs6000_init_builtins
1160 #undef TARGET_EXPAND_BUILTIN
1161 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
1163 #undef TARGET_MANGLE_TYPE
1164 #define TARGET_MANGLE_TYPE rs6000_mangle_type
1166 #undef TARGET_INIT_LIBFUNCS
1167 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
1170 #undef TARGET_BINDS_LOCAL_P
1171 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
1174 #undef TARGET_MS_BITFIELD_LAYOUT_P
1175 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
1177 #undef TARGET_ASM_OUTPUT_MI_THUNK
1178 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
1180 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
1181 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
1183 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1184 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
1186 #undef TARGET_INVALID_WITHIN_DOLOOP
1187 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
1189 #undef TARGET_RTX_COSTS
1190 #define TARGET_RTX_COSTS rs6000_rtx_costs
1191 #undef TARGET_ADDRESS_COST
1192 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1194 #undef TARGET_VECTOR_OPAQUE_P
1195 #define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
1197 #undef TARGET_DWARF_REGISTER_SPAN
1198 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1200 #undef TARGET_INIT_DWARF_REG_SIZES_EXTRA
1201 #define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra
1203 /* On rs6000, function arguments are promoted, as are function return
1205 #undef TARGET_PROMOTE_FUNCTION_ARGS
1206 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true
1207 #undef TARGET_PROMOTE_FUNCTION_RETURN
1208 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true
1210 #undef TARGET_RETURN_IN_MEMORY
1211 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1213 #undef TARGET_SETUP_INCOMING_VARARGS
1214 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1216 /* Always strict argument naming on rs6000. */
1217 #undef TARGET_STRICT_ARGUMENT_NAMING
1218 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1219 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1220 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1221 #undef TARGET_SPLIT_COMPLEX_ARG
1222 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
1223 #undef TARGET_MUST_PASS_IN_STACK
1224 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1225 #undef TARGET_PASS_BY_REFERENCE
1226 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1227 #undef TARGET_ARG_PARTIAL_BYTES
1228 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1230 #undef TARGET_BUILD_BUILTIN_VA_LIST
1231 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1233 #undef TARGET_EXPAND_BUILTIN_VA_START
1234 #define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start
1236 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1237 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1239 #undef TARGET_EH_RETURN_FILTER_MODE
1240 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1242 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1243 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1245 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1246 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1248 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1249 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1251 #undef TARGET_HANDLE_OPTION
1252 #define TARGET_HANDLE_OPTION rs6000_handle_option
1254 #undef TARGET_DEFAULT_TARGET_FLAGS
1255 #define TARGET_DEFAULT_TARGET_FLAGS \
1258 #undef TARGET_STACK_PROTECT_FAIL
1259 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1261 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1262 The PowerPC architecture requires only weak consistency among
1263 processors--that is, memory accesses between processors need not be
1264 sequentially consistent and memory accesses among processors can occur
1265 in any order. The ability to order memory accesses weakly provides
1266 opportunities for more efficient use of the system bus. Unless a
1267 dependency exists, the 604e allows read operations to precede store
1269 #undef TARGET_RELAXED_ORDERING
1270 #define TARGET_RELAXED_ORDERING true
1273 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1274 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1277 /* Use a 32-bit anchor range. This leads to sequences like:
1279 addis tmp,anchor,high
1282 where tmp itself acts as an anchor, and can be shared between
1283 accesses to the same 64k page. */
1284 #undef TARGET_MIN_ANCHOR_OFFSET
1285 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1286 #undef TARGET_MAX_ANCHOR_OFFSET
1287 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1288 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1289 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1291 #undef TARGET_BUILTIN_RECIPROCAL
1292 #define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal
1294 #undef TARGET_EXPAND_TO_RTL_HOOK
1295 #define TARGET_EXPAND_TO_RTL_HOOK rs6000_alloc_sdmode_stack_slot
1297 #undef TARGET_INSTANTIATE_DECLS
1298 #define TARGET_INSTANTIATE_DECLS rs6000_instantiate_decls
1300 struct gcc_target targetm = TARGET_INITIALIZER;
1303 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1306 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1308 /* The GPRs can hold any mode, but values bigger than one register
1309 cannot go past R31. */
1310 if (INT_REGNO_P (regno))
1311 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1313 /* The float registers can only hold floating modes and DImode.
1314 This excludes the 32-bit decimal float mode for now. */
1315 if (FP_REGNO_P (regno))
1317 ((SCALAR_FLOAT_MODE_P (mode)
1318 && (mode != TDmode || (regno % 2) == 0)
1319 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1320 || (GET_MODE_CLASS (mode) == MODE_INT
1321 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
1322 || (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
1323 && PAIRED_VECTOR_MODE (mode)));
1325 /* The CR register can only hold CC modes. */
1326 if (CR_REGNO_P (regno))
1327 return GET_MODE_CLASS (mode) == MODE_CC;
1329 if (XER_REGNO_P (regno))
1330 return mode == PSImode;
1332 /* AltiVec only in AldyVec registers. */
1333 if (ALTIVEC_REGNO_P (regno))
1334 return ALTIVEC_VECTOR_MODE (mode);
1336 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1337 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1340 /* We cannot put TImode anywhere except general register and it must be
1341 able to fit within the register set. */
1343 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1346 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1348 rs6000_init_hard_regno_mode_ok (void)
1352 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1353 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1354 if (rs6000_hard_regno_mode_ok (r, m))
1355 rs6000_hard_regno_mode_ok_p[m][r] = true;
1359 /* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */
1362 darwin_rs6000_override_options (void)
1364 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
1366 rs6000_altivec_abi = 1;
1367 TARGET_ALTIVEC_VRSAVE = 1;
1368 if (DEFAULT_ABI == ABI_DARWIN)
1370 if (MACHO_DYNAMIC_NO_PIC_P)
1373 warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
1376 else if (flag_pic == 1)
1381 if (TARGET_64BIT && ! TARGET_POWERPC64)
1383 target_flags |= MASK_POWERPC64;
1384 warning (0, "-m64 requires PowerPC64 architecture, enabling");
1388 rs6000_default_long_calls = 1;
1389 target_flags |= MASK_SOFT_FLOAT;
1392 /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes
1394 if (!flag_mkernel && !flag_apple_kext
1396 && ! (target_flags_explicit & MASK_ALTIVEC))
1397 target_flags |= MASK_ALTIVEC;
1399 /* Unless the user (not the configurer) has explicitly overridden
1400 it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to
1401 G4 unless targetting the kernel. */
1404 && strverscmp (darwin_macosx_version_min, "10.5") >= 0
1405 && ! (target_flags_explicit & MASK_ALTIVEC)
1406 && ! rs6000_select[1].string)
1408 target_flags |= MASK_ALTIVEC;
1413 /* If not otherwise specified by a target, make 'long double' equivalent to
1416 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1417 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1420 /* Override command line options. Mostly we process the processor
1421 type and sometimes adjust other TARGET_ options. */
1424 rs6000_override_options (const char *default_cpu)
1427 struct rs6000_cpu_select *ptr;
1430 /* Simplifications for entries below. */
1433 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1434 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1437 /* This table occasionally claims that a processor does not support
1438 a particular feature even though it does, but the feature is slower
1439 than the alternative. Thus, it shouldn't be relied on as a
1440 complete description of the processor's support.
1442 Please keep this list in order, and don't forget to update the
1443 documentation in invoke.texi when adding a new processor or
1447 const char *const name; /* Canonical processor name. */
1448 const enum processor_type processor; /* Processor type enum value. */
1449 const int target_enable; /* Target flags to enable. */
1450 } const processor_target_table[]
1451 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1452 {"403", PROCESSOR_PPC403,
1453 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1454 {"405", PROCESSOR_PPC405,
1455 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1456 {"405fp", PROCESSOR_PPC405,
1457 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1458 {"440", PROCESSOR_PPC440,
1459 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1460 {"440fp", PROCESSOR_PPC440,
1461 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1462 {"464", PROCESSOR_PPC440,
1463 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1464 {"464fp", PROCESSOR_PPC440,
1465 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1466 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1467 {"601", PROCESSOR_PPC601,
1468 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1469 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1470 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1471 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1472 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1473 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1474 {"620", PROCESSOR_PPC620,
1475 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1476 {"630", PROCESSOR_PPC630,
1477 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1478 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1479 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1480 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1481 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1482 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1483 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1484 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1485 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
1486 /* 8548 has a dummy entry for now. */
1487 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
1488 {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1489 {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
1490 {"e500mc", PROCESSOR_PPCE500MC, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1491 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1492 {"970", PROCESSOR_POWER4,
1493 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1494 {"cell", PROCESSOR_CELL,
1495 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1496 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1497 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1498 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1499 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1500 {"G5", PROCESSOR_POWER4,
1501 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1502 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1503 {"power2", PROCESSOR_POWER,
1504 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1505 {"power3", PROCESSOR_PPC630,
1506 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1507 {"power4", PROCESSOR_POWER4,
1508 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1510 {"power5", PROCESSOR_POWER5,
1511 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1512 | MASK_MFCRF | MASK_POPCNTB},
1513 {"power5+", PROCESSOR_POWER5,
1514 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1515 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1516 {"power6", PROCESSOR_POWER6,
1517 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1518 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP},
1519 {"power6x", PROCESSOR_POWER6,
1520 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT
1521 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP
1523 {"power7", PROCESSOR_POWER5,
1524 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
1525 | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP},
1526 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1527 {"powerpc64", PROCESSOR_POWERPC64,
1528 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1529 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1530 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1531 {"rios2", PROCESSOR_RIOS2,
1532 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1533 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1534 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1535 {"rs64", PROCESSOR_RS64A,
1536 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1539 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1541 /* Some OSs don't support saving the high part of 64-bit registers on
1542 context switch. Other OSs don't support saving Altivec registers.
1543 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1544 settings; if the user wants either, the user must explicitly specify
1545 them and we won't interfere with the user's specification. */
1548 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1549 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT | MASK_STRICT_ALIGN
1550 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1551 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1552 | MASK_DLMZB | MASK_CMPB | MASK_MFPGPR | MASK_DFP)
1555 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1556 #ifdef OS_MISSING_POWERPC64
1557 if (OS_MISSING_POWERPC64)
1558 set_masks &= ~MASK_POWERPC64;
1560 #ifdef OS_MISSING_ALTIVEC
1561 if (OS_MISSING_ALTIVEC)
1562 set_masks &= ~MASK_ALTIVEC;
1565 /* Don't override by the processor default if given explicitly. */
1566 set_masks &= ~target_flags_explicit;
1568 /* Identify the processor type. */
1569 rs6000_select[0].string = default_cpu;
1570 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1572 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1574 ptr = &rs6000_select[i];
1575 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1577 for (j = 0; j < ptt_size; j++)
1578 if (! strcmp (ptr->string, processor_target_table[j].name))
1580 if (ptr->set_tune_p)
1581 rs6000_cpu = processor_target_table[j].processor;
1583 if (ptr->set_arch_p)
1585 target_flags &= ~set_masks;
1586 target_flags |= (processor_target_table[j].target_enable
1593 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1597 if ((TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC)
1598 && !rs6000_explicit_options.isel)
1601 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
1602 || rs6000_cpu == PROCESSOR_PPCE500MC)
1605 error ("AltiVec not supported in this target");
1607 error ("Spe not supported in this target");
1610 /* Disable cell micro code if we are optimizing for the cell
1611 and not optimizing for size. */
1612 if (rs6000_gen_cell_microcode == -1)
1613 rs6000_gen_cell_microcode = !(rs6000_cpu == PROCESSOR_CELL
1616 /* If we are optimizing big endian systems for space, use the load/store
1617 multiple and string instructions unless we are not generating
1619 if (BYTES_BIG_ENDIAN && optimize_size && !rs6000_gen_cell_microcode)
1620 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1622 /* Don't allow -mmultiple or -mstring on little endian systems
1623 unless the cpu is a 750, because the hardware doesn't support the
1624 instructions used in little endian mode, and causes an alignment
1625 trap. The 750 does not cause an alignment trap (except when the
1626 target is unaligned). */
1628 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1630 if (TARGET_MULTIPLE)
1632 target_flags &= ~MASK_MULTIPLE;
1633 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1634 warning (0, "-mmultiple is not supported on little endian systems");
1639 target_flags &= ~MASK_STRING;
1640 if ((target_flags_explicit & MASK_STRING) != 0)
1641 warning (0, "-mstring is not supported on little endian systems");
1645 /* Set debug flags */
1646 if (rs6000_debug_name)
1648 if (! strcmp (rs6000_debug_name, "all"))
1649 rs6000_debug_stack = rs6000_debug_arg = 1;
1650 else if (! strcmp (rs6000_debug_name, "stack"))
1651 rs6000_debug_stack = 1;
1652 else if (! strcmp (rs6000_debug_name, "arg"))
1653 rs6000_debug_arg = 1;
1655 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1658 if (rs6000_traceback_name)
1660 if (! strncmp (rs6000_traceback_name, "full", 4))
1661 rs6000_traceback = traceback_full;
1662 else if (! strncmp (rs6000_traceback_name, "part", 4))
1663 rs6000_traceback = traceback_part;
1664 else if (! strncmp (rs6000_traceback_name, "no", 2))
1665 rs6000_traceback = traceback_none;
1667 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1668 rs6000_traceback_name);
1671 if (!rs6000_explicit_options.long_double)
1672 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1674 #ifndef POWERPC_LINUX
1675 if (!rs6000_explicit_options.ieee)
1676 rs6000_ieeequad = 1;
1679 /* Enable Altivec ABI for AIX -maltivec. */
1680 if (TARGET_XCOFF && TARGET_ALTIVEC)
1681 rs6000_altivec_abi = 1;
1683 /* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For
1684 PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can
1685 be explicitly overridden in either case. */
1688 if (!rs6000_explicit_options.altivec_abi
1689 && (TARGET_64BIT || TARGET_ALTIVEC))
1690 rs6000_altivec_abi = 1;
1692 /* Enable VRSAVE for AltiVec ABI, unless explicitly overridden. */
1693 if (!rs6000_explicit_options.vrsave)
1694 TARGET_ALTIVEC_VRSAVE = rs6000_altivec_abi;
1697 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1698 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1700 rs6000_darwin64_abi = 1;
1702 darwin_one_byte_bool = 1;
1704 /* Default to natural alignment, for better performance. */
1705 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1708 /* Place FP constants in the constant pool instead of TOC
1709 if section anchors enabled. */
1710 if (flag_section_anchors)
1711 TARGET_NO_FP_IN_TOC = 1;
1713 /* Handle -mtls-size option. */
1714 rs6000_parse_tls_size_option ();
1716 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1717 SUBTARGET_OVERRIDE_OPTIONS;
1719 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1720 SUBSUBTARGET_OVERRIDE_OPTIONS;
1722 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1723 SUB3TARGET_OVERRIDE_OPTIONS;
1726 if (TARGET_E500 || rs6000_cpu == PROCESSOR_PPCE500MC)
1728 /* The e500 and e500mc do not have string instructions, and we set
1729 MASK_STRING above when optimizing for size. */
1730 if ((target_flags & MASK_STRING) != 0)
1731 target_flags = target_flags & ~MASK_STRING;
1733 else if (rs6000_select[1].string != NULL)
1735 /* For the powerpc-eabispe configuration, we set all these by
1736 default, so let's unset them if we manually set another
1737 CPU that is not the E500. */
1738 if (!rs6000_explicit_options.spe_abi)
1740 if (!rs6000_explicit_options.spe)
1742 if (!rs6000_explicit_options.float_gprs)
1743 rs6000_float_gprs = 0;
1744 if (!rs6000_explicit_options.isel)
1748 /* Detect invalid option combinations with E500. */
1751 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1752 && rs6000_cpu != PROCESSOR_POWER5
1753 && rs6000_cpu != PROCESSOR_POWER6
1754 && rs6000_cpu != PROCESSOR_CELL);
1755 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1756 || rs6000_cpu == PROCESSOR_POWER5);
1757 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
1758 || rs6000_cpu == PROCESSOR_POWER5
1759 || rs6000_cpu == PROCESSOR_POWER6);
1761 rs6000_sched_restricted_insns_priority
1762 = (rs6000_sched_groups ? 1 : 0);
1764 /* Handle -msched-costly-dep option. */
1765 rs6000_sched_costly_dep
1766 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1768 if (rs6000_sched_costly_dep_str)
1770 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1771 rs6000_sched_costly_dep = no_dep_costly;
1772 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1773 rs6000_sched_costly_dep = all_deps_costly;
1774 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1775 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1776 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1777 rs6000_sched_costly_dep = store_to_load_dep_costly;
1779 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1782 /* Handle -minsert-sched-nops option. */
1783 rs6000_sched_insert_nops
1784 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1786 if (rs6000_sched_insert_nops_str)
1788 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1789 rs6000_sched_insert_nops = sched_finish_none;
1790 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1791 rs6000_sched_insert_nops = sched_finish_pad_groups;
1792 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1793 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1795 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1798 #ifdef TARGET_REGNAMES
1799 /* If the user desires alternate register names, copy in the
1800 alternate names now. */
1801 if (TARGET_REGNAMES)
1802 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1805 /* Set aix_struct_return last, after the ABI is determined.
1806 If -maix-struct-return or -msvr4-struct-return was explicitly
1807 used, don't override with the ABI default. */
1808 if (!rs6000_explicit_options.aix_struct_ret)
1809 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
1811 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
1812 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1815 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1817 /* We can only guarantee the availability of DI pseudo-ops when
1818 assembling for 64-bit targets. */
1821 targetm.asm_out.aligned_op.di = NULL;
1822 targetm.asm_out.unaligned_op.di = NULL;
1825 /* Set branch target alignment, if not optimizing for size. */
1828 /* Cell wants to be aligned 8byte for dual issue. */
1829 if (rs6000_cpu == PROCESSOR_CELL)
1831 if (align_functions <= 0)
1832 align_functions = 8;
1833 if (align_jumps <= 0)
1835 if (align_loops <= 0)
1838 if (rs6000_align_branch_targets)
1840 if (align_functions <= 0)
1841 align_functions = 16;
1842 if (align_jumps <= 0)
1844 if (align_loops <= 0)
1847 if (align_jumps_max_skip <= 0)
1848 align_jumps_max_skip = 15;
1849 if (align_loops_max_skip <= 0)
1850 align_loops_max_skip = 15;
1853 /* Arrange to save and restore machine status around nested functions. */
1854 init_machine_status = rs6000_init_machine_status;
1856 /* We should always be splitting complex arguments, but we can't break
1857 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1858 if (DEFAULT_ABI != ABI_AIX)
1859 targetm.calls.split_complex_arg = NULL;
1861 /* Initialize rs6000_cost with the appropriate target costs. */
1863 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1867 case PROCESSOR_RIOS1:
1868 rs6000_cost = &rios1_cost;
1871 case PROCESSOR_RIOS2:
1872 rs6000_cost = &rios2_cost;
1875 case PROCESSOR_RS64A:
1876 rs6000_cost = &rs64a_cost;
1879 case PROCESSOR_MPCCORE:
1880 rs6000_cost = &mpccore_cost;
1883 case PROCESSOR_PPC403:
1884 rs6000_cost = &ppc403_cost;
1887 case PROCESSOR_PPC405:
1888 rs6000_cost = &ppc405_cost;
1891 case PROCESSOR_PPC440:
1892 rs6000_cost = &ppc440_cost;
1895 case PROCESSOR_PPC601:
1896 rs6000_cost = &ppc601_cost;
1899 case PROCESSOR_PPC603:
1900 rs6000_cost = &ppc603_cost;
1903 case PROCESSOR_PPC604:
1904 rs6000_cost = &ppc604_cost;
1907 case PROCESSOR_PPC604e:
1908 rs6000_cost = &ppc604e_cost;
1911 case PROCESSOR_PPC620:
1912 rs6000_cost = &ppc620_cost;
1915 case PROCESSOR_PPC630:
1916 rs6000_cost = &ppc630_cost;
1919 case PROCESSOR_CELL:
1920 rs6000_cost = &ppccell_cost;
1923 case PROCESSOR_PPC750:
1924 case PROCESSOR_PPC7400:
1925 rs6000_cost = &ppc750_cost;
1928 case PROCESSOR_PPC7450:
1929 rs6000_cost = &ppc7450_cost;
1932 case PROCESSOR_PPC8540:
1933 rs6000_cost = &ppc8540_cost;
1936 case PROCESSOR_PPCE300C2:
1937 case PROCESSOR_PPCE300C3:
1938 rs6000_cost = &ppce300c2c3_cost;
1941 case PROCESSOR_PPCE500MC:
1942 rs6000_cost = &ppce500mc_cost;
1945 case PROCESSOR_POWER4:
1946 case PROCESSOR_POWER5:
1947 rs6000_cost = &power4_cost;
1950 case PROCESSOR_POWER6:
1951 rs6000_cost = &power6_cost;
1958 if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES))
1959 set_param_value ("simultaneous-prefetches",
1960 rs6000_cost->simultaneous_prefetches);
1961 if (!PARAM_SET_P (PARAM_L1_CACHE_SIZE))
1962 set_param_value ("l1-cache-size", rs6000_cost->l1_cache_size);
1963 if (!PARAM_SET_P (PARAM_L1_CACHE_LINE_SIZE))
1964 set_param_value ("l1-cache-line-size", rs6000_cost->cache_line_size);
1965 if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
1966 set_param_value ("l2-cache-size", rs6000_cost->l2_cache_size);
1968 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
1969 can be optimized to ap = __builtin_next_arg (0). */
1970 if (DEFAULT_ABI != ABI_V4)
1971 targetm.expand_builtin_va_start = NULL;
1973 /* Set up single/double float flags.
1974 If TARGET_HARD_FLOAT is set, but neither single or double is set,
1975 then set both flags. */
1976 if (TARGET_HARD_FLOAT && TARGET_FPRS
1977 && rs6000_single_float == 0 && rs6000_double_float == 0)
1978 rs6000_single_float = rs6000_double_float = 1;
1980 /* Reset single and double FP flags if target is E500. */
1983 rs6000_single_float = rs6000_double_float = 0;
1984 if (TARGET_E500_SINGLE)
1985 rs6000_single_float = 1;
1986 if (TARGET_E500_DOUBLE)
1987 rs6000_single_float = rs6000_double_float = 1;
1990 rs6000_init_hard_regno_mode_ok ();
1993 /* Implement targetm.vectorize.builtin_mask_for_load. */
1995 rs6000_builtin_mask_for_load (void)
1998 return altivec_builtin_mask_for_load;
2003 /* Implement targetm.vectorize.builtin_conversion.
2004 Returns a decl of a function that implements conversion of an integer vector
2005 into a floating-point vector, or vice-versa. TYPE is the type of the integer
2006 side of the conversion.
2007 Return NULL_TREE if it is not available. */
2009 rs6000_builtin_conversion (enum tree_code code, tree type)
2011 if (!TARGET_ALTIVEC)
2016 case FIX_TRUNC_EXPR:
2017 switch (TYPE_MODE (type))
2020 return TYPE_UNSIGNED (type)
2021 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VCTUXS]
2022 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VCTSXS];
2028 switch (TYPE_MODE (type))
2031 return TYPE_UNSIGNED (type)
2032 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFUX]
2033 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VCFSX];
2043 /* Implement targetm.vectorize.builtin_mul_widen_even. */
2045 rs6000_builtin_mul_widen_even (tree type)
2047 if (!TARGET_ALTIVEC)
2050 switch (TYPE_MODE (type))
2053 return TYPE_UNSIGNED (type)
2054 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH]
2055 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
2058 return TYPE_UNSIGNED (type)
2059 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB]
2060 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
2066 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
2068 rs6000_builtin_mul_widen_odd (tree type)
2070 if (!TARGET_ALTIVEC)
2073 switch (TYPE_MODE (type))
2076 return TYPE_UNSIGNED (type)
2077 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH]
2078 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
2081 return TYPE_UNSIGNED (type)
2082 ? rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB]
2083 : rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
2090 /* Return true iff, data reference of TYPE can reach vector alignment (16)
2091 after applying N number of iterations. This routine does not determine
2092 how may iterations are required to reach desired alignment. */
2095 rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed)
2102 if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
2105 if (rs6000_alignment_flags == MASK_ALIGN_POWER)
2115 /* Assuming that all other types are naturally aligned. CHECKME! */
2120 /* Implement targetm.vectorize.builtin_vec_perm. */
2122 rs6000_builtin_vec_perm (tree type, tree *mask_element_type)
2126 *mask_element_type = unsigned_char_type_node;
2128 switch (TYPE_MODE (type))
2131 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_16QI];
2135 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_8HI];
2139 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SI];
2143 d = rs6000_builtin_decls[ALTIVEC_BUILTIN_VPERM_4SF];
2154 /* Handle generic options of the form -mfoo=yes/no.
2155 NAME is the option name.
2156 VALUE is the option value.
2157 FLAG is the pointer to the flag where to store a 1 or 0, depending on
2158 whether the option value is 'yes' or 'no' respectively. */
2160 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
2164 else if (!strcmp (value, "yes"))
2166 else if (!strcmp (value, "no"))
2169 error ("unknown -m%s= option specified: '%s'", name, value);
2172 /* Validate and record the size specified with the -mtls-size option. */
2175 rs6000_parse_tls_size_option (void)
2177 if (rs6000_tls_size_string == 0)
2179 else if (strcmp (rs6000_tls_size_string, "16") == 0)
2180 rs6000_tls_size = 16;
2181 else if (strcmp (rs6000_tls_size_string, "32") == 0)
2182 rs6000_tls_size = 32;
2183 else if (strcmp (rs6000_tls_size_string, "64") == 0)
2184 rs6000_tls_size = 64;
2186 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
2190 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
2192 if (DEFAULT_ABI == ABI_DARWIN)
2193 /* The Darwin libraries never set errno, so we might as well
2194 avoid calling them when that's the only reason we would. */
2195 flag_errno_math = 0;
2197 /* Double growth factor to counter reduced min jump length. */
2198 set_param_value ("max-grow-copy-bb-insns", 16);
2200 /* Enable section anchors by default.
2201 Skip section anchors for Objective C and Objective C++
2202 until front-ends fixed. */
2203 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
2204 flag_section_anchors = 2;
2207 static enum fpu_type_t
2208 rs6000_parse_fpu_option (const char *option)
2210 if (!strcmp("none", option)) return FPU_NONE;
2211 if (!strcmp("sp_lite", option)) return FPU_SF_LITE;
2212 if (!strcmp("dp_lite", option)) return FPU_DF_LITE;
2213 if (!strcmp("sp_full", option)) return FPU_SF_FULL;
2214 if (!strcmp("dp_full", option)) return FPU_DF_FULL;
2215 error("unknown value %s for -mfpu", option);
2219 /* Implement TARGET_HANDLE_OPTION. */
2222 rs6000_handle_option (size_t code, const char *arg, int value)
2224 enum fpu_type_t fpu_type = FPU_NONE;
2229 target_flags &= ~(MASK_POWER | MASK_POWER2
2230 | MASK_MULTIPLE | MASK_STRING);
2231 target_flags_explicit |= (MASK_POWER | MASK_POWER2
2232 | MASK_MULTIPLE | MASK_STRING);
2234 case OPT_mno_powerpc:
2235 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
2236 | MASK_PPC_GFXOPT | MASK_POWERPC64);
2237 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
2238 | MASK_PPC_GFXOPT | MASK_POWERPC64);
2241 target_flags &= ~MASK_MINIMAL_TOC;
2242 TARGET_NO_FP_IN_TOC = 0;
2243 TARGET_NO_SUM_IN_TOC = 0;
2244 target_flags_explicit |= MASK_MINIMAL_TOC;
2245 #ifdef TARGET_USES_SYSV4_OPT
2246 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
2247 just the same as -mminimal-toc. */
2248 target_flags |= MASK_MINIMAL_TOC;
2249 target_flags_explicit |= MASK_MINIMAL_TOC;
2253 #ifdef TARGET_USES_SYSV4_OPT
2255 /* Make -mtoc behave like -mminimal-toc. */
2256 target_flags |= MASK_MINIMAL_TOC;
2257 target_flags_explicit |= MASK_MINIMAL_TOC;
2261 #ifdef TARGET_USES_AIX64_OPT
2266 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
2267 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
2268 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
2271 #ifdef TARGET_USES_AIX64_OPT
2276 target_flags &= ~MASK_POWERPC64;
2277 target_flags_explicit |= MASK_POWERPC64;
2280 case OPT_minsert_sched_nops_:
2281 rs6000_sched_insert_nops_str = arg;
2284 case OPT_mminimal_toc:
2287 TARGET_NO_FP_IN_TOC = 0;
2288 TARGET_NO_SUM_IN_TOC = 0;
2295 target_flags |= (MASK_MULTIPLE | MASK_STRING);
2296 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
2303 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
2304 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
2308 case OPT_mpowerpc_gpopt:
2309 case OPT_mpowerpc_gfxopt:
2312 target_flags |= MASK_POWERPC;
2313 target_flags_explicit |= MASK_POWERPC;
2317 case OPT_maix_struct_return:
2318 case OPT_msvr4_struct_return:
2319 rs6000_explicit_options.aix_struct_ret = true;
2323 rs6000_explicit_options.vrsave = true;
2324 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
2328 rs6000_explicit_options.isel = true;
2329 rs6000_isel = value;
2333 rs6000_explicit_options.isel = true;
2334 rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
2338 rs6000_explicit_options.spe = true;
2343 rs6000_explicit_options.spe = true;
2344 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
2348 rs6000_debug_name = arg;
2351 #ifdef TARGET_USES_SYSV4_OPT
2353 rs6000_abi_name = arg;
2357 rs6000_sdata_name = arg;
2360 case OPT_mtls_size_:
2361 rs6000_tls_size_string = arg;
2364 case OPT_mrelocatable:
2367 target_flags |= MASK_MINIMAL_TOC;
2368 target_flags_explicit |= MASK_MINIMAL_TOC;
2369 TARGET_NO_FP_IN_TOC = 1;
2373 case OPT_mrelocatable_lib:
2376 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2377 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
2378 TARGET_NO_FP_IN_TOC = 1;
2382 target_flags &= ~MASK_RELOCATABLE;
2383 target_flags_explicit |= MASK_RELOCATABLE;
2389 if (!strcmp (arg, "altivec"))
2391 rs6000_explicit_options.altivec_abi = true;
2392 rs6000_altivec_abi = 1;
2394 /* Enabling the AltiVec ABI turns off the SPE ABI. */
2397 else if (! strcmp (arg, "no-altivec"))
2399 rs6000_explicit_options.altivec_abi = true;
2400 rs6000_altivec_abi = 0;
2402 else if (! strcmp (arg, "spe"))
2404 rs6000_explicit_options.spe_abi = true;
2406 rs6000_altivec_abi = 0;
2407 if (!TARGET_SPE_ABI)
2408 error ("not configured for ABI: '%s'", arg);
2410 else if (! strcmp (arg, "no-spe"))
2412 rs6000_explicit_options.spe_abi = true;
2416 /* These are here for testing during development only, do not
2417 document in the manual please. */
2418 else if (! strcmp (arg, "d64"))
2420 rs6000_darwin64_abi = 1;
2421 warning (0, "Using darwin64 ABI");
2423 else if (! strcmp (arg, "d32"))
2425 rs6000_darwin64_abi = 0;
2426 warning (0, "Using old darwin ABI");
2429 else if (! strcmp (arg, "ibmlongdouble"))
2431 rs6000_explicit_options.ieee = true;
2432 rs6000_ieeequad = 0;
2433 warning (0, "Using IBM extended precision long double");
2435 else if (! strcmp (arg, "ieeelongdouble"))
2437 rs6000_explicit_options.ieee = true;
2438 rs6000_ieeequad = 1;
2439 warning (0, "Using IEEE extended precision long double");
2444 error ("unknown ABI specified: '%s'", arg);
2450 rs6000_select[1].string = arg;
2454 rs6000_select[2].string = arg;
2457 case OPT_mtraceback_:
2458 rs6000_traceback_name = arg;
2461 case OPT_mfloat_gprs_:
2462 rs6000_explicit_options.float_gprs = true;
2463 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
2464 rs6000_float_gprs = 1;
2465 else if (! strcmp (arg, "double"))
2466 rs6000_float_gprs = 2;
2467 else if (! strcmp (arg, "no"))
2468 rs6000_float_gprs = 0;
2471 error ("invalid option for -mfloat-gprs: '%s'", arg);
2476 case OPT_mlong_double_:
2477 rs6000_explicit_options.long_double = true;
2478 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2479 if (value != 64 && value != 128)
2481 error ("Unknown switch -mlong-double-%s", arg);
2482 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
2486 rs6000_long_double_type_size = value;
2489 case OPT_msched_costly_dep_:
2490 rs6000_sched_costly_dep_str = arg;
2494 rs6000_explicit_options.alignment = true;
2495 if (! strcmp (arg, "power"))
2497 /* On 64-bit Darwin, power alignment is ABI-incompatible with
2498 some C library functions, so warn about it. The flag may be
2499 useful for performance studies from time to time though, so
2500 don't disable it entirely. */
2501 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2502 warning (0, "-malign-power is not supported for 64-bit Darwin;"
2503 " it is incompatible with the installed C and C++ libraries");
2504 rs6000_alignment_flags = MASK_ALIGN_POWER;
2506 else if (! strcmp (arg, "natural"))
2507 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2510 error ("unknown -malign-XXXXX option specified: '%s'", arg);
2515 case OPT_msingle_float:
2516 if (!TARGET_SINGLE_FPU)
2517 warning (0, "-msingle-float option equivalent to -mhard-float");
2518 /* -msingle-float implies -mno-double-float and TARGET_HARD_FLOAT. */
2519 rs6000_double_float = 0;
2520 target_flags &= ~MASK_SOFT_FLOAT;
2521 target_flags_explicit |= MASK_SOFT_FLOAT;
2524 case OPT_mdouble_float:
2525 /* -mdouble-float implies -msingle-float and TARGET_HARD_FLOAT. */
2526 rs6000_single_float = 1;
2527 target_flags &= ~MASK_SOFT_FLOAT;
2528 target_flags_explicit |= MASK_SOFT_FLOAT;
2531 case OPT_msimple_fpu:
2532 if (!TARGET_SINGLE_FPU)
2533 warning (0, "-msimple-fpu option ignored");
2536 case OPT_mhard_float:
2537 /* -mhard_float implies -msingle-float and -mdouble-float. */
2538 rs6000_single_float = rs6000_double_float = 1;
2541 case OPT_msoft_float:
2542 /* -msoft_float implies -mnosingle-float and -mnodouble-float. */
2543 rs6000_single_float = rs6000_double_float = 0;
2547 fpu_type = rs6000_parse_fpu_option(arg);
2548 if (fpu_type != FPU_NONE)
2549 /* If -mfpu is not none, then turn off SOFT_FLOAT, turn on HARD_FLOAT. */
2551 target_flags &= ~MASK_SOFT_FLOAT;
2552 target_flags_explicit |= MASK_SOFT_FLOAT;
2553 rs6000_xilinx_fpu = 1;
2554 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_SF_FULL)
2555 rs6000_single_float = 1;
2556 if (fpu_type == FPU_DF_LITE || fpu_type == FPU_DF_FULL)
2557 rs6000_single_float = rs6000_double_float = 1;
2558 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_DF_LITE)
2559 rs6000_simple_fpu = 1;
2563 /* -mfpu=none is equivalent to -msoft-float */
2564 target_flags |= MASK_SOFT_FLOAT;
2565 target_flags_explicit |= MASK_SOFT_FLOAT;
2566 rs6000_single_float = rs6000_double_float = 0;
2573 /* Do anything needed at the start of the asm file. */
2576 rs6000_file_start (void)
2580 const char *start = buffer;
2581 struct rs6000_cpu_select *ptr;
2582 const char *default_cpu = TARGET_CPU_DEFAULT;
2583 FILE *file = asm_out_file;
2585 default_file_start ();
2587 #ifdef TARGET_BI_ARCH
2588 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
2592 if (flag_verbose_asm)
2594 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
2595 rs6000_select[0].string = default_cpu;
2597 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2599 ptr = &rs6000_select[i];
2600 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2602 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
2607 if (PPC405_ERRATUM77)
2609 fprintf (file, "%s PPC405CR_ERRATUM77", start);
2613 #ifdef USING_ELFOS_H
2614 switch (rs6000_sdata)
2616 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
2617 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
2618 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
2619 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
2622 if (rs6000_sdata && g_switch_value)
2624 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
2634 #ifdef HAVE_AS_GNU_ATTRIBUTE
2635 if (TARGET_32BIT && DEFAULT_ABI == ABI_V4)
2637 fprintf (file, "\t.gnu_attribute 4, %d\n",
2638 ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT) ? 1
2639 : (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT) ? 3
2641 fprintf (file, "\t.gnu_attribute 8, %d\n",
2642 (TARGET_ALTIVEC_ABI ? 2
2643 : TARGET_SPE_ABI ? 3
2645 fprintf (file, "\t.gnu_attribute 12, %d\n",
2646 aix_struct_return ? 2 : 1);
2651 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
2653 switch_to_section (toc_section);
2654 switch_to_section (text_section);
2659 /* Return nonzero if this function is known to have a null epilogue. */
2662 direct_return (void)
2664 if (reload_completed)
2666 rs6000_stack_t *info = rs6000_stack_info ();
2668 if (info->first_gp_reg_save == 32
2669 && info->first_fp_reg_save == 64
2670 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
2671 && ! info->lr_save_p
2672 && ! info->cr_save_p
2673 && info->vrsave_mask == 0
2681 /* Return the number of instructions it takes to form a constant in an
2682 integer register. */
2685 num_insns_constant_wide (HOST_WIDE_INT value)
2687 /* signed constant loadable with {cal|addi} */
2688 if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000)
2691 /* constant loadable with {cau|addis} */
2692 else if ((value & 0xffff) == 0
2693 && (value >> 31 == -1 || value >> 31 == 0))
2696 #if HOST_BITS_PER_WIDE_INT == 64
2697 else if (TARGET_POWERPC64)
2699 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
2700 HOST_WIDE_INT high = value >> 31;
2702 if (high == 0 || high == -1)
2708 return num_insns_constant_wide (high) + 1;
2710 return (num_insns_constant_wide (high)
2711 + num_insns_constant_wide (low) + 1);
2720 num_insns_constant (rtx op, enum machine_mode mode)
2722 HOST_WIDE_INT low, high;
2724 switch (GET_CODE (op))
2727 #if HOST_BITS_PER_WIDE_INT == 64
2728 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
2729 && mask64_operand (op, mode))
2733 return num_insns_constant_wide (INTVAL (op));
2736 if (mode == SFmode || mode == SDmode)
2741 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2742 if (DECIMAL_FLOAT_MODE_P (mode))
2743 REAL_VALUE_TO_TARGET_DECIMAL32 (rv, l);
2745 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
2746 return num_insns_constant_wide ((HOST_WIDE_INT) l);
2749 if (mode == VOIDmode || mode == DImode)
2751 high = CONST_DOUBLE_HIGH (op);
2752 low = CONST_DOUBLE_LOW (op);
2759 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2760 if (DECIMAL_FLOAT_MODE_P (mode))
2761 REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
2763 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
2764 high = l[WORDS_BIG_ENDIAN == 0];
2765 low = l[WORDS_BIG_ENDIAN != 0];
2769 return (num_insns_constant_wide (low)
2770 + num_insns_constant_wide (high));
2773 if ((high == 0 && low >= 0)
2774 || (high == -1 && low < 0))
2775 return num_insns_constant_wide (low);
2777 else if (mask64_operand (op, mode))
2781 return num_insns_constant_wide (high) + 1;
2784 return (num_insns_constant_wide (high)
2785 + num_insns_constant_wide (low) + 1);
2793 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
2794 If the mode of OP is MODE_VECTOR_INT, this simply returns the
2795 corresponding element of the vector, but for V4SFmode and V2SFmode,
2796 the corresponding "float" is interpreted as an SImode integer. */
2799 const_vector_elt_as_int (rtx op, unsigned int elt)
2801 rtx tmp = CONST_VECTOR_ELT (op, elt);
2802 if (GET_MODE (op) == V4SFmode
2803 || GET_MODE (op) == V2SFmode)
2804 tmp = gen_lowpart (SImode, tmp);
2805 return INTVAL (tmp);
2808 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
2809 or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used
2810 depends on STEP and COPIES, one of which will be 1. If COPIES > 1,
2811 all items are set to the same value and contain COPIES replicas of the
2812 vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's
2813 operand and the others are set to the value of the operand's msb. */
2816 vspltis_constant (rtx op, unsigned step, unsigned copies)
2818 enum machine_mode mode = GET_MODE (op);
2819 enum machine_mode inner = GET_MODE_INNER (mode);
2822 unsigned nunits = GET_MODE_NUNITS (mode);
2823 unsigned bitsize = GET_MODE_BITSIZE (inner);
2824 unsigned mask = GET_MODE_MASK (inner);
2826 HOST_WIDE_INT val = const_vector_elt_as_int (op, nunits - 1);
2827 HOST_WIDE_INT splat_val = val;
2828 HOST_WIDE_INT msb_val = val > 0 ? 0 : -1;
2830 /* Construct the value to be splatted, if possible. If not, return 0. */
2831 for (i = 2; i <= copies; i *= 2)
2833 HOST_WIDE_INT small_val;
2835 small_val = splat_val >> bitsize;
2837 if (splat_val != ((small_val << bitsize) | (small_val & mask)))
2839 splat_val = small_val;
2842 /* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */
2843 if (EASY_VECTOR_15 (splat_val))
2846 /* Also check if we can splat, and then add the result to itself. Do so if
2847 the value is positive, of if the splat instruction is using OP's mode;
2848 for splat_val < 0, the splat and the add should use the same mode. */
2849 else if (EASY_VECTOR_15_ADD_SELF (splat_val)
2850 && (splat_val >= 0 || (step == 1 && copies == 1)))
2856 /* Check if VAL is present in every STEP-th element, and the
2857 other elements are filled with its most significant bit. */
2858 for (i = 0; i < nunits - 1; ++i)
2860 HOST_WIDE_INT desired_val;
2861 if (((i + 1) & (step - 1)) == 0)
2864 desired_val = msb_val;
2866 if (desired_val != const_vector_elt_as_int (op, i))
2874 /* Return true if OP is of the given MODE and can be synthesized
2875 with a vspltisb, vspltish or vspltisw. */
2878 easy_altivec_constant (rtx op, enum machine_mode mode)
2880 unsigned step, copies;
2882 if (mode == VOIDmode)
2883 mode = GET_MODE (op);
2884 else if (mode != GET_MODE (op))
2887 /* Start with a vspltisw. */
2888 step = GET_MODE_NUNITS (mode) / 4;
2891 if (vspltis_constant (op, step, copies))
2894 /* Then try with a vspltish. */
2900 if (vspltis_constant (op, step, copies))
2903 /* And finally a vspltisb. */
2909 if (vspltis_constant (op, step, copies))
2915 /* Generate a VEC_DUPLICATE representing a vspltis[bhw] instruction whose
2916 result is OP. Abort if it is not possible. */
2919 gen_easy_altivec_constant (rtx op)
2921 enum machine_mode mode = GET_MODE (op);
2922 int nunits = GET_MODE_NUNITS (mode);
2923 rtx last = CONST_VECTOR_ELT (op, nunits - 1);
2924 unsigned step = nunits / 4;
2925 unsigned copies = 1;
2927 /* Start with a vspltisw. */
2928 if (vspltis_constant (op, step, copies))
2929 return gen_rtx_VEC_DUPLICATE (V4SImode, gen_lowpart (SImode, last));
2931 /* Then try with a vspltish. */
2937 if (vspltis_constant (op, step, copies))
2938 return gen_rtx_VEC_DUPLICATE (V8HImode, gen_lowpart (HImode, last));
2940 /* And finally a vspltisb. */
2946 if (vspltis_constant (op, step, copies))
2947 return gen_rtx_VEC_DUPLICATE (V16QImode, gen_lowpart (QImode, last));
2953 output_vec_const_move (rtx *operands)
2956 enum machine_mode mode;
2961 mode = GET_MODE (dest);
2966 if (zero_constant (vec, mode))
2967 return "vxor %0,%0,%0";
2969 splat_vec = gen_easy_altivec_constant (vec);
2970 gcc_assert (GET_CODE (splat_vec) == VEC_DUPLICATE);
2971 operands[1] = XEXP (splat_vec, 0);
2972 if (!EASY_VECTOR_15 (INTVAL (operands[1])))
2975 switch (GET_MODE (splat_vec))
2978 return "vspltisw %0,%1";
2981 return "vspltish %0,%1";
2984 return "vspltisb %0,%1";
2991 gcc_assert (TARGET_SPE);
2993 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2994 pattern of V1DI, V4HI, and V2SF.
2996 FIXME: We should probably return # and add post reload
2997 splitters for these, but this way is so easy ;-). */
2998 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2999 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
3000 operands[1] = CONST_VECTOR_ELT (vec, 0);
3001 operands[2] = CONST_VECTOR_ELT (vec, 1);
3003 return "li %0,%1\n\tevmergelo %0,%0,%0";
3005 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
3008 /* Initialize TARGET of vector PAIRED to VALS. */
3011 paired_expand_vector_init (rtx target, rtx vals)
3013 enum machine_mode mode = GET_MODE (target);
3014 int n_elts = GET_MODE_NUNITS (mode);
3016 rtx x, new_rtx, tmp, constant_op, op1, op2;
3019 for (i = 0; i < n_elts; ++i)
3021 x = XVECEXP (vals, 0, i);
3022 if (!CONSTANT_P (x))
3027 /* Load from constant pool. */
3028 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
3034 /* The vector is initialized only with non-constants. */
3035 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, XVECEXP (vals, 0, 0),
3036 XVECEXP (vals, 0, 1));
3038 emit_move_insn (target, new_rtx);
3042 /* One field is non-constant and the other one is a constant. Load the
3043 constant from the constant pool and use ps_merge instruction to
3044 construct the whole vector. */
3045 op1 = XVECEXP (vals, 0, 0);
3046 op2 = XVECEXP (vals, 0, 1);
3048 constant_op = (CONSTANT_P (op1)) ? op1 : op2;
3050 tmp = gen_reg_rtx (GET_MODE (constant_op));
3051 emit_move_insn (tmp, constant_op);
3053 if (CONSTANT_P (op1))
3054 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, tmp, op2);
3056 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, op1, tmp);
3058 emit_move_insn (target, new_rtx);
3062 paired_expand_vector_move (rtx operands[])
3064 rtx op0 = operands[0], op1 = operands[1];
3066 emit_move_insn (op0, op1);
3069 /* Emit vector compare for code RCODE. DEST is destination, OP1 and
3070 OP2 are two VEC_COND_EXPR operands, CC_OP0 and CC_OP1 are the two
3071 operands for the relation operation COND. This is a recursive
3075 paired_emit_vector_compare (enum rtx_code rcode,
3076 rtx dest, rtx op0, rtx op1,
3077 rtx cc_op0, rtx cc_op1)
3079 rtx tmp = gen_reg_rtx (V2SFmode);
3080 rtx tmp1, max, min, equal_zero;
3082 gcc_assert (TARGET_PAIRED_FLOAT);
3083 gcc_assert (GET_MODE (op0) == GET_MODE (op1));
3089 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
3093 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
3094 emit_insn (gen_selv2sf4 (dest, tmp, op0, op1, CONST0_RTX (SFmode)));
3098 paired_emit_vector_compare (GE, dest, op0, op1, cc_op1, cc_op0);
3101 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
3104 tmp1 = gen_reg_rtx (V2SFmode);
3105 max = gen_reg_rtx (V2SFmode);
3106 min = gen_reg_rtx (V2SFmode);
3107 equal_zero = gen_reg_rtx (V2SFmode);
3109 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
3110 emit_insn (gen_selv2sf4
3111 (max, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
3112 emit_insn (gen_subv2sf3 (tmp, cc_op1, cc_op0));
3113 emit_insn (gen_selv2sf4
3114 (min, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
3115 emit_insn (gen_subv2sf3 (tmp1, min, max));
3116 emit_insn (gen_selv2sf4 (dest, tmp1, op0, op1, CONST0_RTX (SFmode)));
3119 paired_emit_vector_compare (EQ, dest, op1, op0, cc_op0, cc_op1);
3122 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
3125 paired_emit_vector_compare (LT, dest, op1, op0, cc_op0, cc_op1);
3128 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
3131 paired_emit_vector_compare (GT, dest, op1, op0, cc_op0, cc_op1);
3140 /* Emit vector conditional expression.
3141 DEST is destination. OP1 and OP2 are two VEC_COND_EXPR operands.
3142 CC_OP0 and CC_OP1 are the two operands for the relation operation COND. */
3145 paired_emit_vector_cond_expr (rtx dest, rtx op1, rtx op2,
3146 rtx cond, rtx cc_op0, rtx cc_op1)
3148 enum rtx_code rcode = GET_CODE (cond);
3150 if (!TARGET_PAIRED_FLOAT)
3153 paired_emit_vector_compare (rcode, dest, op1, op2, cc_op0, cc_op1);
3158 /* Initialize vector TARGET to VALS. */
3161 rs6000_expand_vector_init (rtx target, rtx vals)
3163 enum machine_mode mode = GET_MODE (target);
3164 enum machine_mode inner_mode = GET_MODE_INNER (mode);
3165 int n_elts = GET_MODE_NUNITS (mode);
3166 int n_var = 0, one_var = -1;
3167 bool all_same = true, all_const_zero = true;
3171 for (i = 0; i < n_elts; ++i)
3173 x = XVECEXP (vals, 0, i);
3174 if (!CONSTANT_P (x))
3175 ++n_var, one_var = i;
3176 else if (x != CONST0_RTX (inner_mode))
3177 all_const_zero = false;
3179 if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0)))
3185 rtx const_vec = gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0));
3186 if (mode != V4SFmode && all_const_zero)
3188 /* Zero register. */
3189 emit_insn (gen_rtx_SET (VOIDmode, target,
3190 gen_rtx_XOR (mode, target, target)));
3193 else if (mode != V4SFmode && easy_vector_constant (const_vec, mode))
3195 /* Splat immediate. */
3196 emit_insn (gen_rtx_SET (VOIDmode, target, const_vec));
3200 ; /* Splat vector element. */
3203 /* Load from constant pool. */
3204 emit_move_insn (target, const_vec);
3209 /* Store value to stack temp. Load vector element. Splat. */
3212 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
3213 emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
3214 XVECEXP (vals, 0, 0));
3215 x = gen_rtx_UNSPEC (VOIDmode,
3216 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
3217 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3219 gen_rtx_SET (VOIDmode,
3222 x = gen_rtx_VEC_SELECT (inner_mode, target,
3223 gen_rtx_PARALLEL (VOIDmode,
3224 gen_rtvec (1, const0_rtx)));
3225 emit_insn (gen_rtx_SET (VOIDmode, target,
3226 gen_rtx_VEC_DUPLICATE (mode, x)));
3230 /* One field is non-constant. Load constant then overwrite
3234 rtx copy = copy_rtx (vals);
3236 /* Load constant part of vector, substitute neighboring value for
3238 XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts);
3239 rs6000_expand_vector_init (target, copy);
3241 /* Insert variable. */
3242 rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), one_var);
3246 /* Construct the vector in memory one field at a time
3247 and load the whole vector. */
3248 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
3249 for (i = 0; i < n_elts; i++)
3250 emit_move_insn (adjust_address_nv (mem, inner_mode,
3251 i * GET_MODE_SIZE (inner_mode)),
3252 XVECEXP (vals, 0, i));
3253 emit_move_insn (target, mem);
3256 /* Set field ELT of TARGET to VAL. */
3259 rs6000_expand_vector_set (rtx target, rtx val, int elt)
3261 enum machine_mode mode = GET_MODE (target);
3262 enum machine_mode inner_mode = GET_MODE_INNER (mode);
3263 rtx reg = gen_reg_rtx (mode);
3265 int width = GET_MODE_SIZE (inner_mode);
3268 /* Load single variable value. */
3269 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
3270 emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val);
3271 x = gen_rtx_UNSPEC (VOIDmode,
3272 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
3273 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3275 gen_rtx_SET (VOIDmode,
3279 /* Linear sequence. */
3280 mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
3281 for (i = 0; i < 16; ++i)
3282 XVECEXP (mask, 0, i) = GEN_INT (i);
3284 /* Set permute mask to insert element into target. */
3285 for (i = 0; i < width; ++i)
3286 XVECEXP (mask, 0, elt*width + i)
3287 = GEN_INT (i + 0x10);
3288 x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
3289 x = gen_rtx_UNSPEC (mode,
3290 gen_rtvec (3, target, reg,
3291 force_reg (V16QImode, x)),
3293 emit_insn (gen_rtx_SET (VOIDmode, target, x));
3296 /* Extract field ELT from VEC into TARGET. */
3299 rs6000_expand_vector_extract (rtx target, rtx vec, int elt)
3301 enum machine_mode mode = GET_MODE (vec);
3302 enum machine_mode inner_mode = GET_MODE_INNER (mode);
3305 /* Allocate mode-sized buffer. */
3306 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
3308 /* Add offset to field within buffer matching vector element. */
3309 mem = adjust_address_nv (mem, mode, elt * GET_MODE_SIZE (inner_mode));
3311 /* Store single field into mode-sized buffer. */
3312 x = gen_rtx_UNSPEC (VOIDmode,
3313 gen_rtvec (1, const0_rtx), UNSPEC_STVE);
3314 emit_insn (gen_rtx_PARALLEL (VOIDmode,
3316 gen_rtx_SET (VOIDmode,
3319 emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0));
3322 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
3323 implement ANDing by the mask IN. */
3325 build_mask64_2_operands (rtx in, rtx *out)
3327 #if HOST_BITS_PER_WIDE_INT >= 64
3328 unsigned HOST_WIDE_INT c, lsb, m1, m2;
3331 gcc_assert (GET_CODE (in) == CONST_INT);
3336 /* Assume c initially something like 0x00fff000000fffff. The idea
3337 is to rotate the word so that the middle ^^^^^^ group of zeros
3338 is at the MS end and can be cleared with an rldicl mask. We then
3339 rotate back and clear off the MS ^^ group of zeros with a
3341 c = ~c; /* c == 0xff000ffffff00000 */
3342 lsb = c & -c; /* lsb == 0x0000000000100000 */
3343 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
3344 c = ~c; /* c == 0x00fff000000fffff */
3345 c &= -lsb; /* c == 0x00fff00000000000 */
3346 lsb = c & -c; /* lsb == 0x0000100000000000 */
3347 c = ~c; /* c == 0xff000fffffffffff */
3348 c &= -lsb; /* c == 0xff00000000000000 */
3350 while ((lsb >>= 1) != 0)
3351 shift++; /* shift == 44 on exit from loop */
3352 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
3353 m1 = ~m1; /* m1 == 0x000000ffffffffff */
3354 m2 = ~c; /* m2 == 0x00ffffffffffffff */
3358 /* Assume c initially something like 0xff000f0000000000. The idea
3359 is to rotate the word so that the ^^^ middle group of zeros
3360 is at the LS end and can be cleared with an rldicr mask. We then
3361 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
3363 lsb = c & -c; /* lsb == 0x0000010000000000 */
3364 m2 = -lsb; /* m2 == 0xffffff0000000000 */
3365 c = ~c; /* c == 0x00fff0ffffffffff */
3366 c &= -lsb; /* c == 0x00fff00000000000 */
3367 lsb = c & -c; /* lsb == 0x0000100000000000 */
3368 c = ~c; /* c == 0xff000fffffffffff */
3369 c &= -lsb; /* c == 0xff00000000000000 */
3371 while ((lsb >>= 1) != 0)
3372 shift++; /* shift == 44 on exit from loop */
3373 m1 = ~c; /* m1 == 0x00ffffffffffffff */
3374 m1 >>= shift; /* m1 == 0x0000000000000fff */
3375 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
3378 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
3379 masks will be all 1's. We are guaranteed more than one transition. */
3380 out[0] = GEN_INT (64 - shift);
3381 out[1] = GEN_INT (m1);
3382 out[2] = GEN_INT (shift);
3383 out[3] = GEN_INT (m2);
3391 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
3394 invalid_e500_subreg (rtx op, enum machine_mode mode)
3396 if (TARGET_E500_DOUBLE)
3398 /* Reject (subreg:SI (reg:DF)); likewise with subreg:DI or
3399 subreg:TI and reg:TF. Decimal float modes are like integer
3400 modes (only low part of each register used) for this
3402 if (GET_CODE (op) == SUBREG
3403 && (mode == SImode || mode == DImode || mode == TImode
3404 || mode == DDmode || mode == TDmode)
3405 && REG_P (SUBREG_REG (op))
3406 && (GET_MODE (SUBREG_REG (op)) == DFmode
3407 || GET_MODE (SUBREG_REG (op)) == TFmode))
3410 /* Reject (subreg:DF (reg:DI)); likewise with subreg:TF and
3412 if (GET_CODE (op) == SUBREG
3413 && (mode == DFmode || mode == TFmode)
3414 && REG_P (SUBREG_REG (op))
3415 && (GET_MODE (SUBREG_REG (op)) == DImode
3416 || GET_MODE (SUBREG_REG (op)) == TImode
3417 || GET_MODE (SUBREG_REG (op)) == DDmode
3418 || GET_MODE (SUBREG_REG (op)) == TDmode))
3423 && GET_CODE (op) == SUBREG
3425 && REG_P (SUBREG_REG (op))
3426 && SPE_VECTOR_MODE (GET_MODE (SUBREG_REG (op))))
3432 /* AIX increases natural record alignment to doubleword if the first
3433 field is an FP double while the FP fields remain word aligned. */
3436 rs6000_special_round_type_align (tree type, unsigned int computed,
3437 unsigned int specified)
3439 unsigned int align = MAX (computed, specified);
3440 tree field = TYPE_FIELDS (type);
3442 /* Skip all non field decls */
3443 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
3444 field = TREE_CHAIN (field);
3446 if (field != NULL && field != type)
3448 type = TREE_TYPE (field);
3449 while (TREE_CODE (type) == ARRAY_TYPE)
3450 type = TREE_TYPE (type);
3452 if (type != error_mark_node && TYPE_MODE (type) == DFmode)
3453 align = MAX (align, 64);
3459 /* Darwin increases record alignment to the natural alignment of
3463 darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
3464 unsigned int specified)
3466 unsigned int align = MAX (computed, specified);
3468 if (TYPE_PACKED (type))
3471 /* Find the first field, looking down into aggregates. */
3473 tree field = TYPE_FIELDS (type);
3474 /* Skip all non field decls */
3475 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
3476 field = TREE_CHAIN (field);
3479 type = TREE_TYPE (field);
3480 while (TREE_CODE (type) == ARRAY_TYPE)
3481 type = TREE_TYPE (type);
3482 } while (AGGREGATE_TYPE_P (type));
3484 if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
3485 align = MAX (align, TYPE_ALIGN (type));
3490 /* Return 1 for an operand in small memory on V.4/eabi. */
3493 small_data_operand (rtx op ATTRIBUTE_UNUSED,
3494 enum machine_mode mode ATTRIBUTE_UNUSED)
3499 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
3502 if (DEFAULT_ABI != ABI_V4)
3505 /* Vector and float memory instructions have a limited offset on the
3506 SPE, so using a vector or float variable directly as an operand is
3509 && (SPE_VECTOR_MODE (mode) || FLOAT_MODE_P (mode)))
3512 if (GET_CODE (op) == SYMBOL_REF)
3515 else if (GET_CODE (op) != CONST
3516 || GET_CODE (XEXP (op, 0)) != PLUS
3517 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
3518 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
3523 rtx sum = XEXP (op, 0);
3524 HOST_WIDE_INT summand;
3526 /* We have to be careful here, because it is the referenced address
3527 that must be 32k from _SDA_BASE_, not just the symbol. */
3528 summand = INTVAL (XEXP (sum, 1));
3529 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
3532 sym_ref = XEXP (sum, 0);
3535 return SYMBOL_REF_SMALL_P (sym_ref);
3541 /* Return true if either operand is a general purpose register. */
3544 gpr_or_gpr_p (rtx op0, rtx op1)
3546 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
3547 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
3551 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
3554 constant_pool_expr_p (rtx op)
3558 split_const (op, &base, &offset);
3559 return (GET_CODE (base) == SYMBOL_REF
3560 && CONSTANT_POOL_ADDRESS_P (base)
3561 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (base), Pmode));
3565 toc_relative_expr_p (rtx op)
3569 if (GET_CODE (op) != CONST)
3572 split_const (op, &base, &offset);
3573 return (GET_CODE (base) == UNSPEC
3574 && XINT (base, 1) == UNSPEC_TOCREL);
3578 legitimate_constant_pool_address_p (rtx x)
3581 && GET_CODE (x) == PLUS
3582 && GET_CODE (XEXP (x, 0)) == REG
3583 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
3584 && toc_relative_expr_p (XEXP (x, 1)));
3588 legitimate_small_data_p (enum machine_mode mode, rtx x)
3590 return (DEFAULT_ABI == ABI_V4
3591 && !flag_pic && !TARGET_TOC
3592 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
3593 && small_data_operand (x, mode));
3596 /* SPE offset addressing is limited to 5-bits worth of double words. */
3597 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
3600 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
3602 unsigned HOST_WIDE_INT offset, extra;
3604 if (GET_CODE (x) != PLUS)
3606 if (GET_CODE (XEXP (x, 0)) != REG)
3608 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3610 if (legitimate_constant_pool_address_p (x))
3612 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
3615 offset = INTVAL (XEXP (x, 1));
3623 /* AltiVec vector modes. Only reg+reg addressing is valid and
3624 constant offset zero should not occur due to canonicalization. */
3631 /* Paired vector modes. Only reg+reg addressing is valid and
3632 constant offset zero should not occur due to canonicalization. */
3633 if (TARGET_PAIRED_FLOAT)
3635 /* SPE vector modes. */
3636 return SPE_CONST_OFFSET_OK (offset);
3639 if (TARGET_E500_DOUBLE)
3640 return SPE_CONST_OFFSET_OK (offset);
3644 /* On e500v2, we may have:
3646 (subreg:DF (mem:DI (plus (reg) (const_int))) 0).
3648 Which gets addressed with evldd instructions. */
3649 if (TARGET_E500_DOUBLE)
3650 return SPE_CONST_OFFSET_OK (offset);
3652 if (mode == DFmode || mode == DDmode || !TARGET_POWERPC64)
3654 else if (offset & 3)
3659 if (TARGET_E500_DOUBLE)
3660 return (SPE_CONST_OFFSET_OK (offset)
3661 && SPE_CONST_OFFSET_OK (offset + 8));
3665 if (mode == TFmode || mode == TDmode || !TARGET_POWERPC64)
3667 else if (offset & 3)
3678 return (offset < 0x10000) && (offset + extra < 0x10000);
3682 legitimate_indexed_address_p (rtx x, int strict)
3686 if (GET_CODE (x) != PLUS)
3692 /* Recognize the rtl generated by reload which we know will later be
3693 replaced with proper base and index regs. */
3695 && reload_in_progress
3696 && (REG_P (op0) || GET_CODE (op0) == PLUS)
3700 return (REG_P (op0) && REG_P (op1)
3701 && ((INT_REG_OK_FOR_BASE_P (op0, strict)
3702 && INT_REG_OK_FOR_INDEX_P (op1, strict))
3703 || (INT_REG_OK_FOR_BASE_P (op1, strict)
3704 && INT_REG_OK_FOR_INDEX_P (op0, strict))));
3708 legitimate_indirect_address_p (rtx x, int strict)
3710 return GET_CODE (x) == REG && INT_REG_OK_FOR_BASE_P (x, strict);
3714 macho_lo_sum_memory_operand (rtx x, enum machine_mode mode)
3716 if (!TARGET_MACHO || !flag_pic
3717 || mode != SImode || GET_CODE (x) != MEM)
3721 if (GET_CODE (x) != LO_SUM)
3723 if (GET_CODE (XEXP (x, 0)) != REG)
3725 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0))
3729 return CONSTANT_P (x);
3733 legitimate_lo_sum_address_p (enum machine_mode mode, rtx x, int strict)
3735 if (GET_CODE (x) != LO_SUM)
3737 if (GET_CODE (XEXP (x, 0)) != REG)
3739 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3741 /* Restrict addressing for DI because of our SUBREG hackery. */
3742 if (TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3743 || mode == DDmode || mode == TDmode
3748 if (TARGET_ELF || TARGET_MACHO)
3750 if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
3754 if (GET_MODE_NUNITS (mode) != 1)
3756 if (GET_MODE_BITSIZE (mode) > 64
3757 || (GET_MODE_BITSIZE (mode) > 32 && !TARGET_POWERPC64
3758 && !(TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
3759 && (mode == DFmode || mode == DDmode))))
3762 return CONSTANT_P (x);
3769 /* Try machine-dependent ways of modifying an illegitimate address
3770 to be legitimate. If we find one, return the new, valid address.
3771 This is used from only one place: `memory_address' in explow.c.
3773 OLDX is the address as it was before break_out_memory_refs was
3774 called. In some cases it is useful to look at this to decide what
3777 MODE is passed so that this function can use GO_IF_LEGITIMATE_ADDRESS.
3779 It is always safe for this function to do nothing. It exists to
3780 recognize opportunities to optimize the output.
3782 On RS/6000, first check for the sum of a register with a constant
3783 integer that is out of range. If so, generate code to add the
3784 constant with the low-order 16 bits masked to the register and force
3785 this result into another register (this can be done with `cau').
3786 Then generate an address of REG+(CONST&0xffff), allowing for the
3787 possibility of bit 16 being a one.
3789 Then check for the sum of a register and something not constant, try to
3790 load the other things into a register and return the sum. */
3793 rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
3794 enum machine_mode mode)
3796 if (GET_CODE (x) == SYMBOL_REF)
3798 enum tls_model model = SYMBOL_REF_TLS_MODEL (x);
3800 return rs6000_legitimize_tls_address (x, model);
3803 if (GET_CODE (x) == PLUS
3804 && GET_CODE (XEXP (x, 0)) == REG
3805 && GET_CODE (XEXP (x, 1)) == CONST_INT
3806 && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) >= 0x10000
3807 && !(SPE_VECTOR_MODE (mode)
3808 || ALTIVEC_VECTOR_MODE (mode)
3809 || (TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3810 || mode == DImode || mode == DDmode
3811 || mode == TDmode))))
3813 HOST_WIDE_INT high_int, low_int;
3815 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
3816 high_int = INTVAL (XEXP (x, 1)) - low_int;
3817 sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0),
3818 GEN_INT (high_int)), 0);
3819 return gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));
3821 else if (GET_CODE (x) == PLUS
3822 && GET_CODE (XEXP (x, 0)) == REG
3823 && GET_CODE (XEXP (x, 1)) != CONST_INT
3824 && GET_MODE_NUNITS (mode) == 1
3825 && ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
3827 || ((mode != DImode && mode != DFmode && mode != DDmode)
3828 || (TARGET_E500_DOUBLE && mode != DDmode)))
3829 && (TARGET_POWERPC64 || mode != DImode)
3834 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
3835 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
3837 else if (ALTIVEC_VECTOR_MODE (mode))
3841 /* Make sure both operands are registers. */
3842 if (GET_CODE (x) == PLUS)
3843 return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)),
3844 force_reg (Pmode, XEXP (x, 1)));
3846 reg = force_reg (Pmode, x);
3849 else if (SPE_VECTOR_MODE (mode)
3850 || (TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
3851 || mode == DDmode || mode == TDmode
3852 || mode == DImode)))
3856 /* We accept [reg + reg] and [reg + OFFSET]. */
3858 if (GET_CODE (x) == PLUS)
3860 rtx op1 = XEXP (x, 0);
3861 rtx op2 = XEXP (x, 1);
3864 op1 = force_reg (Pmode, op1);
3866 if (GET_CODE (op2) != REG
3867 && (GET_CODE (op2) != CONST_INT
3868 || !SPE_CONST_OFFSET_OK (INTVAL (op2))
3869 || (GET_MODE_SIZE (mode) > 8
3870 && !SPE_CONST_OFFSET_OK (INTVAL (op2) + 8))))
3871 op2 = force_reg (Pmode, op2);
3873 /* We can't always do [reg + reg] for these, because [reg +
3874 reg + offset] is not a legitimate addressing mode. */
3875 y = gen_rtx_PLUS (Pmode, op1, op2);
3877 if ((GET_MODE_SIZE (mode) > 8 || mode == DDmode) && REG_P (op2))
3878 return force_reg (Pmode, y);
3883 return force_reg (Pmode, x);
3889 && GET_CODE (x) != CONST_INT
3890 && GET_CODE (x) != CONST_DOUBLE
3892 && GET_MODE_NUNITS (mode) == 1
3893 && (GET_MODE_BITSIZE (mode) <= 32
3894 || ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
3895 && (mode == DFmode || mode == DDmode))))
3897 rtx reg = gen_reg_rtx (Pmode);
3898 emit_insn (gen_elf_high (reg, x));
3899 return gen_rtx_LO_SUM (Pmode, reg, x);
3901 else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
3904 && ! MACHO_DYNAMIC_NO_PIC_P
3906 && GET_CODE (x) != CONST_INT
3907 && GET_CODE (x) != CONST_DOUBLE
3909 && GET_MODE_NUNITS (mode) == 1
3910 && ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
3911 || (mode != DFmode && mode != DDmode))
3915 rtx reg = gen_reg_rtx (Pmode);
3916 emit_insn (gen_macho_high (reg, x));
3917 return gen_rtx_LO_SUM (Pmode, reg, x);
3920 && GET_CODE (x) == SYMBOL_REF
3921 && constant_pool_expr_p (x)
3922 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
3924 return create_TOC_reference (x);
3930 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
3931 We need to emit DTP-relative relocations. */
3934 rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
3939 fputs ("\t.long\t", file);
3942 fputs (DOUBLE_INT_ASM_OP, file);
3947 output_addr_const (file, x);
3948 fputs ("@dtprel+0x8000", file);
3951 /* Construct the SYMBOL_REF for the tls_get_addr function. */
3953 static GTY(()) rtx rs6000_tls_symbol;
3955 rs6000_tls_get_addr (void)
3957 if (!rs6000_tls_symbol)
3958 rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr");
3960 return rs6000_tls_symbol;
3963 /* Construct the SYMBOL_REF for TLS GOT references. */
3965 static GTY(()) rtx rs6000_got_symbol;
3967 rs6000_got_sym (void)
3969 if (!rs6000_got_symbol)
3971 rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
3972 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL;
3973 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL;
3976 return rs6000_got_symbol;
3979 /* ADDR contains a thread-local SYMBOL_REF. Generate code to compute
3980 this (thread-local) address. */
3983 rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
3987 dest = gen_reg_rtx (Pmode);
3988 if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 16)
3994 tlsreg = gen_rtx_REG (Pmode, 13);
3995 insn = gen_tls_tprel_64 (dest, tlsreg, addr);
3999 tlsreg = gen_rtx_REG (Pmode, 2);
4000 insn = gen_tls_tprel_32 (dest, tlsreg, addr);
4004 else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32)
4008 tmp = gen_reg_rtx (Pmode);
4011 tlsreg = gen_rtx_REG (Pmode, 13);
4012 insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr);
4016 tlsreg = gen_rtx_REG (Pmode, 2);
4017 insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr);
4021 insn = gen_tls_tprel_lo_64 (dest, tmp, addr);
4023 insn = gen_tls_tprel_lo_32 (dest, tmp, addr);
4028 rtx r3, got, tga, tmp1, tmp2, eqv;