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 Free Software Foundation, Inc.
4 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the
20 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
54 #include "sched-int.h"
55 #include "tree-gimple.h"
58 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
61 #include "gstab.h" /* for N_SLINE */
64 #ifndef TARGET_NO_PROTOTYPE
65 #define TARGET_NO_PROTOTYPE 0
68 #define min(A,B) ((A) < (B) ? (A) : (B))
69 #define max(A,B) ((A) > (B) ? (A) : (B))
71 /* Structure used to define the rs6000 stack */
72 typedef struct rs6000_stack {
73 int first_gp_reg_save; /* first callee saved GP register used */
74 int first_fp_reg_save; /* first callee saved FP register used */
75 int first_altivec_reg_save; /* first callee saved AltiVec register used */
76 int lr_save_p; /* true if the link reg needs to be saved */
77 int cr_save_p; /* true if the CR reg needs to be saved */
78 unsigned int vrsave_mask; /* mask of vec registers to save */
79 int toc_save_p; /* true if the TOC needs to be saved */
80 int push_p; /* true if we need to allocate stack space */
81 int calls_p; /* true if the function makes any calls */
82 int world_save_p; /* true if we're saving *everything*:
83 r13-r31, cr, f14-f31, vrsave, v20-v31 */
84 enum rs6000_abi abi; /* which ABI to use */
85 int gp_save_offset; /* offset to save GP regs from initial SP */
86 int fp_save_offset; /* offset to save FP regs from initial SP */
87 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
88 int lr_save_offset; /* offset to save LR from initial SP */
89 int cr_save_offset; /* offset to save CR from initial SP */
90 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
91 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
92 int toc_save_offset; /* offset to save the TOC pointer */
93 int varargs_save_offset; /* offset to save the varargs registers */
94 int ehrd_offset; /* offset to EH return data */
95 int reg_size; /* register size (4 or 8) */
96 HOST_WIDE_INT vars_size; /* variable save area size */
97 int parm_size; /* outgoing parameter size */
98 int save_size; /* save area size */
99 int fixed_size; /* fixed size of stack frame */
100 int gp_size; /* size of saved GP registers */
101 int fp_size; /* size of saved FP registers */
102 int altivec_size; /* size of saved AltiVec registers */
103 int cr_size; /* size to hold CR if not in save_size */
104 int lr_size; /* size to hold LR 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 int toc_size; /* size to hold TOC if not in save_size */
111 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
112 int spe_64bit_regs_used;
115 /* A C structure for machine-specific, per-function data.
116 This is added to the cfun structure. */
117 typedef struct machine_function GTY(())
119 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
120 int ra_needs_full_frame;
121 /* Some local-dynamic symbol. */
122 const char *some_ld_name;
123 /* Whether the instruction chain has been scanned already. */
124 int insn_chain_scanned_p;
125 /* Flags if __builtin_return_address (0) was used. */
127 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
128 varargs save area. */
129 HOST_WIDE_INT varargs_save_offset;
132 /* Target cpu type */
134 enum processor_type rs6000_cpu;
135 struct rs6000_cpu_select rs6000_select[3] =
137 /* switch name, tune arch */
138 { (const char *)0, "--with-cpu=", 1, 1 },
139 { (const char *)0, "-mcpu=", 1, 1 },
140 { (const char *)0, "-mtune=", 1, 0 },
143 /* Always emit branch hint bits. */
144 static GTY(()) bool rs6000_always_hint;
146 /* Schedule instructions for group formation. */
147 static GTY(()) bool rs6000_sched_groups;
149 /* Support for -msched-costly-dep option. */
150 const char *rs6000_sched_costly_dep_str;
151 enum rs6000_dependence_cost rs6000_sched_costly_dep;
153 /* Support for -minsert-sched-nops option. */
154 const char *rs6000_sched_insert_nops_str;
155 enum rs6000_nop_insertion rs6000_sched_insert_nops;
157 /* Support targetm.vectorize.builtin_mask_for_load. */
158 static GTY(()) tree altivec_builtin_mask_for_load;
160 /* Size of long double */
161 int rs6000_long_double_type_size;
163 /* Whether -mabi=altivec has appeared */
164 int rs6000_altivec_abi;
166 /* Nonzero if we want SPE ABI extensions. */
169 /* Nonzero if floating point operations are done in the GPRs. */
170 int rs6000_float_gprs = 0;
172 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
173 int rs6000_darwin64_abi;
175 /* Set to nonzero once AIX common-mode calls have been defined. */
176 static GTY(()) int common_mode_defined;
178 /* Save information from a "cmpxx" operation until the branch or scc is
180 rtx rs6000_compare_op0, rs6000_compare_op1;
181 int rs6000_compare_fp_p;
183 /* Label number of label created for -mrelocatable, to call to so we can
184 get the address of the GOT section */
185 int rs6000_pic_labelno;
188 /* Which abi to adhere to */
189 const char *rs6000_abi_name;
191 /* Semantics of the small data area */
192 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
194 /* Which small data model to use */
195 const char *rs6000_sdata_name = (char *)0;
197 /* Counter for labels which are to be placed in .fixup. */
198 int fixuplabelno = 0;
201 /* Bit size of immediate TLS offsets and string from which it is decoded. */
202 int rs6000_tls_size = 32;
203 const char *rs6000_tls_size_string;
205 /* ABI enumeration available for subtarget to use. */
206 enum rs6000_abi rs6000_current_abi;
208 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
212 const char *rs6000_debug_name;
213 int rs6000_debug_stack; /* debug stack applications */
214 int rs6000_debug_arg; /* debug argument handling */
216 /* Value is TRUE if register/mode pair is acceptable. */
217 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
219 /* Built in types. */
221 tree rs6000_builtin_types[RS6000_BTI_MAX];
222 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
224 const char *rs6000_traceback_name;
226 traceback_default = 0,
232 /* Flag to say the TOC is initialized */
234 char toc_label_name[10];
236 /* Alias set for saves and restores from the rs6000 stack. */
237 static GTY(()) int rs6000_sr_alias_set;
239 /* Control alignment for fields within structures. */
240 /* String from -malign-XXXXX. */
241 int rs6000_alignment_flags;
243 /* True for any options that were explicitly set. */
245 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
246 bool alignment; /* True if -malign- was used. */
247 bool abi; /* True if -mabi= was used. */
248 bool spe; /* True if -mspe= was used. */
249 bool float_gprs; /* True if -mfloat-gprs= was used. */
250 bool isel; /* True if -misel was used. */
251 bool long_double; /* True if -mlong-double- was used. */
252 } rs6000_explicit_options;
254 struct builtin_description
256 /* mask is not const because we're going to alter it below. This
257 nonsense will go away when we rewrite the -march infrastructure
258 to give us more target flag bits. */
260 const enum insn_code icode;
261 const char *const name;
262 const enum rs6000_builtins code;
265 /* Target cpu costs. */
267 struct processor_costs {
268 const int mulsi; /* cost of SImode multiplication. */
269 const int mulsi_const; /* cost of SImode multiplication by constant. */
270 const int mulsi_const9; /* cost of SImode mult by short constant. */
271 const int muldi; /* cost of DImode multiplication. */
272 const int divsi; /* cost of SImode division. */
273 const int divdi; /* cost of DImode division. */
274 const int fp; /* cost of simple SFmode and DFmode insns. */
275 const int dmul; /* cost of DFmode multiplication (and fmadd). */
276 const int sdiv; /* cost of SFmode division (fdivs). */
277 const int ddiv; /* cost of DFmode division (fdiv). */
280 const struct processor_costs *rs6000_cost;
282 /* Processor costs (relative to an add) */
284 /* Instruction size costs on 32bit processors. */
286 struct processor_costs size32_cost = {
287 COSTS_N_INSNS (1), /* mulsi */
288 COSTS_N_INSNS (1), /* mulsi_const */
289 COSTS_N_INSNS (1), /* mulsi_const9 */
290 COSTS_N_INSNS (1), /* muldi */
291 COSTS_N_INSNS (1), /* divsi */
292 COSTS_N_INSNS (1), /* divdi */
293 COSTS_N_INSNS (1), /* fp */
294 COSTS_N_INSNS (1), /* dmul */
295 COSTS_N_INSNS (1), /* sdiv */
296 COSTS_N_INSNS (1), /* ddiv */
299 /* Instruction size costs on 64bit processors. */
301 struct processor_costs size64_cost = {
302 COSTS_N_INSNS (1), /* mulsi */
303 COSTS_N_INSNS (1), /* mulsi_const */
304 COSTS_N_INSNS (1), /* mulsi_const9 */
305 COSTS_N_INSNS (1), /* muldi */
306 COSTS_N_INSNS (1), /* divsi */
307 COSTS_N_INSNS (1), /* divdi */
308 COSTS_N_INSNS (1), /* fp */
309 COSTS_N_INSNS (1), /* dmul */
310 COSTS_N_INSNS (1), /* sdiv */
311 COSTS_N_INSNS (1), /* ddiv */
314 /* Instruction costs on RIOS1 processors. */
316 struct processor_costs rios1_cost = {
317 COSTS_N_INSNS (5), /* mulsi */
318 COSTS_N_INSNS (4), /* mulsi_const */
319 COSTS_N_INSNS (3), /* mulsi_const9 */
320 COSTS_N_INSNS (5), /* muldi */
321 COSTS_N_INSNS (19), /* divsi */
322 COSTS_N_INSNS (19), /* divdi */
323 COSTS_N_INSNS (2), /* fp */
324 COSTS_N_INSNS (2), /* dmul */
325 COSTS_N_INSNS (19), /* sdiv */
326 COSTS_N_INSNS (19), /* ddiv */
329 /* Instruction costs on RIOS2 processors. */
331 struct processor_costs rios2_cost = {
332 COSTS_N_INSNS (2), /* mulsi */
333 COSTS_N_INSNS (2), /* mulsi_const */
334 COSTS_N_INSNS (2), /* mulsi_const9 */
335 COSTS_N_INSNS (2), /* muldi */
336 COSTS_N_INSNS (13), /* divsi */
337 COSTS_N_INSNS (13), /* divdi */
338 COSTS_N_INSNS (2), /* fp */
339 COSTS_N_INSNS (2), /* dmul */
340 COSTS_N_INSNS (17), /* sdiv */
341 COSTS_N_INSNS (17), /* ddiv */
344 /* Instruction costs on RS64A processors. */
346 struct processor_costs rs64a_cost = {
347 COSTS_N_INSNS (20), /* mulsi */
348 COSTS_N_INSNS (12), /* mulsi_const */
349 COSTS_N_INSNS (8), /* mulsi_const9 */
350 COSTS_N_INSNS (34), /* muldi */
351 COSTS_N_INSNS (65), /* divsi */
352 COSTS_N_INSNS (67), /* divdi */
353 COSTS_N_INSNS (4), /* fp */
354 COSTS_N_INSNS (4), /* dmul */
355 COSTS_N_INSNS (31), /* sdiv */
356 COSTS_N_INSNS (31), /* ddiv */
359 /* Instruction costs on MPCCORE processors. */
361 struct processor_costs mpccore_cost = {
362 COSTS_N_INSNS (2), /* mulsi */
363 COSTS_N_INSNS (2), /* mulsi_const */
364 COSTS_N_INSNS (2), /* mulsi_const9 */
365 COSTS_N_INSNS (2), /* muldi */
366 COSTS_N_INSNS (6), /* divsi */
367 COSTS_N_INSNS (6), /* divdi */
368 COSTS_N_INSNS (4), /* fp */
369 COSTS_N_INSNS (5), /* dmul */
370 COSTS_N_INSNS (10), /* sdiv */
371 COSTS_N_INSNS (17), /* ddiv */
374 /* Instruction costs on PPC403 processors. */
376 struct processor_costs ppc403_cost = {
377 COSTS_N_INSNS (4), /* mulsi */
378 COSTS_N_INSNS (4), /* mulsi_const */
379 COSTS_N_INSNS (4), /* mulsi_const9 */
380 COSTS_N_INSNS (4), /* muldi */
381 COSTS_N_INSNS (33), /* divsi */
382 COSTS_N_INSNS (33), /* divdi */
383 COSTS_N_INSNS (11), /* fp */
384 COSTS_N_INSNS (11), /* dmul */
385 COSTS_N_INSNS (11), /* sdiv */
386 COSTS_N_INSNS (11), /* ddiv */
389 /* Instruction costs on PPC405 processors. */
391 struct processor_costs ppc405_cost = {
392 COSTS_N_INSNS (5), /* mulsi */
393 COSTS_N_INSNS (4), /* mulsi_const */
394 COSTS_N_INSNS (3), /* mulsi_const9 */
395 COSTS_N_INSNS (5), /* muldi */
396 COSTS_N_INSNS (35), /* divsi */
397 COSTS_N_INSNS (35), /* divdi */
398 COSTS_N_INSNS (11), /* fp */
399 COSTS_N_INSNS (11), /* dmul */
400 COSTS_N_INSNS (11), /* sdiv */
401 COSTS_N_INSNS (11), /* ddiv */
404 /* Instruction costs on PPC440 processors. */
406 struct processor_costs ppc440_cost = {
407 COSTS_N_INSNS (3), /* mulsi */
408 COSTS_N_INSNS (2), /* mulsi_const */
409 COSTS_N_INSNS (2), /* mulsi_const9 */
410 COSTS_N_INSNS (3), /* muldi */
411 COSTS_N_INSNS (34), /* divsi */
412 COSTS_N_INSNS (34), /* divdi */
413 COSTS_N_INSNS (5), /* fp */
414 COSTS_N_INSNS (5), /* dmul */
415 COSTS_N_INSNS (19), /* sdiv */
416 COSTS_N_INSNS (33), /* ddiv */
419 /* Instruction costs on PPC601 processors. */
421 struct processor_costs ppc601_cost = {
422 COSTS_N_INSNS (5), /* mulsi */
423 COSTS_N_INSNS (5), /* mulsi_const */
424 COSTS_N_INSNS (5), /* mulsi_const9 */
425 COSTS_N_INSNS (5), /* muldi */
426 COSTS_N_INSNS (36), /* divsi */
427 COSTS_N_INSNS (36), /* divdi */
428 COSTS_N_INSNS (4), /* fp */
429 COSTS_N_INSNS (5), /* dmul */
430 COSTS_N_INSNS (17), /* sdiv */
431 COSTS_N_INSNS (31), /* ddiv */
434 /* Instruction costs on PPC603 processors. */
436 struct processor_costs ppc603_cost = {
437 COSTS_N_INSNS (5), /* mulsi */
438 COSTS_N_INSNS (3), /* mulsi_const */
439 COSTS_N_INSNS (2), /* mulsi_const9 */
440 COSTS_N_INSNS (5), /* muldi */
441 COSTS_N_INSNS (37), /* divsi */
442 COSTS_N_INSNS (37), /* divdi */
443 COSTS_N_INSNS (3), /* fp */
444 COSTS_N_INSNS (4), /* dmul */
445 COSTS_N_INSNS (18), /* sdiv */
446 COSTS_N_INSNS (33), /* ddiv */
449 /* Instruction costs on PPC604 processors. */
451 struct processor_costs ppc604_cost = {
452 COSTS_N_INSNS (4), /* mulsi */
453 COSTS_N_INSNS (4), /* mulsi_const */
454 COSTS_N_INSNS (4), /* mulsi_const9 */
455 COSTS_N_INSNS (4), /* muldi */
456 COSTS_N_INSNS (20), /* divsi */
457 COSTS_N_INSNS (20), /* divdi */
458 COSTS_N_INSNS (3), /* fp */
459 COSTS_N_INSNS (3), /* dmul */
460 COSTS_N_INSNS (18), /* sdiv */
461 COSTS_N_INSNS (32), /* ddiv */
464 /* Instruction costs on PPC604e processors. */
466 struct processor_costs ppc604e_cost = {
467 COSTS_N_INSNS (2), /* mulsi */
468 COSTS_N_INSNS (2), /* mulsi_const */
469 COSTS_N_INSNS (2), /* mulsi_const9 */
470 COSTS_N_INSNS (2), /* muldi */
471 COSTS_N_INSNS (20), /* divsi */
472 COSTS_N_INSNS (20), /* divdi */
473 COSTS_N_INSNS (3), /* fp */
474 COSTS_N_INSNS (3), /* dmul */
475 COSTS_N_INSNS (18), /* sdiv */
476 COSTS_N_INSNS (32), /* ddiv */
479 /* Instruction costs on PPC620 processors. */
481 struct processor_costs ppc620_cost = {
482 COSTS_N_INSNS (5), /* mulsi */
483 COSTS_N_INSNS (4), /* mulsi_const */
484 COSTS_N_INSNS (3), /* mulsi_const9 */
485 COSTS_N_INSNS (7), /* muldi */
486 COSTS_N_INSNS (21), /* divsi */
487 COSTS_N_INSNS (37), /* divdi */
488 COSTS_N_INSNS (3), /* fp */
489 COSTS_N_INSNS (3), /* dmul */
490 COSTS_N_INSNS (18), /* sdiv */
491 COSTS_N_INSNS (32), /* ddiv */
494 /* Instruction costs on PPC630 processors. */
496 struct processor_costs ppc630_cost = {
497 COSTS_N_INSNS (5), /* mulsi */
498 COSTS_N_INSNS (4), /* mulsi_const */
499 COSTS_N_INSNS (3), /* mulsi_const9 */
500 COSTS_N_INSNS (7), /* muldi */
501 COSTS_N_INSNS (21), /* divsi */
502 COSTS_N_INSNS (37), /* divdi */
503 COSTS_N_INSNS (3), /* fp */
504 COSTS_N_INSNS (3), /* dmul */
505 COSTS_N_INSNS (17), /* sdiv */
506 COSTS_N_INSNS (21), /* ddiv */
509 /* Instruction costs on PPC750 and PPC7400 processors. */
511 struct processor_costs ppc750_cost = {
512 COSTS_N_INSNS (5), /* mulsi */
513 COSTS_N_INSNS (3), /* mulsi_const */
514 COSTS_N_INSNS (2), /* mulsi_const9 */
515 COSTS_N_INSNS (5), /* muldi */
516 COSTS_N_INSNS (17), /* divsi */
517 COSTS_N_INSNS (17), /* divdi */
518 COSTS_N_INSNS (3), /* fp */
519 COSTS_N_INSNS (3), /* dmul */
520 COSTS_N_INSNS (17), /* sdiv */
521 COSTS_N_INSNS (31), /* ddiv */
524 /* Instruction costs on PPC7450 processors. */
526 struct processor_costs ppc7450_cost = {
527 COSTS_N_INSNS (4), /* mulsi */
528 COSTS_N_INSNS (3), /* mulsi_const */
529 COSTS_N_INSNS (3), /* mulsi_const9 */
530 COSTS_N_INSNS (4), /* muldi */
531 COSTS_N_INSNS (23), /* divsi */
532 COSTS_N_INSNS (23), /* divdi */
533 COSTS_N_INSNS (5), /* fp */
534 COSTS_N_INSNS (5), /* dmul */
535 COSTS_N_INSNS (21), /* sdiv */
536 COSTS_N_INSNS (35), /* ddiv */
539 /* Instruction costs on PPC8540 processors. */
541 struct processor_costs ppc8540_cost = {
542 COSTS_N_INSNS (4), /* mulsi */
543 COSTS_N_INSNS (4), /* mulsi_const */
544 COSTS_N_INSNS (4), /* mulsi_const9 */
545 COSTS_N_INSNS (4), /* muldi */
546 COSTS_N_INSNS (19), /* divsi */
547 COSTS_N_INSNS (19), /* divdi */
548 COSTS_N_INSNS (4), /* fp */
549 COSTS_N_INSNS (4), /* dmul */
550 COSTS_N_INSNS (29), /* sdiv */
551 COSTS_N_INSNS (29), /* ddiv */
554 /* Instruction costs on POWER4 and POWER5 processors. */
556 struct processor_costs power4_cost = {
557 COSTS_N_INSNS (3), /* mulsi */
558 COSTS_N_INSNS (2), /* mulsi_const */
559 COSTS_N_INSNS (2), /* mulsi_const9 */
560 COSTS_N_INSNS (4), /* muldi */
561 COSTS_N_INSNS (18), /* divsi */
562 COSTS_N_INSNS (34), /* divdi */
563 COSTS_N_INSNS (3), /* fp */
564 COSTS_N_INSNS (3), /* dmul */
565 COSTS_N_INSNS (17), /* sdiv */
566 COSTS_N_INSNS (17), /* ddiv */
570 static bool rs6000_function_ok_for_sibcall (tree, tree);
571 static const char *rs6000_invalid_within_doloop (rtx);
572 static rtx rs6000_generate_compare (enum rtx_code);
573 static void rs6000_maybe_dead (rtx);
574 static void rs6000_emit_stack_tie (void);
575 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
576 static rtx spe_synthesize_frame_save (rtx);
577 static bool spe_func_has_64bit_regs_p (void);
578 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
580 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
581 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int);
582 static unsigned rs6000_hash_constant (rtx);
583 static unsigned toc_hash_function (const void *);
584 static int toc_hash_eq (const void *, const void *);
585 static int constant_pool_expr_1 (rtx, int *, int *);
586 static bool constant_pool_expr_p (rtx);
587 static bool legitimate_indexed_address_p (rtx, int);
588 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
589 static struct machine_function * rs6000_init_machine_status (void);
590 static bool rs6000_assemble_integer (rtx, unsigned int, int);
591 static bool no_global_regs_above (int);
592 #ifdef HAVE_GAS_HIDDEN
593 static void rs6000_assemble_visibility (tree, int);
595 static int rs6000_ra_ever_killed (void);
596 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
597 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
598 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
599 static const char *rs6000_mangle_fundamental_type (tree);
600 extern const struct attribute_spec rs6000_attribute_table[];
601 static void rs6000_set_default_type_attributes (tree);
602 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
603 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
604 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
606 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
607 static bool rs6000_return_in_memory (tree, tree);
608 static void rs6000_file_start (void);
610 static unsigned int rs6000_elf_section_type_flags (tree, const char *, int);
611 static void rs6000_elf_asm_out_constructor (rtx, int);
612 static void rs6000_elf_asm_out_destructor (rtx, int);
613 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
614 static void rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT);
615 static void rs6000_elf_unique_section (tree, int);
616 static void rs6000_elf_select_rtx_section (enum machine_mode, rtx,
617 unsigned HOST_WIDE_INT);
618 static void rs6000_elf_encode_section_info (tree, rtx, int)
620 static bool rs6000_elf_in_small_data_p (tree);
623 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
624 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
625 static void rs6000_xcoff_select_section (tree, int, unsigned HOST_WIDE_INT);
626 static void rs6000_xcoff_unique_section (tree, int);
627 static void rs6000_xcoff_select_rtx_section (enum machine_mode, rtx,
628 unsigned HOST_WIDE_INT);
629 static const char * rs6000_xcoff_strip_name_encoding (const char *);
630 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
631 static void rs6000_xcoff_file_start (void);
632 static void rs6000_xcoff_file_end (void);
634 static int rs6000_variable_issue (FILE *, int, rtx, int);
635 static bool rs6000_rtx_costs (rtx, int, int, int *);
636 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
637 static bool is_microcoded_insn (rtx);
638 static int is_dispatch_slot_restricted (rtx);
639 static bool is_cracked_insn (rtx);
640 static bool is_branch_slot_insn (rtx);
641 static int rs6000_adjust_priority (rtx, int);
642 static int rs6000_issue_rate (void);
643 static bool rs6000_is_costly_dependence (rtx, rtx, rtx, int, int);
644 static rtx get_next_active_insn (rtx, rtx);
645 static bool insn_terminates_group_p (rtx , enum group_termination);
646 static bool is_costly_group (rtx *, rtx);
647 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
648 static int redefine_groups (FILE *, int, rtx, rtx);
649 static int pad_groups (FILE *, int, rtx, rtx);
650 static void rs6000_sched_finish (FILE *, int);
651 static int rs6000_use_sched_lookahead (void);
652 static tree rs6000_builtin_mask_for_load (void);
654 static void def_builtin (int, const char *, tree, int);
655 static void rs6000_init_builtins (void);
656 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
657 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
658 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
659 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
660 static void altivec_init_builtins (void);
661 static void rs6000_common_init_builtins (void);
662 static void rs6000_init_libfuncs (void);
664 static void enable_mask_for_builtins (struct builtin_description *, int,
665 enum rs6000_builtins,
666 enum rs6000_builtins);
667 static tree build_opaque_vector_type (tree, int);
668 static void spe_init_builtins (void);
669 static rtx spe_expand_builtin (tree, rtx, bool *);
670 static rtx spe_expand_stv_builtin (enum insn_code, tree);
671 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
672 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
673 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
674 static rs6000_stack_t *rs6000_stack_info (void);
675 static void debug_stack_info (rs6000_stack_t *);
677 static rtx altivec_expand_builtin (tree, rtx, bool *);
678 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
679 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
680 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
681 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
682 static rtx altivec_expand_predicate_builtin (enum insn_code,
683 const char *, tree, rtx);
684 static rtx altivec_expand_lv_builtin (enum insn_code, tree, rtx);
685 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
686 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
687 static rtx altivec_expand_vec_set_builtin (tree);
688 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
689 static int get_element_number (tree, tree);
690 static bool rs6000_handle_option (size_t, const char *, int);
691 static void rs6000_parse_tls_size_option (void);
692 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
693 static int first_altivec_reg_to_save (void);
694 static unsigned int compute_vrsave_mask (void);
695 static void compute_save_world_info (rs6000_stack_t *info_ptr);
696 static void is_altivec_return_reg (rtx, void *);
697 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
698 int easy_vector_constant (rtx, enum machine_mode);
699 static bool rs6000_is_opaque_type (tree);
700 static rtx rs6000_dwarf_register_span (rtx);
701 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
702 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
703 static rtx rs6000_tls_get_addr (void);
704 static rtx rs6000_got_sym (void);
705 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
706 static const char *rs6000_get_some_local_dynamic_name (void);
707 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
708 static rtx rs6000_complex_function_value (enum machine_mode);
709 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
710 enum machine_mode, tree);
711 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
713 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
714 tree, HOST_WIDE_INT);
715 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
718 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
721 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, tree, int, bool);
722 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
723 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
724 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
725 enum machine_mode, tree,
727 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
729 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
731 static const char *invalid_arg_for_unprototyped_fn (tree, tree, tree);
733 static void macho_branch_islands (void);
734 static void add_compiler_branch_island (tree, tree, int);
735 static int no_previous_def (tree function_name);
736 static tree get_prev_label (tree function_name);
737 static void rs6000_darwin_file_start (void);
740 static tree rs6000_build_builtin_va_list (void);
741 static tree rs6000_gimplify_va_arg (tree, tree, tree *, tree *);
742 static bool rs6000_must_pass_in_stack (enum machine_mode, tree);
743 static bool rs6000_vector_mode_supported_p (enum machine_mode);
744 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
746 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
748 static int get_vsel_insn (enum machine_mode);
749 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
750 static tree rs6000_stack_protect_fail (void);
752 const int INSN_NOT_AVAILABLE = -1;
753 static enum machine_mode rs6000_eh_return_filter_mode (void);
755 /* Hash table stuff for keeping track of TOC entries. */
757 struct toc_hash_struct GTY(())
759 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
760 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
762 enum machine_mode key_mode;
766 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
768 /* Default register names. */
769 char rs6000_reg_names[][8] =
771 "0", "1", "2", "3", "4", "5", "6", "7",
772 "8", "9", "10", "11", "12", "13", "14", "15",
773 "16", "17", "18", "19", "20", "21", "22", "23",
774 "24", "25", "26", "27", "28", "29", "30", "31",
775 "0", "1", "2", "3", "4", "5", "6", "7",
776 "8", "9", "10", "11", "12", "13", "14", "15",
777 "16", "17", "18", "19", "20", "21", "22", "23",
778 "24", "25", "26", "27", "28", "29", "30", "31",
779 "mq", "lr", "ctr","ap",
780 "0", "1", "2", "3", "4", "5", "6", "7",
782 /* AltiVec registers. */
783 "0", "1", "2", "3", "4", "5", "6", "7",
784 "8", "9", "10", "11", "12", "13", "14", "15",
785 "16", "17", "18", "19", "20", "21", "22", "23",
786 "24", "25", "26", "27", "28", "29", "30", "31",
789 "spe_acc", "spefscr",
790 /* Soft frame pointer. */
794 #ifdef TARGET_REGNAMES
795 static const char alt_reg_names[][8] =
797 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
798 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
799 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
800 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
801 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
802 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
803 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
804 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
805 "mq", "lr", "ctr", "ap",
806 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
808 /* AltiVec registers. */
809 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
810 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
811 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
812 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
815 "spe_acc", "spefscr",
816 /* Soft frame pointer. */
821 #ifndef MASK_STRICT_ALIGN
822 #define MASK_STRICT_ALIGN 0
824 #ifndef TARGET_PROFILE_KERNEL
825 #define TARGET_PROFILE_KERNEL 0
828 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
829 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
831 /* Initialize the GCC target structure. */
832 #undef TARGET_ATTRIBUTE_TABLE
833 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
834 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
835 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
837 #undef TARGET_ASM_ALIGNED_DI_OP
838 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
840 /* Default unaligned ops are only provided for ELF. Find the ops needed
841 for non-ELF systems. */
842 #ifndef OBJECT_FORMAT_ELF
844 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
846 #undef TARGET_ASM_UNALIGNED_HI_OP
847 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
848 #undef TARGET_ASM_UNALIGNED_SI_OP
849 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
850 #undef TARGET_ASM_UNALIGNED_DI_OP
851 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
854 #undef TARGET_ASM_UNALIGNED_HI_OP
855 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
856 #undef TARGET_ASM_UNALIGNED_SI_OP
857 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
858 #undef TARGET_ASM_UNALIGNED_DI_OP
859 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
860 #undef TARGET_ASM_ALIGNED_DI_OP
861 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
865 /* This hook deals with fixups for relocatable code and DI-mode objects
867 #undef TARGET_ASM_INTEGER
868 #define TARGET_ASM_INTEGER rs6000_assemble_integer
870 #ifdef HAVE_GAS_HIDDEN
871 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
872 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
875 #undef TARGET_HAVE_TLS
876 #define TARGET_HAVE_TLS HAVE_AS_TLS
878 #undef TARGET_CANNOT_FORCE_CONST_MEM
879 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
881 #undef TARGET_ASM_FUNCTION_PROLOGUE
882 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
883 #undef TARGET_ASM_FUNCTION_EPILOGUE
884 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
886 #undef TARGET_SCHED_VARIABLE_ISSUE
887 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
889 #undef TARGET_SCHED_ISSUE_RATE
890 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
891 #undef TARGET_SCHED_ADJUST_COST
892 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
893 #undef TARGET_SCHED_ADJUST_PRIORITY
894 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
895 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
896 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
897 #undef TARGET_SCHED_FINISH
898 #define TARGET_SCHED_FINISH rs6000_sched_finish
900 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
901 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
903 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
904 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
906 #undef TARGET_INIT_BUILTINS
907 #define TARGET_INIT_BUILTINS rs6000_init_builtins
909 #undef TARGET_EXPAND_BUILTIN
910 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
912 #undef TARGET_MANGLE_FUNDAMENTAL_TYPE
913 #define TARGET_MANGLE_FUNDAMENTAL_TYPE rs6000_mangle_fundamental_type
915 #undef TARGET_INIT_LIBFUNCS
916 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
919 #undef TARGET_BINDS_LOCAL_P
920 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
923 #undef TARGET_ASM_OUTPUT_MI_THUNK
924 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
926 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
927 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
929 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
930 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
932 #undef TARGET_INVALID_WITHIN_DOLOOP
933 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
935 #undef TARGET_RTX_COSTS
936 #define TARGET_RTX_COSTS rs6000_rtx_costs
937 #undef TARGET_ADDRESS_COST
938 #define TARGET_ADDRESS_COST hook_int_rtx_0
940 #undef TARGET_VECTOR_OPAQUE_P
941 #define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
943 #undef TARGET_DWARF_REGISTER_SPAN
944 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
946 /* On rs6000, function arguments are promoted, as are function return
948 #undef TARGET_PROMOTE_FUNCTION_ARGS
949 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
950 #undef TARGET_PROMOTE_FUNCTION_RETURN
951 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
953 #undef TARGET_RETURN_IN_MEMORY
954 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
956 #undef TARGET_SETUP_INCOMING_VARARGS
957 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
959 /* Always strict argument naming on rs6000. */
960 #undef TARGET_STRICT_ARGUMENT_NAMING
961 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
962 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
963 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
964 #undef TARGET_SPLIT_COMPLEX_ARG
965 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_tree_true
966 #undef TARGET_MUST_PASS_IN_STACK
967 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
968 #undef TARGET_PASS_BY_REFERENCE
969 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
970 #undef TARGET_ARG_PARTIAL_BYTES
971 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
973 #undef TARGET_BUILD_BUILTIN_VA_LIST
974 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
976 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
977 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
979 #undef TARGET_EH_RETURN_FILTER_MODE
980 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
982 #undef TARGET_VECTOR_MODE_SUPPORTED_P
983 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
985 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
986 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
988 #undef TARGET_HANDLE_OPTION
989 #define TARGET_HANDLE_OPTION rs6000_handle_option
991 #undef TARGET_DEFAULT_TARGET_FLAGS
992 #define TARGET_DEFAULT_TARGET_FLAGS \
993 (TARGET_DEFAULT | MASK_SCHED_PROLOG)
995 #undef TARGET_STACK_PROTECT_FAIL
996 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
998 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
999 The PowerPC architecture requires only weak consistency among
1000 processors--that is, memory accesses between processors need not be
1001 sequentially consistent and memory accesses among processors can occur
1002 in any order. The ability to order memory accesses weakly provides
1003 opportunities for more efficient use of the system bus. Unless a
1004 dependency exists, the 604e allows read operations to precede store
1006 #undef TARGET_RELAXED_ORDERING
1007 #define TARGET_RELAXED_ORDERING true
1010 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1011 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1014 struct gcc_target targetm = TARGET_INITIALIZER;
1017 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1020 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1022 /* The GPRs can hold any mode, but values bigger than one register
1023 cannot go past R31. */
1024 if (INT_REGNO_P (regno))
1025 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1027 /* The float registers can only hold floating modes and DImode. */
1028 if (FP_REGNO_P (regno))
1030 (GET_MODE_CLASS (mode) == MODE_FLOAT
1031 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1032 || (GET_MODE_CLASS (mode) == MODE_INT
1033 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD);
1035 /* The CR register can only hold CC modes. */
1036 if (CR_REGNO_P (regno))
1037 return GET_MODE_CLASS (mode) == MODE_CC;
1039 if (XER_REGNO_P (regno))
1040 return mode == PSImode;
1042 /* AltiVec only in AldyVec registers. */
1043 if (ALTIVEC_REGNO_P (regno))
1044 return ALTIVEC_VECTOR_MODE (mode);
1046 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1047 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1050 /* We cannot put TImode anywhere except general register and it must be
1051 able to fit within the register set. */
1053 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1056 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1058 rs6000_init_hard_regno_mode_ok (void)
1062 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1063 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1064 if (rs6000_hard_regno_mode_ok (r, m))
1065 rs6000_hard_regno_mode_ok_p[m][r] = true;
1068 /* If not otherwise specified by a target, make 'long double' equivalent to
1071 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1072 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1075 /* Override command line options. Mostly we process the processor
1076 type and sometimes adjust other TARGET_ options. */
1079 rs6000_override_options (const char *default_cpu)
1082 struct rs6000_cpu_select *ptr;
1085 /* Simplifications for entries below. */
1088 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1089 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1092 /* This table occasionally claims that a processor does not support
1093 a particular feature even though it does, but the feature is slower
1094 than the alternative. Thus, it shouldn't be relied on as a
1095 complete description of the processor's support.
1097 Please keep this list in order, and don't forget to update the
1098 documentation in invoke.texi when adding a new processor or
1102 const char *const name; /* Canonical processor name. */
1103 const enum processor_type processor; /* Processor type enum value. */
1104 const int target_enable; /* Target flags to enable. */
1105 } const processor_target_table[]
1106 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1107 {"403", PROCESSOR_PPC403,
1108 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1109 {"405", PROCESSOR_PPC405, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1110 {"405fp", PROCESSOR_PPC405, POWERPC_BASE_MASK},
1111 {"440", PROCESSOR_PPC440, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1112 {"440fp", PROCESSOR_PPC440, POWERPC_BASE_MASK},
1113 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1114 {"601", PROCESSOR_PPC601,
1115 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1116 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1117 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1118 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1119 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1120 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1121 {"620", PROCESSOR_PPC620,
1122 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1123 {"630", PROCESSOR_PPC630,
1124 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1125 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1126 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1127 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1128 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1129 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1130 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1131 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1132 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1133 /* 8548 has a dummy entry for now. */
1134 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1135 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1136 {"970", PROCESSOR_POWER4,
1137 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1138 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1139 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1140 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1141 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1142 {"G5", PROCESSOR_POWER4,
1143 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1144 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1145 {"power2", PROCESSOR_POWER,
1146 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1147 {"power3", PROCESSOR_PPC630,
1148 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1149 {"power4", PROCESSOR_POWER4,
1150 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1151 {"power5", PROCESSOR_POWER5,
1152 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1153 | MASK_MFCRF | MASK_POPCNTB},
1154 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1155 {"powerpc64", PROCESSOR_POWERPC64,
1156 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1157 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1158 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1159 {"rios2", PROCESSOR_RIOS2,
1160 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1161 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1162 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1163 {"rs64", PROCESSOR_RS64A,
1164 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1167 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1169 /* Some OSs don't support saving the high part of 64-bit registers on
1170 context switch. Other OSs don't support saving Altivec registers.
1171 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1172 settings; if the user wants either, the user must explicitly specify
1173 them and we won't interfere with the user's specification. */
1176 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1177 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT
1178 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1182 rs6000_init_hard_regno_mode_ok ();
1184 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1185 #ifdef OS_MISSING_POWERPC64
1186 if (OS_MISSING_POWERPC64)
1187 set_masks &= ~MASK_POWERPC64;
1189 #ifdef OS_MISSING_ALTIVEC
1190 if (OS_MISSING_ALTIVEC)
1191 set_masks &= ~MASK_ALTIVEC;
1194 /* Don't override by the processor default if given explicitly. */
1195 set_masks &= ~target_flags_explicit;
1197 /* Identify the processor type. */
1198 rs6000_select[0].string = default_cpu;
1199 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1201 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1203 ptr = &rs6000_select[i];
1204 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1206 for (j = 0; j < ptt_size; j++)
1207 if (! strcmp (ptr->string, processor_target_table[j].name))
1209 if (ptr->set_tune_p)
1210 rs6000_cpu = processor_target_table[j].processor;
1212 if (ptr->set_arch_p)
1214 target_flags &= ~set_masks;
1215 target_flags |= (processor_target_table[j].target_enable
1222 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1229 /* If we are optimizing big endian systems for space, use the load/store
1230 multiple and string instructions. */
1231 if (BYTES_BIG_ENDIAN && optimize_size)
1232 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1234 /* Don't allow -mmultiple or -mstring on little endian systems
1235 unless the cpu is a 750, because the hardware doesn't support the
1236 instructions used in little endian mode, and causes an alignment
1237 trap. The 750 does not cause an alignment trap (except when the
1238 target is unaligned). */
1240 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1242 if (TARGET_MULTIPLE)
1244 target_flags &= ~MASK_MULTIPLE;
1245 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1246 warning (0, "-mmultiple is not supported on little endian systems");
1251 target_flags &= ~MASK_STRING;
1252 if ((target_flags_explicit & MASK_STRING) != 0)
1253 warning (0, "-mstring is not supported on little endian systems");
1257 /* Set debug flags */
1258 if (rs6000_debug_name)
1260 if (! strcmp (rs6000_debug_name, "all"))
1261 rs6000_debug_stack = rs6000_debug_arg = 1;
1262 else if (! strcmp (rs6000_debug_name, "stack"))
1263 rs6000_debug_stack = 1;
1264 else if (! strcmp (rs6000_debug_name, "arg"))
1265 rs6000_debug_arg = 1;
1267 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1270 if (rs6000_traceback_name)
1272 if (! strncmp (rs6000_traceback_name, "full", 4))
1273 rs6000_traceback = traceback_full;
1274 else if (! strncmp (rs6000_traceback_name, "part", 4))
1275 rs6000_traceback = traceback_part;
1276 else if (! strncmp (rs6000_traceback_name, "no", 2))
1277 rs6000_traceback = traceback_none;
1279 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1280 rs6000_traceback_name);
1283 if (!rs6000_explicit_options.long_double)
1284 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1286 /* Set Altivec ABI as default for powerpc64 linux. */
1287 if (TARGET_ELF && TARGET_64BIT)
1289 rs6000_altivec_abi = 1;
1290 TARGET_ALTIVEC_VRSAVE = 1;
1293 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1294 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1296 rs6000_darwin64_abi = 1;
1298 darwin_one_byte_bool = 1;
1300 /* Default to natural alignment, for better performance. */
1301 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1304 /* Handle -mtls-size option. */
1305 rs6000_parse_tls_size_option ();
1307 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1308 SUBTARGET_OVERRIDE_OPTIONS;
1310 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1311 SUBSUBTARGET_OVERRIDE_OPTIONS;
1313 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1314 SUB3TARGET_OVERRIDE_OPTIONS;
1320 error ("AltiVec and E500 instructions cannot coexist");
1322 /* The e500 does not have string instructions, and we set
1323 MASK_STRING above when optimizing for size. */
1324 if ((target_flags & MASK_STRING) != 0)
1325 target_flags = target_flags & ~MASK_STRING;
1327 else if (rs6000_select[1].string != NULL)
1329 /* For the powerpc-eabispe configuration, we set all these by
1330 default, so let's unset them if we manually set another
1331 CPU that is not the E500. */
1332 if (!rs6000_explicit_options.abi)
1334 if (!rs6000_explicit_options.spe)
1336 if (!rs6000_explicit_options.float_gprs)
1337 rs6000_float_gprs = 0;
1338 if (!rs6000_explicit_options.isel)
1340 if (!rs6000_explicit_options.long_double)
1341 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1344 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1345 && rs6000_cpu != PROCESSOR_POWER5);
1346 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1347 || rs6000_cpu == PROCESSOR_POWER5);
1349 rs6000_sched_restricted_insns_priority
1350 = (rs6000_sched_groups ? 1 : 0);
1352 /* Handle -msched-costly-dep option. */
1353 rs6000_sched_costly_dep
1354 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1356 if (rs6000_sched_costly_dep_str)
1358 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1359 rs6000_sched_costly_dep = no_dep_costly;
1360 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1361 rs6000_sched_costly_dep = all_deps_costly;
1362 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1363 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1364 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1365 rs6000_sched_costly_dep = store_to_load_dep_costly;
1367 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1370 /* Handle -minsert-sched-nops option. */
1371 rs6000_sched_insert_nops
1372 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1374 if (rs6000_sched_insert_nops_str)
1376 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1377 rs6000_sched_insert_nops = sched_finish_none;
1378 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1379 rs6000_sched_insert_nops = sched_finish_pad_groups;
1380 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1381 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1383 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1386 #ifdef TARGET_REGNAMES
1387 /* If the user desires alternate register names, copy in the
1388 alternate names now. */
1389 if (TARGET_REGNAMES)
1390 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1393 /* Set aix_struct_return last, after the ABI is determined.
1394 If -maix-struct-return or -msvr4-struct-return was explicitly
1395 used, don't override with the ABI default. */
1396 if (!rs6000_explicit_options.aix_struct_ret)
1397 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
1399 if (TARGET_LONG_DOUBLE_128
1400 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN))
1401 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1403 /* Allocate an alias set for register saves & restores from stack. */
1404 rs6000_sr_alias_set = new_alias_set ();
1407 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1409 /* We can only guarantee the availability of DI pseudo-ops when
1410 assembling for 64-bit targets. */
1413 targetm.asm_out.aligned_op.di = NULL;
1414 targetm.asm_out.unaligned_op.di = NULL;
1417 /* Set branch target alignment, if not optimizing for size. */
1420 if (rs6000_sched_groups)
1422 if (align_functions <= 0)
1423 align_functions = 16;
1424 if (align_jumps <= 0)
1426 if (align_loops <= 0)
1429 if (align_jumps_max_skip <= 0)
1430 align_jumps_max_skip = 15;
1431 if (align_loops_max_skip <= 0)
1432 align_loops_max_skip = 15;
1435 /* Arrange to save and restore machine status around nested functions. */
1436 init_machine_status = rs6000_init_machine_status;
1438 /* We should always be splitting complex arguments, but we can't break
1439 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1440 if (DEFAULT_ABI != ABI_AIX)
1441 targetm.calls.split_complex_arg = NULL;
1443 /* Initialize rs6000_cost with the appropriate target costs. */
1445 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1449 case PROCESSOR_RIOS1:
1450 rs6000_cost = &rios1_cost;
1453 case PROCESSOR_RIOS2:
1454 rs6000_cost = &rios2_cost;
1457 case PROCESSOR_RS64A:
1458 rs6000_cost = &rs64a_cost;
1461 case PROCESSOR_MPCCORE:
1462 rs6000_cost = &mpccore_cost;
1465 case PROCESSOR_PPC403:
1466 rs6000_cost = &ppc403_cost;
1469 case PROCESSOR_PPC405:
1470 rs6000_cost = &ppc405_cost;
1473 case PROCESSOR_PPC440:
1474 rs6000_cost = &ppc440_cost;
1477 case PROCESSOR_PPC601:
1478 rs6000_cost = &ppc601_cost;
1481 case PROCESSOR_PPC603:
1482 rs6000_cost = &ppc603_cost;
1485 case PROCESSOR_PPC604:
1486 rs6000_cost = &ppc604_cost;
1489 case PROCESSOR_PPC604e:
1490 rs6000_cost = &ppc604e_cost;
1493 case PROCESSOR_PPC620:
1494 rs6000_cost = &ppc620_cost;
1497 case PROCESSOR_PPC630:
1498 rs6000_cost = &ppc630_cost;
1501 case PROCESSOR_PPC750:
1502 case PROCESSOR_PPC7400:
1503 rs6000_cost = &ppc750_cost;
1506 case PROCESSOR_PPC7450:
1507 rs6000_cost = &ppc7450_cost;
1510 case PROCESSOR_PPC8540:
1511 rs6000_cost = &ppc8540_cost;
1514 case PROCESSOR_POWER4:
1515 case PROCESSOR_POWER5:
1516 rs6000_cost = &power4_cost;
1524 /* Implement targetm.vectorize.builtin_mask_for_load. */
1526 rs6000_builtin_mask_for_load (void)
1529 return altivec_builtin_mask_for_load;
1534 /* Handle generic options of the form -mfoo=yes/no.
1535 NAME is the option name.
1536 VALUE is the option value.
1537 FLAG is the pointer to the flag where to store a 1 or 0, depending on
1538 whether the option value is 'yes' or 'no' respectively. */
1540 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
1544 else if (!strcmp (value, "yes"))
1546 else if (!strcmp (value, "no"))
1549 error ("unknown -m%s= option specified: '%s'", name, value);
1552 /* Validate and record the size specified with the -mtls-size option. */
1555 rs6000_parse_tls_size_option (void)
1557 if (rs6000_tls_size_string == 0)
1559 else if (strcmp (rs6000_tls_size_string, "16") == 0)
1560 rs6000_tls_size = 16;
1561 else if (strcmp (rs6000_tls_size_string, "32") == 0)
1562 rs6000_tls_size = 32;
1563 else if (strcmp (rs6000_tls_size_string, "64") == 0)
1564 rs6000_tls_size = 64;
1566 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
1570 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
1572 if (DEFAULT_ABI == ABI_DARWIN)
1573 /* The Darwin libraries never set errno, so we might as well
1574 avoid calling them when that's the only reason we would. */
1575 flag_errno_math = 0;
1578 /* Implement TARGET_HANDLE_OPTION. */
1581 rs6000_handle_option (size_t code, const char *arg, int value)
1586 target_flags &= ~(MASK_POWER | MASK_POWER2
1587 | MASK_MULTIPLE | MASK_STRING);
1588 target_flags_explicit |= (MASK_POWER | MASK_POWER2
1589 | MASK_MULTIPLE | MASK_STRING);
1591 case OPT_mno_powerpc:
1592 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
1593 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1594 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
1595 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1598 target_flags &= ~(MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC
1599 | MASK_NO_SUM_IN_TOC);
1600 target_flags_explicit |= (MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC
1601 | MASK_NO_SUM_IN_TOC);
1602 #ifdef TARGET_USES_SYSV4_OPT
1603 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
1604 just the same as -mminimal-toc. */
1605 target_flags |= MASK_MINIMAL_TOC;
1606 target_flags_explicit |= MASK_MINIMAL_TOC;
1610 #ifdef TARGET_USES_SYSV4_OPT
1612 /* Make -mtoc behave like -mminimal-toc. */
1613 target_flags |= MASK_MINIMAL_TOC;
1614 target_flags_explicit |= MASK_MINIMAL_TOC;
1618 #ifdef TARGET_USES_AIX64_OPT
1623 target_flags |= MASK_POWERPC64 | MASK_POWERPC | MASK_PPC_GFXOPT;
1624 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC
1628 #ifdef TARGET_USES_AIX64_OPT
1633 target_flags &= ~MASK_POWERPC64;
1634 target_flags_explicit |= MASK_POWERPC64;
1637 case OPT_minsert_sched_nops_:
1638 rs6000_sched_insert_nops_str = arg;
1641 case OPT_mminimal_toc:
1644 target_flags &= ~(MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC);
1645 target_flags_explicit |= (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC);
1652 target_flags |= (MASK_MULTIPLE | MASK_STRING);
1653 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
1660 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1661 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1665 case OPT_mpowerpc_gpopt:
1666 case OPT_mpowerpc_gfxopt:
1669 target_flags |= MASK_POWERPC;
1670 target_flags_explicit |= MASK_POWERPC;
1674 case OPT_maix_struct_return:
1675 case OPT_msvr4_struct_return:
1676 rs6000_explicit_options.aix_struct_ret = true;
1680 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
1684 rs6000_explicit_options.isel = true;
1685 rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
1689 rs6000_explicit_options.spe = true;
1690 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
1691 /* No SPE means 64-bit long doubles, even if an E500. */
1693 rs6000_long_double_type_size = 64;
1697 rs6000_debug_name = arg;
1700 #ifdef TARGET_USES_SYSV4_OPT
1702 rs6000_abi_name = arg;
1706 rs6000_sdata_name = arg;
1709 case OPT_mtls_size_:
1710 rs6000_tls_size_string = arg;
1713 case OPT_mrelocatable:
1716 target_flags |= MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC;
1717 target_flags_explicit |= MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC;
1721 case OPT_mrelocatable_lib:
1724 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC
1725 | MASK_NO_FP_IN_TOC;
1726 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC
1727 | MASK_NO_FP_IN_TOC;
1731 target_flags &= ~MASK_RELOCATABLE;
1732 target_flags_explicit |= MASK_RELOCATABLE;
1738 rs6000_explicit_options.abi = true;
1739 if (!strcmp (arg, "altivec"))
1741 rs6000_altivec_abi = 1;
1744 else if (! strcmp (arg, "no-altivec"))
1745 rs6000_altivec_abi = 0;
1746 else if (! strcmp (arg, "spe"))
1749 rs6000_altivec_abi = 0;
1750 if (!TARGET_SPE_ABI)
1751 error ("not configured for ABI: '%s'", arg);
1753 else if (! strcmp (arg, "no-spe"))
1756 /* These are here for testing during development only, do not
1757 document in the manual please. */
1758 else if (! strcmp (arg, "d64"))
1760 rs6000_darwin64_abi = 1;
1761 warning (0, "Using darwin64 ABI");
1763 else if (! strcmp (arg, "d32"))
1765 rs6000_darwin64_abi = 0;
1766 warning (0, "Using old darwin ABI");
1771 error ("unknown ABI specified: '%s'", arg);
1777 rs6000_select[1].string = arg;
1781 rs6000_select[2].string = arg;
1784 case OPT_mtraceback_:
1785 rs6000_traceback_name = arg;
1788 case OPT_mfloat_gprs_:
1789 rs6000_explicit_options.float_gprs = true;
1790 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
1791 rs6000_float_gprs = 1;
1792 else if (! strcmp (arg, "double"))
1793 rs6000_float_gprs = 2;
1794 else if (! strcmp (arg, "no"))
1795 rs6000_float_gprs = 0;
1798 error ("invalid option for -mfloat-gprs: '%s'", arg);
1803 case OPT_mlong_double_:
1804 rs6000_explicit_options.long_double = true;
1805 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1806 if (value != 64 && value != 128)
1808 error ("Unknown switch -mlong-double-%s", arg);
1809 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1813 rs6000_long_double_type_size = value;
1816 case OPT_msched_costly_dep_:
1817 rs6000_sched_costly_dep_str = arg;
1821 rs6000_explicit_options.alignment = true;
1822 if (! strcmp (arg, "power"))
1824 /* On 64-bit Darwin, power alignment is ABI-incompatible with
1825 some C library functions, so warn about it. The flag may be
1826 useful for performance studies from time to time though, so
1827 don't disable it entirely. */
1828 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1829 warning (0, "-malign-power is not supported for 64-bit Darwin;"
1830 " it is incompatible with the installed C and C++ libraries");
1831 rs6000_alignment_flags = MASK_ALIGN_POWER;
1833 else if (! strcmp (arg, "natural"))
1834 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1837 error ("unknown -malign-XXXXX option specified: '%s'", arg);
1845 /* Do anything needed at the start of the asm file. */
1848 rs6000_file_start (void)
1852 const char *start = buffer;
1853 struct rs6000_cpu_select *ptr;
1854 const char *default_cpu = TARGET_CPU_DEFAULT;
1855 FILE *file = asm_out_file;
1857 default_file_start ();
1859 #ifdef TARGET_BI_ARCH
1860 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
1864 if (flag_verbose_asm)
1866 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
1867 rs6000_select[0].string = default_cpu;
1869 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1871 ptr = &rs6000_select[i];
1872 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1874 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
1879 if (PPC405_ERRATUM77)
1881 fprintf (file, "%s PPC405CR_ERRATUM77", start);
1885 #ifdef USING_ELFOS_H
1886 switch (rs6000_sdata)
1888 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
1889 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
1890 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
1891 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
1894 if (rs6000_sdata && g_switch_value)
1896 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
1906 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
1914 /* Return nonzero if this function is known to have a null epilogue. */
1917 direct_return (void)
1919 if (reload_completed)
1921 rs6000_stack_t *info = rs6000_stack_info ();
1923 if (info->first_gp_reg_save == 32
1924 && info->first_fp_reg_save == 64
1925 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
1926 && ! info->lr_save_p
1927 && ! info->cr_save_p
1928 && info->vrsave_mask == 0
1936 /* Return the number of instructions it takes to form a constant in an
1937 integer register. */
1940 num_insns_constant_wide (HOST_WIDE_INT value)
1942 /* signed constant loadable with {cal|addi} */
1943 if (CONST_OK_FOR_LETTER_P (value, 'I'))
1946 /* constant loadable with {cau|addis} */
1947 else if (CONST_OK_FOR_LETTER_P (value, 'L'))
1950 #if HOST_BITS_PER_WIDE_INT == 64
1951 else if (TARGET_POWERPC64)
1953 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
1954 HOST_WIDE_INT high = value >> 31;
1956 if (high == 0 || high == -1)
1962 return num_insns_constant_wide (high) + 1;
1964 return (num_insns_constant_wide (high)
1965 + num_insns_constant_wide (low) + 1);
1974 num_insns_constant (rtx op, enum machine_mode mode)
1976 HOST_WIDE_INT low, high;
1978 switch (GET_CODE (op))
1981 #if HOST_BITS_PER_WIDE_INT == 64
1982 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
1983 && mask64_operand (op, mode))
1987 return num_insns_constant_wide (INTVAL (op));
1995 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1996 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
1997 return num_insns_constant_wide ((HOST_WIDE_INT) l);
2000 if (mode == VOIDmode || mode == DImode)
2002 high = CONST_DOUBLE_HIGH (op);
2003 low = CONST_DOUBLE_LOW (op);
2010 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2011 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
2012 high = l[WORDS_BIG_ENDIAN == 0];
2013 low = l[WORDS_BIG_ENDIAN != 0];
2017 return (num_insns_constant_wide (low)
2018 + num_insns_constant_wide (high));
2021 if ((high == 0 && low >= 0)
2022 || (high == -1 && low < 0))
2023 return num_insns_constant_wide (low);
2025 else if (mask64_operand (op, mode))
2029 return num_insns_constant_wide (high) + 1;
2032 return (num_insns_constant_wide (high)
2033 + num_insns_constant_wide (low) + 1);
2041 /* Returns the constant for the splat instruction, if exists. */
2044 easy_vector_splat_const (int cst, enum machine_mode mode)
2049 if (EASY_VECTOR_15 (cst)
2050 || EASY_VECTOR_15_ADD_SELF (cst))
2052 if ((cst & 0xffff) != ((cst >> 16) & 0xffff))
2058 if (EASY_VECTOR_15 (cst)
2059 || EASY_VECTOR_15_ADD_SELF (cst))
2061 if ((cst & 0xff) != ((cst >> 8) & 0xff))
2067 if (EASY_VECTOR_15 (cst)
2068 || EASY_VECTOR_15_ADD_SELF (cst))
2076 /* Return nonzero if all elements of a vector have the same value. */
2079 easy_vector_same (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
2083 units = CONST_VECTOR_NUNITS (op);
2085 cst = INTVAL (CONST_VECTOR_ELT (op, 0));
2086 for (i = 1; i < units; ++i)
2087 if (INTVAL (CONST_VECTOR_ELT (op, i)) != cst)
2089 if (i == units && easy_vector_splat_const (cst, mode))
2094 /* Generate easy_vector_constant out of a easy_vector_constant_add_self. */
2097 gen_easy_vector_constant_add_self (rtx op)
2101 units = GET_MODE_NUNITS (GET_MODE (op));
2102 v = rtvec_alloc (units);
2104 for (i = 0; i < units; i++)
2106 GEN_INT (INTVAL (CONST_VECTOR_ELT (op, i)) >> 1);
2107 return gen_rtx_raw_CONST_VECTOR (GET_MODE (op), v);
2111 output_vec_const_move (rtx *operands)
2114 enum machine_mode mode;
2120 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2121 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
2122 mode = GET_MODE (dest);
2126 if (zero_constant (vec, mode))
2127 return "vxor %0,%0,%0";
2129 gcc_assert (easy_vector_constant (vec, mode));
2131 operands[1] = GEN_INT (cst);
2135 if (EASY_VECTOR_15 (cst))
2137 operands[1] = GEN_INT (cst);
2138 return "vspltisw %0,%1";
2140 else if (EASY_VECTOR_15_ADD_SELF (cst))
2146 if (EASY_VECTOR_15 (cst))
2148 operands[1] = GEN_INT (cst);
2149 return "vspltish %0,%1";
2151 else if (EASY_VECTOR_15_ADD_SELF (cst))
2157 if (EASY_VECTOR_15 (cst))
2159 operands[1] = GEN_INT (cst);
2160 return "vspltisb %0,%1";
2162 else if (EASY_VECTOR_15_ADD_SELF (cst))
2170 gcc_assert (TARGET_SPE);
2172 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2173 pattern of V1DI, V4HI, and V2SF.
2175 FIXME: We should probably return # and add post reload
2176 splitters for these, but this way is so easy ;-). */
2177 operands[1] = GEN_INT (cst);
2178 operands[2] = GEN_INT (cst2);
2180 return "li %0,%1\n\tevmergelo %0,%0,%0";
2182 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
2185 /* Initialize vector TARGET to VALS. */
2188 rs6000_expand_vector_init (rtx target, rtx vals)
2190 enum machine_mode mode = GET_MODE (target);
2191 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2192 int n_elts = GET_MODE_NUNITS (mode);
2193 int n_var = 0, one_var = -1;
2194 bool all_same = true, all_const_zero = true;
2198 for (i = 0; i < n_elts; ++i)
2200 x = XVECEXP (vals, 0, i);
2201 if (!CONSTANT_P (x))
2202 ++n_var, one_var = i;
2203 else if (x != CONST0_RTX (inner_mode))
2204 all_const_zero = false;
2206 if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0)))
2212 if (mode != V4SFmode && all_const_zero)
2214 /* Zero register. */
2215 emit_insn (gen_rtx_SET (VOIDmode, target,
2216 gen_rtx_XOR (mode, target, target)));
2219 else if (mode != V4SFmode && easy_vector_same (vals, mode))
2221 /* Splat immediate. */
2222 x = gen_rtx_VEC_DUPLICATE (mode, CONST_VECTOR_ELT (vals, 0));
2223 emit_insn (gen_rtx_SET (VOIDmode, target, x));
2227 ; /* Splat vector element. */
2230 /* Load from constant pool. */
2231 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
2236 /* Store value to stack temp. Load vector element. Splat. */
2239 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2240 emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
2241 XVECEXP (vals, 0, 0));
2242 x = gen_rtx_UNSPEC (VOIDmode,
2243 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2244 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2246 gen_rtx_SET (VOIDmode,
2249 x = gen_rtx_VEC_SELECT (inner_mode, target,
2250 gen_rtx_PARALLEL (VOIDmode,
2251 gen_rtvec (1, const0_rtx)));
2252 emit_insn (gen_rtx_SET (VOIDmode, target,
2253 gen_rtx_VEC_DUPLICATE (mode, x)));
2257 /* One field is non-constant. Load constant then overwrite
2261 rtx copy = copy_rtx (vals);
2263 /* Load constant part of vector, substitute neighboring value for
2265 XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts);
2266 rs6000_expand_vector_init (target, copy);
2268 /* Insert variable. */
2269 rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), one_var);
2273 /* Construct the vector in memory one field at a time
2274 and load the whole vector. */
2275 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2276 for (i = 0; i < n_elts; i++)
2277 emit_move_insn (adjust_address_nv (mem, inner_mode,
2278 i * GET_MODE_SIZE (inner_mode)),
2279 XVECEXP (vals, 0, i));
2280 emit_move_insn (target, mem);
2283 /* Set field ELT of TARGET to VAL. */
2286 rs6000_expand_vector_set (rtx target, rtx val, int elt)
2288 enum machine_mode mode = GET_MODE (target);
2289 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2290 rtx reg = gen_reg_rtx (mode);
2292 int width = GET_MODE_SIZE (inner_mode);
2295 /* Load single variable value. */
2296 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2297 emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val);
2298 x = gen_rtx_UNSPEC (VOIDmode,
2299 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2300 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2302 gen_rtx_SET (VOIDmode,
2306 /* Linear sequence. */
2307 mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
2308 for (i = 0; i < 16; ++i)
2309 XVECEXP (mask, 0, i) = GEN_INT (i);
2311 /* Set permute mask to insert element into target. */
2312 for (i = 0; i < width; ++i)
2313 XVECEXP (mask, 0, elt*width + i)
2314 = GEN_INT (i + 0x10);
2315 x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
2316 x = gen_rtx_UNSPEC (mode,
2317 gen_rtvec (3, target, reg,
2318 force_reg (V16QImode, x)),
2320 emit_insn (gen_rtx_SET (VOIDmode, target, x));
2323 /* Extract field ELT from VEC into TARGET. */
2326 rs6000_expand_vector_extract (rtx target, rtx vec, int elt)
2328 enum machine_mode mode = GET_MODE (vec);
2329 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2332 /* Allocate mode-sized buffer. */
2333 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2335 /* Add offset to field within buffer matching vector element. */
2336 mem = adjust_address_nv (mem, mode, elt * GET_MODE_SIZE (inner_mode));
2338 /* Store single field into mode-sized buffer. */
2339 x = gen_rtx_UNSPEC (VOIDmode,
2340 gen_rtvec (1, const0_rtx), UNSPEC_STVE);
2341 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2343 gen_rtx_SET (VOIDmode,
2346 emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0));
2349 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
2350 implement ANDing by the mask IN. */
2352 build_mask64_2_operands (rtx in, rtx *out)
2354 #if HOST_BITS_PER_WIDE_INT >= 64
2355 unsigned HOST_WIDE_INT c, lsb, m1, m2;
2358 gcc_assert (GET_CODE (in) == CONST_INT);
2363 /* Assume c initially something like 0x00fff000000fffff. The idea
2364 is to rotate the word so that the middle ^^^^^^ group of zeros
2365 is at the MS end and can be cleared with an rldicl mask. We then
2366 rotate back and clear off the MS ^^ group of zeros with a
2368 c = ~c; /* c == 0xff000ffffff00000 */
2369 lsb = c & -c; /* lsb == 0x0000000000100000 */
2370 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
2371 c = ~c; /* c == 0x00fff000000fffff */
2372 c &= -lsb; /* c == 0x00fff00000000000 */
2373 lsb = c & -c; /* lsb == 0x0000100000000000 */
2374 c = ~c; /* c == 0xff000fffffffffff */
2375 c &= -lsb; /* c == 0xff00000000000000 */
2377 while ((lsb >>= 1) != 0)
2378 shift++; /* shift == 44 on exit from loop */
2379 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
2380 m1 = ~m1; /* m1 == 0x000000ffffffffff */
2381 m2 = ~c; /* m2 == 0x00ffffffffffffff */
2385 /* Assume c initially something like 0xff000f0000000000. The idea
2386 is to rotate the word so that the ^^^ middle group of zeros
2387 is at the LS end and can be cleared with an rldicr mask. We then
2388 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
2390 lsb = c & -c; /* lsb == 0x0000010000000000 */
2391 m2 = -lsb; /* m2 == 0xffffff0000000000 */
2392 c = ~c; /* c == 0x00fff0ffffffffff */
2393 c &= -lsb; /* c == 0x00fff00000000000 */
2394 lsb = c & -c; /* lsb == 0x0000100000000000 */
2395 c = ~c; /* c == 0xff000fffffffffff */
2396 c &= -lsb; /* c == 0xff00000000000000 */
2398 while ((lsb >>= 1) != 0)
2399 shift++; /* shift == 44 on exit from loop */
2400 m1 = ~c; /* m1 == 0x00ffffffffffffff */
2401 m1 >>= shift; /* m1 == 0x0000000000000fff */
2402 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
2405 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
2406 masks will be all 1's. We are guaranteed more than one transition. */
2407 out[0] = GEN_INT (64 - shift);
2408 out[1] = GEN_INT (m1);
2409 out[2] = GEN_INT (shift);
2410 out[3] = GEN_INT (m2);
2418 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
2421 invalid_e500_subreg (rtx op, enum machine_mode mode)
2423 /* Reject (subreg:SI (reg:DF)). */
2424 if (GET_CODE (op) == SUBREG
2426 && REG_P (SUBREG_REG (op))
2427 && GET_MODE (SUBREG_REG (op)) == DFmode)
2430 /* Reject (subreg:DF (reg:DI)). */
2431 if (GET_CODE (op) == SUBREG
2433 && REG_P (SUBREG_REG (op))
2434 && GET_MODE (SUBREG_REG (op)) == DImode)
2440 /* Darwin, AIX increases natural record alignment to doubleword if the first
2441 field is an FP double while the FP fields remain word aligned. */
2444 rs6000_special_round_type_align (tree type, int computed, int specified)
2446 tree field = TYPE_FIELDS (type);
2448 /* Skip all non field decls */
2449 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2450 field = TREE_CHAIN (field);
2452 if (field == NULL || field == type || DECL_MODE (field) != DFmode)
2453 return MAX (computed, specified);
2455 return MAX (MAX (computed, specified), 64);
2458 /* Return 1 for an operand in small memory on V.4/eabi. */
2461 small_data_operand (rtx op ATTRIBUTE_UNUSED,
2462 enum machine_mode mode ATTRIBUTE_UNUSED)
2467 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
2470 if (DEFAULT_ABI != ABI_V4)
2473 if (GET_CODE (op) == SYMBOL_REF)
2476 else if (GET_CODE (op) != CONST
2477 || GET_CODE (XEXP (op, 0)) != PLUS
2478 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
2479 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
2484 rtx sum = XEXP (op, 0);
2485 HOST_WIDE_INT summand;
2487 /* We have to be careful here, because it is the referenced address
2488 that must be 32k from _SDA_BASE_, not just the symbol. */
2489 summand = INTVAL (XEXP (sum, 1));
2490 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
2493 sym_ref = XEXP (sum, 0);
2496 return SYMBOL_REF_SMALL_P (sym_ref);
2502 /* Return true if either operand is a general purpose register. */
2505 gpr_or_gpr_p (rtx op0, rtx op1)
2507 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
2508 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
2512 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
2515 constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
2517 switch (GET_CODE (op))
2520 if (RS6000_SYMBOL_REF_TLS_P (op))
2522 else if (CONSTANT_POOL_ADDRESS_P (op))
2524 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
2532 else if (! strcmp (XSTR (op, 0), toc_label_name))
2541 return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
2542 && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
2544 return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
2553 constant_pool_expr_p (rtx op)
2557 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
2561 toc_relative_expr_p (rtx op)
2565 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
2569 legitimate_constant_pool_address_p (rtx x)
2572 && GET_CODE (x) == PLUS
2573 && GET_CODE (XEXP (x, 0)) == REG
2574 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
2575 && constant_pool_expr_p (XEXP (x, 1)));
2579 rs6000_legitimate_small_data_p (enum machine_mode mode, rtx x)
2581 return (DEFAULT_ABI == ABI_V4
2582 && !flag_pic && !TARGET_TOC
2583 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
2584 && small_data_operand (x, mode));
2587 /* SPE offset addressing is limited to 5-bits worth of double words. */
2588 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
2591 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
2593 unsigned HOST_WIDE_INT offset, extra;
2595 if (GET_CODE (x) != PLUS)
2597 if (GET_CODE (XEXP (x, 0)) != REG)
2599 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
2601 if (legitimate_constant_pool_address_p (x))
2603 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2606 offset = INTVAL (XEXP (x, 1));
2614 /* AltiVec vector modes. Only reg+reg addressing is valid and
2615 constant offset zero should not occur due to canonicalization.
2616 Allow any offset when not strict before reload. */
2623 /* SPE vector modes. */
2624 return SPE_CONST_OFFSET_OK (offset);
2627 if (TARGET_E500_DOUBLE)
2628 return SPE_CONST_OFFSET_OK (offset);
2631 /* On e500v2, we may have:
2633 (subreg:DF (mem:DI (plus (reg) (const_int))) 0).
2635 Which gets addressed with evldd instructions. */
2636 if (TARGET_E500_DOUBLE)
2637 return SPE_CONST_OFFSET_OK (offset);
2639 if (mode == DFmode || !TARGET_POWERPC64)
2641 else if (offset & 3)
2647 if (mode == TFmode || !TARGET_POWERPC64)
2649 else if (offset & 3)
2660 return (offset < 0x10000) && (offset + extra < 0x10000);
2664 legitimate_indexed_address_p (rtx x, int strict)
2668 if (GET_CODE (x) != PLUS)
2674 if (!REG_P (op0) || !REG_P (op1))
2677 return ((INT_REG_OK_FOR_BASE_P (op0, strict)
2678 && INT_REG_OK_FOR_INDEX_P (op1, strict))
2679 || (INT_REG_OK_FOR_BASE_P (op1, strict)
2680 && INT_REG_OK_FOR_INDEX_P (op0, strict)));
2684 legitimate_indirect_address_p (rtx x, int strict)
2686 return GET_CODE (x) == REG && INT_REG_OK_FOR_BASE_P (x, strict);
2690 macho_lo_sum_memory_operand (rtx x, enum machine_mode mode)
2692 if (!TARGET_MACHO || !flag_pic
2693 || mode != SImode || GET_CODE (x) != MEM)
2697 if (GET_CODE (x) != LO_SUM)
2699 if (GET_CODE (XEXP (x, 0)) != REG)
2701 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0))
2705 return CONSTANT_P (x);
2709 legitimate_lo_sum_address_p (enum machine_mode mode, rtx x, int strict)
2711 if (GET_CODE (x) != LO_SUM)
2713 if (GET_CODE (XEXP (x, 0)) != REG)
2715 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
2717 /* Restrict addressing for DI because of our SUBREG hackery. */
2718 if (TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
2722 if (TARGET_ELF || TARGET_MACHO)
2724 if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
2728 if (GET_MODE_NUNITS (mode) != 1)
2730 if (GET_MODE_BITSIZE (mode) > 64
2731 || (GET_MODE_BITSIZE (mode) > 32 && !TARGET_POWERPC64
2732 && !(TARGET_HARD_FLOAT && TARGET_FPRS && mode == DFmode)))
2735 return CONSTANT_P (x);
2742 /* Try machine-dependent ways of modifying an illegitimate address
2743 to be legitimate. If we find one, return the new, valid address.
2744 This is used from only one place: `memory_address' in explow.c.
2746 OLDX is the address as it was before break_out_memory_refs was
2747 called. In some cases it is useful to look at this to decide what
2750 MODE is passed so that this function can use GO_IF_LEGITIMATE_ADDRESS.
2752 It is always safe for this function to do nothing. It exists to
2753 recognize opportunities to optimize the output.
2755 On RS/6000, first check for the sum of a register with a constant
2756 integer that is out of range. If so, generate code to add the
2757 constant with the low-order 16 bits masked to the register and force
2758 this result into another register (this can be done with `cau').
2759 Then generate an address of REG+(CONST&0xffff), allowing for the
2760 possibility of bit 16 being a one.
2762 Then check for the sum of a register and something not constant, try to
2763 load the other things into a register and return the sum. */
2766 rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
2767 enum machine_mode mode)
2769 if (GET_CODE (x) == SYMBOL_REF)
2771 enum tls_model model = SYMBOL_REF_TLS_MODEL (x);
2773 return rs6000_legitimize_tls_address (x, model);
2776 if (GET_CODE (x) == PLUS
2777 && GET_CODE (XEXP (x, 0)) == REG
2778 && GET_CODE (XEXP (x, 1)) == CONST_INT
2779 && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) >= 0x10000)
2781 HOST_WIDE_INT high_int, low_int;
2783 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
2784 high_int = INTVAL (XEXP (x, 1)) - low_int;
2785 sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0),
2786 GEN_INT (high_int)), 0);
2787 return gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));
2789 else if (GET_CODE (x) == PLUS
2790 && GET_CODE (XEXP (x, 0)) == REG
2791 && GET_CODE (XEXP (x, 1)) != CONST_INT
2792 && GET_MODE_NUNITS (mode) == 1
2793 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
2795 || (((mode != DImode && mode != DFmode) || TARGET_E500_DOUBLE)
2797 && (TARGET_POWERPC64 || mode != DImode)
2800 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
2801 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
2803 else if (ALTIVEC_VECTOR_MODE (mode))
2807 /* Make sure both operands are registers. */
2808 if (GET_CODE (x) == PLUS)
2809 return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)),
2810 force_reg (Pmode, XEXP (x, 1)));
2812 reg = force_reg (Pmode, x);
2815 else if (SPE_VECTOR_MODE (mode)
2816 || (TARGET_E500_DOUBLE && (mode == DFmode
2817 || mode == DImode)))
2821 /* We accept [reg + reg] and [reg + OFFSET]. */
2823 if (GET_CODE (x) == PLUS)
2825 rtx op1 = XEXP (x, 0);
2826 rtx op2 = XEXP (x, 1);
2828 op1 = force_reg (Pmode, op1);
2830 if (GET_CODE (op2) != REG
2831 && (GET_CODE (op2) != CONST_INT
2832 || !SPE_CONST_OFFSET_OK (INTVAL (op2))))
2833 op2 = force_reg (Pmode, op2);
2835 return gen_rtx_PLUS (Pmode, op1, op2);
2838 return force_reg (Pmode, x);
2844 && GET_CODE (x) != CONST_INT
2845 && GET_CODE (x) != CONST_DOUBLE
2847 && GET_MODE_NUNITS (mode) == 1
2848 && (GET_MODE_BITSIZE (mode) <= 32
2849 || ((TARGET_HARD_FLOAT && TARGET_FPRS) && mode == DFmode)))
2851 rtx reg = gen_reg_rtx (Pmode);
2852 emit_insn (gen_elf_high (reg, x));
2853 return gen_rtx_LO_SUM (Pmode, reg, x);
2855 else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
2858 && ! MACHO_DYNAMIC_NO_PIC_P
2860 && GET_CODE (x) != CONST_INT
2861 && GET_CODE (x) != CONST_DOUBLE
2863 && ((TARGET_HARD_FLOAT && TARGET_FPRS) || mode != DFmode)
2867 rtx reg = gen_reg_rtx (Pmode);
2868 emit_insn (gen_macho_high (reg, x));
2869 return gen_rtx_LO_SUM (Pmode, reg, x);
2872 && constant_pool_expr_p (x)
2873 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
2875 return create_TOC_reference (x);
2881 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
2882 We need to emit DTP-relative relocations. */
2885 rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
2890 fputs ("\t.long\t", file);
2893 fputs (DOUBLE_INT_ASM_OP, file);
2898 output_addr_const (file, x);
2899 fputs ("@dtprel+0x8000", file);
2902 /* Construct the SYMBOL_REF for the tls_get_addr function. */
2904 static GTY(()) rtx rs6000_tls_symbol;
2906 rs6000_tls_get_addr (void)
2908 if (!rs6000_tls_symbol)
2909 rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr");
2911 return rs6000_tls_symbol;
2914 /* Construct the SYMBOL_REF for TLS GOT references. */
2916 static GTY(()) rtx rs6000_got_symbol;
2918 rs6000_got_sym (void)
2920 if (!rs6000_got_symbol)
2922 rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
2923 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL;
2924 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL;
2927 return rs6000_got_symbol;
2930 /* ADDR contains a thread-local SYMBOL_REF. Generate code to compute
2931 this (thread-local) address. */
2934 rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
2938 dest = gen_reg_rtx (Pmode);
2939 if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 16)
2945 tlsreg = gen_rtx_REG (Pmode, 13);
2946 insn = gen_tls_tprel_64 (dest, tlsreg, addr);
2950 tlsreg = gen_rtx_REG (Pmode, 2);
2951 insn = gen_tls_tprel_32 (dest, tlsreg, addr);
2955 else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32)
2959 tmp = gen_reg_rtx (Pmode);
2962 tlsreg = gen_rtx_REG (Pmode, 13);
2963 insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr);
2967 tlsreg = gen_rtx_REG (Pmode, 2);
2968 insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr);
2972 insn = gen_tls_tprel_lo_64 (dest, tmp, addr);
2974 insn = gen_tls_tprel_lo_32 (dest, tmp, addr);
2979 rtx r3, got, tga, tmp1, tmp2, eqv;
2981 /* We currently use relocations like @got@tlsgd for tls, which
2982 means the linker will handle allocation of tls entries, placing
2983 them in the .got section. So use a pointer to the .got section,
2984 not one to secondary TOC sections used by 64-bit -mminimal-toc,
2985 or to secondary GOT sections used by 32-bit -fPIC. */
2987 got = gen_rtx_REG (Pmode, 2);
2991 got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
2994 rtx gsym = rs6000_got_sym ();
2995 got = gen_reg_rtx (Pmode);
2997 rs6000_emit_move (got, gsym, Pmode);
3000 rtx tempLR, tmp3, mem;
3003 tempLR = gen_reg_rtx (Pmode);
3004 tmp1 = gen_reg_rtx (Pmode);
3005 tmp2 = gen_reg_rtx (Pmode);
3006 tmp3 = gen_reg_rtx (Pmode);
3007 mem = gen_const_mem (Pmode, tmp1);
3009 first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, gsym));
3010 emit_move_insn (tmp1, tempLR);
3011 emit_move_insn (tmp2, mem);
3012 emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
3013 last = emit_move_insn (got, tmp3);
3014 REG_NOTES (last) = gen_rtx_EXPR_LIST (REG_EQUAL, gsym,
3016 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
3018 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
3024 if (model == TLS_MODEL_GLOBAL_DYNAMIC)
3026 r3 = gen_rtx_REG (Pmode, 3);
3028 insn = gen_tls_gd_64 (r3, got, addr);
3030 insn = gen_tls_gd_32 (r3, got, addr);
3033 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3034 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3035 insn = emit_call_insn (insn);
3036 CONST_OR_PURE_CALL_P (insn) = 1;
3037 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3038 insn = get_insns ();
3040 emit_libcall_block (insn, dest, r3, addr);
3042 else if (model == TLS_MODEL_LOCAL_DYNAMIC)
3044 r3 = gen_rtx_REG (Pmode, 3);
3046 insn = gen_tls_ld_64 (r3, got);
3048 insn = gen_tls_ld_32 (r3, got);
3051 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3052 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3053 insn = emit_call_insn (insn);
3054 CONST_OR_PURE_CALL_P (insn) = 1;
3055 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3056 insn = get_insns ();
3058 tmp1 = gen_reg_rtx (Pmode);
3059 eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
3061 emit_libcall_block (insn, tmp1, r3, eqv);
3062 if (rs6000_tls_size == 16)
3065 insn = gen_tls_dtprel_64 (dest, tmp1, addr);
3067 insn = gen_tls_dtprel_32 (dest, tmp1, addr);
3069 else if (rs6000_tls_size == 32)
3071 tmp2 = gen_reg_rtx (Pmode);
3073 insn = gen_tls_dtprel_ha_64 (tmp2, tmp1, addr);
3075 insn = gen_tls_dtprel_ha_32 (tmp2, tmp1, addr);
3078 insn = gen_tls_dtprel_lo_64 (dest, tmp2, addr);
3080 insn = gen_tls_dtprel_lo_32 (dest, tmp2, addr);
3084 tmp2 = gen_reg_rtx (Pmode);
3086 insn = gen_tls_got_dtprel_64 (tmp2, got, addr);
3088 insn = gen_tls_got_dtprel_32 (tmp2, got, addr);
3090 insn = gen_rtx_SET (Pmode, dest,
3091 gen_rtx_PLUS (Pmode, tmp2, tmp1));
3097 /* IE, or 64 bit offset LE. */
3098 tmp2 = gen_reg_rtx (Pmode);
3100 insn = gen_tls_got_tprel_64 (tmp2, got, addr);
3102 insn = gen_tls_got_tprel_32 (tmp2, got, addr);
3105 insn = gen_tls_tls_64 (dest, tmp2, addr);
3107 insn = gen_tls_tls_32 (dest, tmp2, addr);
3115 /* Return 1 if X contains a thread-local symbol. */
3118 rs6000_tls_referenced_p (rtx x)
3120 if (! TARGET_HAVE_TLS)
3123 return for_each_rtx (&x, &rs6000_tls_symbol_ref_1, 0);
3126 /* Return 1 if *X is a thread-local symbol. This is the same as
3127 rs6000_tls_symbol_ref except for the type of the unused argument. */
3130 rs6000_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
3132 return RS6000_SYMBOL_REF_TLS_P (*x);
3135 /* The convention appears to be to define this wherever it is used.
3136 With legitimize_reload_address now defined here, REG_MODE_OK_FOR_BASE_P
3137 is now used here. */
3138 #ifndef REG_MODE_OK_FOR_BASE_P
3139 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
3142 /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS. Returns a value to
3143 replace the input X, or the original X if no replacement is called for.
3144 The output parameter *WIN is 1 if the calling macro should goto WIN,
3147 For RS/6000, we wish to handle large displacements off a base
3148 register by splitting the addend across an addiu/addis and the mem insn.
3149 This cuts number of extra insns needed from 3 to 1.
3151 On Darwin, we use this to generate code for floating point constants.
3152 A movsf_low is generated so we wind up with 2 instructions rather than 3.
3153 The Darwin code is inside #if TARGET_MACHO because only then is
3154 machopic_function_base_name() defined. */
3156 rs6000_legitimize_reload_address (rtx x, enum machine_mode mode,
3157 int opnum, int type,
3158 int ind_levels ATTRIBUTE_UNUSED, int *win)
3160 /* We must recognize output that we have already generated ourselves. */
3161 if (GET_CODE (x) == PLUS
3162 && GET_CODE (XEXP (x, 0)) == PLUS
3163 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3164 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3165 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3167 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3168 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3169 opnum, (enum reload_type)type);
3175 if (DEFAULT_ABI == ABI_DARWIN && flag_pic
3176 && GET_CODE (x) == LO_SUM
3177 && GET_CODE (XEXP (x, 0)) == PLUS
3178 && XEXP (XEXP (x, 0), 0) == pic_offset_table_rtx
3179 && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH
3180 && GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 0)) == CONST
3181 && XEXP (XEXP (XEXP (x, 0), 1), 0) == XEXP (x, 1)
3182 && GET_CODE (XEXP (XEXP (x, 1), 0)) == MINUS
3183 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 0)) == SYMBOL_REF
3184 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 1)) == SYMBOL_REF)
3186 /* Result of previous invocation of this function on Darwin
3187 floating point constant. */
3188 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3189 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3190 opnum, (enum reload_type)type);
3196 /* Force ld/std non-word aligned offset into base register by wrapping
3198 if (GET_CODE (x) == PLUS
3199 && GET_CODE (XEXP (x, 0)) == REG
3200 && REGNO (XEXP (x, 0)) < 32
3201 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3202 && GET_CODE (XEXP (x, 1)) == CONST_INT
3203 && (INTVAL (XEXP (x, 1)) & 3) != 0
3204 && !ALTIVEC_VECTOR_MODE (mode)
3205 && GET_MODE_SIZE (mode) >= UNITS_PER_WORD
3206 && TARGET_POWERPC64)
3208 x = gen_rtx_PLUS (GET_MODE (x), x, GEN_INT (0));
3209 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3210 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3211 opnum, (enum reload_type) type);
3216 if (GET_CODE (x) == PLUS
3217 && GET_CODE (XEXP (x, 0)) == REG
3218 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
3219 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3220 && GET_CODE (XEXP (x, 1)) == CONST_INT
3221 && !SPE_VECTOR_MODE (mode)
3222 && !(TARGET_E500_DOUBLE && (mode == DFmode
3224 && !ALTIVEC_VECTOR_MODE (mode))
3226 HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
3227 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
3229 = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;
3231 /* Check for 32-bit overflow. */
3232 if (high + low != val)
3238 /* Reload the high part into a base reg; leave the low part
3239 in the mem directly. */
3241 x = gen_rtx_PLUS (GET_MODE (x),
3242 gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
3246 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3247 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3248 opnum, (enum reload_type)type);
3253 if (GET_CODE (x) == SYMBOL_REF
3254 && !ALTIVEC_VECTOR_MODE (mode)
3256 && DEFAULT_ABI == ABI_DARWIN
3257 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
3259 && DEFAULT_ABI == ABI_V4
3262 /* Don't do this for TFmode, since the result isn't offsettable.
3263 The same goes for DImode without 64-bit gprs. */
3265 && (mode != DImode || TARGET_POWERPC64))
3270 rtx offset = gen_rtx_CONST (Pmode,
3271 gen_rtx_MINUS (Pmode, x,
3272 machopic_function_base_sym ()));
3273 x = gen_rtx_LO_SUM (GET_MODE (x),
3274 gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
3275 gen_rtx_HIGH (Pmode, offset)), offset);
3279 x = gen_rtx_LO_SUM (GET_MODE (x),
3280 gen_rtx_HIGH (Pmode, x), x);
3282 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3283 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3284 opnum, (enum reload_type)type);
3289 /* Reload an offset address wrapped by an AND that represents the
3290 masking of the lower bits. Strip the outer AND and let reload
3291 convert the offset address into an indirect address. */
3293 && ALTIVEC_VECTOR_MODE (mode)
3294 && GET_CODE (x) == AND
3295 && GET_CODE (XEXP (x, 0)) == PLUS
3296 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3297 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3298 && GET_CODE (XEXP (x, 1)) == CONST_INT
3299 && INTVAL (XEXP (x, 1)) == -16)
3307 && constant_pool_expr_p (x)
3308 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
3310 (x) = create_TOC_reference (x);
3318 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
3319 that is a valid memory address for an instruction.
3320 The MODE argument is the machine mode for the MEM expression
3321 that wants to use this address.
3323 On the RS/6000, there are four valid address: a SYMBOL_REF that
3324 refers to a constant pool entry of an address (or the sum of it
3325 plus a constant), a short (16-bit signed) constant plus a register,
3326 the sum of two registers, or a register indirect, possibly with an
3327 auto-increment. For DFmode and DImode with a constant plus register,
3328 we must ensure that both words are addressable or PowerPC64 with offset
3331 For modes spanning multiple registers (DFmode in 32-bit GPRs,
3332 32-bit DImode, TImode, TFmode), indexed addressing cannot be used because
3333 adjacent memory cells are accessed by adding word-sized offsets
3334 during assembly output. */
3336 rs6000_legitimate_address (enum machine_mode mode, rtx x, int reg_ok_strict)
3338 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */
3340 && ALTIVEC_VECTOR_MODE (mode)
3341 && GET_CODE (x) == AND
3342 && GET_CODE (XEXP (x, 1)) == CONST_INT
3343 && INTVAL (XEXP (x, 1)) == -16)
3346 if (RS6000_SYMBOL_REF_TLS_P (x))
3348 if (legitimate_indirect_address_p (x, reg_ok_strict))
3350 if ((GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
3351 && !ALTIVEC_VECTOR_MODE (mode)
3352 && !SPE_VECTOR_MODE (mode)
3353 /* Restrict addressing for DI because of our SUBREG hackery. */
3354 && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
3356 && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict))
3358 if (rs6000_legitimate_small_data_p (mode, x))
3360 if (legitimate_constant_pool_address_p (x))
3362 /* If not REG_OK_STRICT (before reload) let pass any stack offset. */
3364 && GET_CODE (x) == PLUS
3365 && GET_CODE (XEXP (x, 0)) == REG
3366 && (XEXP (x, 0) == virtual_stack_vars_rtx
3367 || XEXP (x, 0) == arg_pointer_rtx)
3368 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3370 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict))
3374 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3376 || ((mode != DFmode || TARGET_E500_DOUBLE) && mode != TFmode))
3377 && (TARGET_POWERPC64 || mode != DImode)
3378 && legitimate_indexed_address_p (x, reg_ok_strict))
3380 if (legitimate_lo_sum_address_p (mode, x, reg_ok_strict))
3385 /* Go to LABEL if ADDR (a legitimate address expression)
3386 has an effect that depends on the machine mode it is used for.
3388 On the RS/6000 this is true of all integral offsets (since AltiVec
3389 modes don't allow them) or is a pre-increment or decrement.
3391 ??? Except that due to conceptual problems in offsettable_address_p
3392 we can't really report the problems of integral offsets. So leave
3393 this assuming that the adjustable offset must be valid for the
3394 sub-words of a TFmode operand, which is what we had before. */
3397 rs6000_mode_dependent_address (rtx addr)
3399 switch (GET_CODE (addr))
3402 if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
3404 unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
3405 return val + 12 + 0x8000 >= 0x10000;
3414 return TARGET_UPDATE;
3423 /* Return number of consecutive hard regs needed starting at reg REGNO
3424 to hold something of mode MODE.
3425 This is ordinarily the length in words of a value of mode MODE