1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006
4 Free Software Foundation, Inc.
5 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 2, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the
21 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 MA 02110-1301, USA. */
26 #include "coretypes.h"
30 #include "hard-reg-set.h"
32 #include "insn-config.h"
33 #include "conditions.h"
34 #include "insn-attr.h"
44 #include "basic-block.h"
45 #include "integrate.h"
51 #include "target-def.h"
52 #include "langhooks.h"
54 #include "cfglayout.h"
55 #include "sched-int.h"
56 #include "tree-gimple.h"
59 #include "tm-constrs.h"
61 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
64 #include "gstab.h" /* for N_SLINE */
67 #ifndef TARGET_NO_PROTOTYPE
68 #define TARGET_NO_PROTOTYPE 0
71 #define min(A,B) ((A) < (B) ? (A) : (B))
72 #define max(A,B) ((A) > (B) ? (A) : (B))
74 /* Structure used to define the rs6000 stack */
75 typedef struct rs6000_stack {
76 int first_gp_reg_save; /* first callee saved GP register used */
77 int first_fp_reg_save; /* first callee saved FP register used */
78 int first_altivec_reg_save; /* first callee saved AltiVec register used */
79 int lr_save_p; /* true if the link reg needs to be saved */
80 int cr_save_p; /* true if the CR reg needs to be saved */
81 unsigned int vrsave_mask; /* mask of vec registers to save */
82 int push_p; /* true if we need to allocate stack space */
83 int calls_p; /* true if the function makes any calls */
84 int world_save_p; /* true if we're saving *everything*:
85 r13-r31, cr, f14-f31, vrsave, v20-v31 */
86 enum rs6000_abi abi; /* which ABI to use */
87 int gp_save_offset; /* offset to save GP regs from initial SP */
88 int fp_save_offset; /* offset to save FP regs from initial SP */
89 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
90 int lr_save_offset; /* offset to save LR from initial SP */
91 int cr_save_offset; /* offset to save CR from initial SP */
92 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
93 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
94 int varargs_save_offset; /* offset to save the varargs registers */
95 int ehrd_offset; /* offset to EH return data */
96 int reg_size; /* register size (4 or 8) */
97 HOST_WIDE_INT vars_size; /* variable save area size */
98 int parm_size; /* outgoing parameter size */
99 int save_size; /* save area size */
100 int fixed_size; /* fixed size of stack frame */
101 int gp_size; /* size of saved GP registers */
102 int fp_size; /* size of saved FP registers */
103 int altivec_size; /* size of saved AltiVec registers */
104 int cr_size; /* size to hold CR if not in save_size */
105 int vrsave_size; /* size to hold VRSAVE if not in save_size */
106 int altivec_padding_size; /* size of altivec alignment padding if
108 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
109 int spe_padding_size;
110 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
111 int spe_64bit_regs_used;
114 /* A C structure for machine-specific, per-function data.
115 This is added to the cfun structure. */
116 typedef struct machine_function GTY(())
118 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
119 int ra_needs_full_frame;
120 /* Some local-dynamic symbol. */
121 const char *some_ld_name;
122 /* Whether the instruction chain has been scanned already. */
123 int insn_chain_scanned_p;
124 /* Flags if __builtin_return_address (0) was used. */
126 /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4
127 varargs save area. */
128 HOST_WIDE_INT varargs_save_offset;
131 /* Target cpu type */
133 enum processor_type rs6000_cpu;
134 struct rs6000_cpu_select rs6000_select[3] =
136 /* switch name, tune arch */
137 { (const char *)0, "--with-cpu=", 1, 1 },
138 { (const char *)0, "-mcpu=", 1, 1 },
139 { (const char *)0, "-mtune=", 1, 0 },
142 /* Always emit branch hint bits. */
143 static GTY(()) bool rs6000_always_hint;
145 /* Schedule instructions for group formation. */
146 static GTY(()) bool rs6000_sched_groups;
148 /* Align branch targets. */
149 static GTY(()) bool rs6000_align_branch_targets;
151 /* Support for -msched-costly-dep option. */
152 const char *rs6000_sched_costly_dep_str;
153 enum rs6000_dependence_cost rs6000_sched_costly_dep;
155 /* Support for -minsert-sched-nops option. */
156 const char *rs6000_sched_insert_nops_str;
157 enum rs6000_nop_insertion rs6000_sched_insert_nops;
159 /* Support targetm.vectorize.builtin_mask_for_load. */
160 static GTY(()) tree altivec_builtin_mask_for_load;
162 /* Size of long double. */
163 int rs6000_long_double_type_size;
165 /* IEEE quad extended precision long double. */
168 /* Whether -mabi=altivec has appeared. */
169 int rs6000_altivec_abi;
171 /* Nonzero if we want SPE ABI extensions. */
174 /* Nonzero if floating point operations are done in the GPRs. */
175 int rs6000_float_gprs = 0;
177 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
178 int rs6000_darwin64_abi;
180 /* Set to nonzero once AIX common-mode calls have been defined. */
181 static GTY(()) int common_mode_defined;
183 /* Save information from a "cmpxx" operation until the branch or scc is
185 rtx rs6000_compare_op0, rs6000_compare_op1;
186 int rs6000_compare_fp_p;
188 /* Label number of label created for -mrelocatable, to call to so we can
189 get the address of the GOT section */
190 int rs6000_pic_labelno;
193 /* Which abi to adhere to */
194 const char *rs6000_abi_name;
196 /* Semantics of the small data area */
197 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
199 /* Which small data model to use */
200 const char *rs6000_sdata_name = (char *)0;
202 /* Counter for labels which are to be placed in .fixup. */
203 int fixuplabelno = 0;
206 /* Bit size of immediate TLS offsets and string from which it is decoded. */
207 int rs6000_tls_size = 32;
208 const char *rs6000_tls_size_string;
210 /* ABI enumeration available for subtarget to use. */
211 enum rs6000_abi rs6000_current_abi;
213 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
217 const char *rs6000_debug_name;
218 int rs6000_debug_stack; /* debug stack applications */
219 int rs6000_debug_arg; /* debug argument handling */
221 /* Value is TRUE if register/mode pair is acceptable. */
222 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
224 /* Built in types. */
226 tree rs6000_builtin_types[RS6000_BTI_MAX];
227 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
229 const char *rs6000_traceback_name;
231 traceback_default = 0,
237 /* Flag to say the TOC is initialized */
239 char toc_label_name[10];
241 /* Cached value of rs6000_variable_issue. This is cached in
242 rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */
243 static short cached_can_issue_more;
245 static GTY(()) section *read_only_data_section;
246 static GTY(()) section *private_data_section;
247 static GTY(()) section *read_only_private_data_section;
248 static GTY(()) section *sdata2_section;
249 static GTY(()) section *toc_section;
251 /* Control alignment for fields within structures. */
252 /* String from -malign-XXXXX. */
253 int rs6000_alignment_flags;
255 /* True for any options that were explicitly set. */
257 bool aix_struct_ret; /* True if -maix-struct-ret was used. */
258 bool alignment; /* True if -malign- was used. */
259 bool abi; /* True if -mabi=spe/nospe was used. */
260 bool spe; /* True if -mspe= was used. */
261 bool float_gprs; /* True if -mfloat-gprs= was used. */
262 bool isel; /* True if -misel was used. */
263 bool long_double; /* True if -mlong-double- was used. */
264 bool ieee; /* True if -mabi=ieee/ibmlongdouble used. */
265 } rs6000_explicit_options;
267 struct builtin_description
269 /* mask is not const because we're going to alter it below. This
270 nonsense will go away when we rewrite the -march infrastructure
271 to give us more target flag bits. */
273 const enum insn_code icode;
274 const char *const name;
275 const enum rs6000_builtins code;
278 /* Target cpu costs. */
280 struct processor_costs {
281 const int mulsi; /* cost of SImode multiplication. */
282 const int mulsi_const; /* cost of SImode multiplication by constant. */
283 const int mulsi_const9; /* cost of SImode mult by short constant. */
284 const int muldi; /* cost of DImode multiplication. */
285 const int divsi; /* cost of SImode division. */
286 const int divdi; /* cost of DImode division. */
287 const int fp; /* cost of simple SFmode and DFmode insns. */
288 const int dmul; /* cost of DFmode multiplication (and fmadd). */
289 const int sdiv; /* cost of SFmode division (fdivs). */
290 const int ddiv; /* cost of DFmode division (fdiv). */
293 const struct processor_costs *rs6000_cost;
295 /* Processor costs (relative to an add) */
297 /* Instruction size costs on 32bit processors. */
299 struct processor_costs size32_cost = {
300 COSTS_N_INSNS (1), /* mulsi */
301 COSTS_N_INSNS (1), /* mulsi_const */
302 COSTS_N_INSNS (1), /* mulsi_const9 */
303 COSTS_N_INSNS (1), /* muldi */
304 COSTS_N_INSNS (1), /* divsi */
305 COSTS_N_INSNS (1), /* divdi */
306 COSTS_N_INSNS (1), /* fp */
307 COSTS_N_INSNS (1), /* dmul */
308 COSTS_N_INSNS (1), /* sdiv */
309 COSTS_N_INSNS (1), /* ddiv */
312 /* Instruction size costs on 64bit processors. */
314 struct processor_costs size64_cost = {
315 COSTS_N_INSNS (1), /* mulsi */
316 COSTS_N_INSNS (1), /* mulsi_const */
317 COSTS_N_INSNS (1), /* mulsi_const9 */
318 COSTS_N_INSNS (1), /* muldi */
319 COSTS_N_INSNS (1), /* divsi */
320 COSTS_N_INSNS (1), /* divdi */
321 COSTS_N_INSNS (1), /* fp */
322 COSTS_N_INSNS (1), /* dmul */
323 COSTS_N_INSNS (1), /* sdiv */
324 COSTS_N_INSNS (1), /* ddiv */
327 /* Instruction costs on RIOS1 processors. */
329 struct processor_costs rios1_cost = {
330 COSTS_N_INSNS (5), /* mulsi */
331 COSTS_N_INSNS (4), /* mulsi_const */
332 COSTS_N_INSNS (3), /* mulsi_const9 */
333 COSTS_N_INSNS (5), /* muldi */
334 COSTS_N_INSNS (19), /* divsi */
335 COSTS_N_INSNS (19), /* divdi */
336 COSTS_N_INSNS (2), /* fp */
337 COSTS_N_INSNS (2), /* dmul */
338 COSTS_N_INSNS (19), /* sdiv */
339 COSTS_N_INSNS (19), /* ddiv */
342 /* Instruction costs on RIOS2 processors. */
344 struct processor_costs rios2_cost = {
345 COSTS_N_INSNS (2), /* mulsi */
346 COSTS_N_INSNS (2), /* mulsi_const */
347 COSTS_N_INSNS (2), /* mulsi_const9 */
348 COSTS_N_INSNS (2), /* muldi */
349 COSTS_N_INSNS (13), /* divsi */
350 COSTS_N_INSNS (13), /* divdi */
351 COSTS_N_INSNS (2), /* fp */
352 COSTS_N_INSNS (2), /* dmul */
353 COSTS_N_INSNS (17), /* sdiv */
354 COSTS_N_INSNS (17), /* ddiv */
357 /* Instruction costs on RS64A processors. */
359 struct processor_costs rs64a_cost = {
360 COSTS_N_INSNS (20), /* mulsi */
361 COSTS_N_INSNS (12), /* mulsi_const */
362 COSTS_N_INSNS (8), /* mulsi_const9 */
363 COSTS_N_INSNS (34), /* muldi */
364 COSTS_N_INSNS (65), /* divsi */
365 COSTS_N_INSNS (67), /* divdi */
366 COSTS_N_INSNS (4), /* fp */
367 COSTS_N_INSNS (4), /* dmul */
368 COSTS_N_INSNS (31), /* sdiv */
369 COSTS_N_INSNS (31), /* ddiv */
372 /* Instruction costs on MPCCORE processors. */
374 struct processor_costs mpccore_cost = {
375 COSTS_N_INSNS (2), /* mulsi */
376 COSTS_N_INSNS (2), /* mulsi_const */
377 COSTS_N_INSNS (2), /* mulsi_const9 */
378 COSTS_N_INSNS (2), /* muldi */
379 COSTS_N_INSNS (6), /* divsi */
380 COSTS_N_INSNS (6), /* divdi */
381 COSTS_N_INSNS (4), /* fp */
382 COSTS_N_INSNS (5), /* dmul */
383 COSTS_N_INSNS (10), /* sdiv */
384 COSTS_N_INSNS (17), /* ddiv */
387 /* Instruction costs on PPC403 processors. */
389 struct processor_costs ppc403_cost = {
390 COSTS_N_INSNS (4), /* mulsi */
391 COSTS_N_INSNS (4), /* mulsi_const */
392 COSTS_N_INSNS (4), /* mulsi_const9 */
393 COSTS_N_INSNS (4), /* muldi */
394 COSTS_N_INSNS (33), /* divsi */
395 COSTS_N_INSNS (33), /* divdi */
396 COSTS_N_INSNS (11), /* fp */
397 COSTS_N_INSNS (11), /* dmul */
398 COSTS_N_INSNS (11), /* sdiv */
399 COSTS_N_INSNS (11), /* ddiv */
402 /* Instruction costs on PPC405 processors. */
404 struct processor_costs ppc405_cost = {
405 COSTS_N_INSNS (5), /* mulsi */
406 COSTS_N_INSNS (4), /* mulsi_const */
407 COSTS_N_INSNS (3), /* mulsi_const9 */
408 COSTS_N_INSNS (5), /* muldi */
409 COSTS_N_INSNS (35), /* divsi */
410 COSTS_N_INSNS (35), /* divdi */
411 COSTS_N_INSNS (11), /* fp */
412 COSTS_N_INSNS (11), /* dmul */
413 COSTS_N_INSNS (11), /* sdiv */
414 COSTS_N_INSNS (11), /* ddiv */
417 /* Instruction costs on PPC440 processors. */
419 struct processor_costs ppc440_cost = {
420 COSTS_N_INSNS (3), /* mulsi */
421 COSTS_N_INSNS (2), /* mulsi_const */
422 COSTS_N_INSNS (2), /* mulsi_const9 */
423 COSTS_N_INSNS (3), /* muldi */
424 COSTS_N_INSNS (34), /* divsi */
425 COSTS_N_INSNS (34), /* divdi */
426 COSTS_N_INSNS (5), /* fp */
427 COSTS_N_INSNS (5), /* dmul */
428 COSTS_N_INSNS (19), /* sdiv */
429 COSTS_N_INSNS (33), /* ddiv */
432 /* Instruction costs on PPC601 processors. */
434 struct processor_costs ppc601_cost = {
435 COSTS_N_INSNS (5), /* mulsi */
436 COSTS_N_INSNS (5), /* mulsi_const */
437 COSTS_N_INSNS (5), /* mulsi_const9 */
438 COSTS_N_INSNS (5), /* muldi */
439 COSTS_N_INSNS (36), /* divsi */
440 COSTS_N_INSNS (36), /* divdi */
441 COSTS_N_INSNS (4), /* fp */
442 COSTS_N_INSNS (5), /* dmul */
443 COSTS_N_INSNS (17), /* sdiv */
444 COSTS_N_INSNS (31), /* ddiv */
447 /* Instruction costs on PPC603 processors. */
449 struct processor_costs ppc603_cost = {
450 COSTS_N_INSNS (5), /* mulsi */
451 COSTS_N_INSNS (3), /* mulsi_const */
452 COSTS_N_INSNS (2), /* mulsi_const9 */
453 COSTS_N_INSNS (5), /* muldi */
454 COSTS_N_INSNS (37), /* divsi */
455 COSTS_N_INSNS (37), /* divdi */
456 COSTS_N_INSNS (3), /* fp */
457 COSTS_N_INSNS (4), /* dmul */
458 COSTS_N_INSNS (18), /* sdiv */
459 COSTS_N_INSNS (33), /* ddiv */
462 /* Instruction costs on PPC604 processors. */
464 struct processor_costs ppc604_cost = {
465 COSTS_N_INSNS (4), /* mulsi */
466 COSTS_N_INSNS (4), /* mulsi_const */
467 COSTS_N_INSNS (4), /* mulsi_const9 */
468 COSTS_N_INSNS (4), /* muldi */
469 COSTS_N_INSNS (20), /* divsi */
470 COSTS_N_INSNS (20), /* divdi */
471 COSTS_N_INSNS (3), /* fp */
472 COSTS_N_INSNS (3), /* dmul */
473 COSTS_N_INSNS (18), /* sdiv */
474 COSTS_N_INSNS (32), /* ddiv */
477 /* Instruction costs on PPC604e processors. */
479 struct processor_costs ppc604e_cost = {
480 COSTS_N_INSNS (2), /* mulsi */
481 COSTS_N_INSNS (2), /* mulsi_const */
482 COSTS_N_INSNS (2), /* mulsi_const9 */
483 COSTS_N_INSNS (2), /* muldi */
484 COSTS_N_INSNS (20), /* divsi */
485 COSTS_N_INSNS (20), /* divdi */
486 COSTS_N_INSNS (3), /* fp */
487 COSTS_N_INSNS (3), /* dmul */
488 COSTS_N_INSNS (18), /* sdiv */
489 COSTS_N_INSNS (32), /* ddiv */
492 /* Instruction costs on PPC620 processors. */
494 struct processor_costs ppc620_cost = {
495 COSTS_N_INSNS (5), /* mulsi */
496 COSTS_N_INSNS (4), /* mulsi_const */
497 COSTS_N_INSNS (3), /* mulsi_const9 */
498 COSTS_N_INSNS (7), /* muldi */
499 COSTS_N_INSNS (21), /* divsi */
500 COSTS_N_INSNS (37), /* divdi */
501 COSTS_N_INSNS (3), /* fp */
502 COSTS_N_INSNS (3), /* dmul */
503 COSTS_N_INSNS (18), /* sdiv */
504 COSTS_N_INSNS (32), /* ddiv */
507 /* Instruction costs on PPC630 processors. */
509 struct processor_costs ppc630_cost = {
510 COSTS_N_INSNS (5), /* mulsi */
511 COSTS_N_INSNS (4), /* mulsi_const */
512 COSTS_N_INSNS (3), /* mulsi_const9 */
513 COSTS_N_INSNS (7), /* muldi */
514 COSTS_N_INSNS (21), /* divsi */
515 COSTS_N_INSNS (37), /* divdi */
516 COSTS_N_INSNS (3), /* fp */
517 COSTS_N_INSNS (3), /* dmul */
518 COSTS_N_INSNS (17), /* sdiv */
519 COSTS_N_INSNS (21), /* ddiv */
522 /* Instruction costs on PPC750 and PPC7400 processors. */
524 struct processor_costs ppc750_cost = {
525 COSTS_N_INSNS (5), /* mulsi */
526 COSTS_N_INSNS (3), /* mulsi_const */
527 COSTS_N_INSNS (2), /* mulsi_const9 */
528 COSTS_N_INSNS (5), /* muldi */
529 COSTS_N_INSNS (17), /* divsi */
530 COSTS_N_INSNS (17), /* divdi */
531 COSTS_N_INSNS (3), /* fp */
532 COSTS_N_INSNS (3), /* dmul */
533 COSTS_N_INSNS (17), /* sdiv */
534 COSTS_N_INSNS (31), /* ddiv */
537 /* Instruction costs on PPC7450 processors. */
539 struct processor_costs ppc7450_cost = {
540 COSTS_N_INSNS (4), /* mulsi */
541 COSTS_N_INSNS (3), /* mulsi_const */
542 COSTS_N_INSNS (3), /* mulsi_const9 */
543 COSTS_N_INSNS (4), /* muldi */
544 COSTS_N_INSNS (23), /* divsi */
545 COSTS_N_INSNS (23), /* divdi */
546 COSTS_N_INSNS (5), /* fp */
547 COSTS_N_INSNS (5), /* dmul */
548 COSTS_N_INSNS (21), /* sdiv */
549 COSTS_N_INSNS (35), /* ddiv */
552 /* Instruction costs on PPC8540 processors. */
554 struct processor_costs ppc8540_cost = {
555 COSTS_N_INSNS (4), /* mulsi */
556 COSTS_N_INSNS (4), /* mulsi_const */
557 COSTS_N_INSNS (4), /* mulsi_const9 */
558 COSTS_N_INSNS (4), /* muldi */
559 COSTS_N_INSNS (19), /* divsi */
560 COSTS_N_INSNS (19), /* divdi */
561 COSTS_N_INSNS (4), /* fp */
562 COSTS_N_INSNS (4), /* dmul */
563 COSTS_N_INSNS (29), /* sdiv */
564 COSTS_N_INSNS (29), /* ddiv */
567 /* Instruction costs on POWER4 and POWER5 processors. */
569 struct processor_costs power4_cost = {
570 COSTS_N_INSNS (3), /* mulsi */
571 COSTS_N_INSNS (2), /* mulsi_const */
572 COSTS_N_INSNS (2), /* mulsi_const9 */
573 COSTS_N_INSNS (4), /* muldi */
574 COSTS_N_INSNS (18), /* divsi */
575 COSTS_N_INSNS (34), /* divdi */
576 COSTS_N_INSNS (3), /* fp */
577 COSTS_N_INSNS (3), /* dmul */
578 COSTS_N_INSNS (17), /* sdiv */
579 COSTS_N_INSNS (17), /* ddiv */
582 /* Instruction costs on POWER6 processors. */
584 struct processor_costs power6_cost = {
585 COSTS_N_INSNS (8), /* mulsi */
586 COSTS_N_INSNS (8), /* mulsi_const */
587 COSTS_N_INSNS (8), /* mulsi_const9 */
588 COSTS_N_INSNS (8), /* muldi */
589 COSTS_N_INSNS (22), /* divsi */
590 COSTS_N_INSNS (28), /* divdi */
591 COSTS_N_INSNS (3), /* fp */
592 COSTS_N_INSNS (3), /* dmul */
593 COSTS_N_INSNS (13), /* sdiv */
594 COSTS_N_INSNS (16), /* ddiv */
598 static bool rs6000_function_ok_for_sibcall (tree, tree);
599 static const char *rs6000_invalid_within_doloop (rtx);
600 static rtx rs6000_generate_compare (enum rtx_code);
601 static void rs6000_maybe_dead (rtx);
602 static void rs6000_emit_stack_tie (void);
603 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
604 static rtx spe_synthesize_frame_save (rtx);
605 static bool spe_func_has_64bit_regs_p (void);
606 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
608 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
609 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int);
610 static unsigned rs6000_hash_constant (rtx);
611 static unsigned toc_hash_function (const void *);
612 static int toc_hash_eq (const void *, const void *);
613 static int constant_pool_expr_1 (rtx, int *, int *);
614 static bool constant_pool_expr_p (rtx);
615 static bool legitimate_small_data_p (enum machine_mode, rtx);
616 static bool legitimate_indexed_address_p (rtx, int);
617 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
618 static struct machine_function * rs6000_init_machine_status (void);
619 static bool rs6000_assemble_integer (rtx, unsigned int, int);
620 static bool no_global_regs_above (int);
621 #ifdef HAVE_GAS_HIDDEN
622 static void rs6000_assemble_visibility (tree, int);
624 static int rs6000_ra_ever_killed (void);
625 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
626 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
627 static bool rs6000_ms_bitfield_layout_p (tree);
628 static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *);
629 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
630 static const char *rs6000_mangle_fundamental_type (tree);
631 extern const struct attribute_spec rs6000_attribute_table[];
632 static void rs6000_set_default_type_attributes (tree);
633 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
634 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
635 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
637 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
638 static bool rs6000_return_in_memory (tree, tree);
639 static void rs6000_file_start (void);
641 static unsigned int rs6000_elf_section_type_flags (tree, const char *, int);
642 static void rs6000_elf_asm_out_constructor (rtx, int);
643 static void rs6000_elf_asm_out_destructor (rtx, int);
644 static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
645 static void rs6000_elf_asm_init_sections (void);
646 static section *rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT);
647 static void rs6000_elf_unique_section (tree, int);
648 static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx,
649 unsigned HOST_WIDE_INT);
650 static void rs6000_elf_encode_section_info (tree, rtx, int)
653 static bool rs6000_use_blocks_for_constant_p (enum machine_mode, rtx);
655 static void rs6000_xcoff_asm_output_anchor (rtx);
656 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
657 static void rs6000_xcoff_asm_init_sections (void);
658 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
659 static section *rs6000_xcoff_select_section (tree, int,
660 unsigned HOST_WIDE_INT);
661 static void rs6000_xcoff_unique_section (tree, int);
662 static section *rs6000_xcoff_select_rtx_section
663 (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
664 static const char * rs6000_xcoff_strip_name_encoding (const char *);
665 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
666 static void rs6000_xcoff_file_start (void);
667 static void rs6000_xcoff_file_end (void);
669 static int rs6000_variable_issue (FILE *, int, rtx, int);
670 static bool rs6000_rtx_costs (rtx, int, int, int *);
671 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
672 static void rs6000_sched_init (FILE *, int, int);
673 static bool is_microcoded_insn (rtx);
674 static bool is_cracked_insn (rtx);
675 static bool is_branch_slot_insn (rtx);
676 static bool is_load_insn (rtx);
677 static bool is_store_insn (rtx);
678 static bool set_to_load_agen (rtx,rtx);
679 static bool adjacent_mem_locations (rtx,rtx);
680 static int rs6000_adjust_priority (rtx, int);
681 static int rs6000_issue_rate (void);
682 static bool rs6000_is_costly_dependence (rtx, rtx, rtx, int, int);
683 static rtx get_next_active_insn (rtx, rtx);
684 static bool insn_terminates_group_p (rtx , enum group_termination);
685 static bool insn_must_be_first_in_group (rtx);
686 static bool insn_must_be_last_in_group (rtx);
687 static bool is_costly_group (rtx *, rtx);
688 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
689 static int redefine_groups (FILE *, int, rtx, rtx);
690 static int pad_groups (FILE *, int, rtx, rtx);
691 static void rs6000_sched_finish (FILE *, int);
692 static int rs6000_sched_reorder (FILE *, int, rtx *, int *, int);
693 static int rs6000_sched_reorder2 (FILE *, int, rtx *, int *, int);
694 static int rs6000_use_sched_lookahead (void);
695 static tree rs6000_builtin_mask_for_load (void);
696 static tree rs6000_builtin_mul_widen_even (tree);
697 static tree rs6000_builtin_mul_widen_odd (tree);
699 static void def_builtin (int, const char *, tree, int);
700 static void rs6000_init_builtins (void);
701 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
702 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
703 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
704 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
705 static void altivec_init_builtins (void);
706 static void rs6000_common_init_builtins (void);
707 static void rs6000_init_libfuncs (void);
709 static void enable_mask_for_builtins (struct builtin_description *, int,
710 enum rs6000_builtins,
711 enum rs6000_builtins);
712 static tree build_opaque_vector_type (tree, int);
713 static void spe_init_builtins (void);
714 static rtx spe_expand_builtin (tree, rtx, bool *);
715 static rtx spe_expand_stv_builtin (enum insn_code, tree);
716 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
717 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
718 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
719 static rs6000_stack_t *rs6000_stack_info (void);
720 static void debug_stack_info (rs6000_stack_t *);
722 static rtx altivec_expand_builtin (tree, rtx, bool *);
723 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
724 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
725 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
726 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
727 static rtx altivec_expand_predicate_builtin (enum insn_code,
728 const char *, tree, rtx);
729 static rtx altivec_expand_lv_builtin (enum insn_code, tree, rtx);
730 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
731 static rtx altivec_expand_vec_init_builtin (tree, tree, rtx);
732 static rtx altivec_expand_vec_set_builtin (tree);
733 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
734 static int get_element_number (tree, tree);
735 static bool rs6000_handle_option (size_t, const char *, int);
736 static void rs6000_parse_tls_size_option (void);
737 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
738 static int first_altivec_reg_to_save (void);
739 static unsigned int compute_vrsave_mask (void);
740 static void compute_save_world_info (rs6000_stack_t *info_ptr);
741 static void is_altivec_return_reg (rtx, void *);
742 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
743 int easy_vector_constant (rtx, enum machine_mode);
744 static bool rs6000_is_opaque_type (tree);
745 static rtx rs6000_dwarf_register_span (rtx);
746 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
747 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
748 static rtx rs6000_tls_get_addr (void);
749 static rtx rs6000_got_sym (void);
750 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
751 static const char *rs6000_get_some_local_dynamic_name (void);
752 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
753 static rtx rs6000_complex_function_value (enum machine_mode);
754 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
755 enum machine_mode, tree);
756 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
758 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
759 tree, HOST_WIDE_INT);
760 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
763 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
766 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, tree, int, bool);
767 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
768 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
769 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
770 enum machine_mode, tree,
772 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
774 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
776 static const char *invalid_arg_for_unprototyped_fn (tree, tree, tree);
778 static void macho_branch_islands (void);
779 static void add_compiler_branch_island (tree, tree, int);
780 static int no_previous_def (tree function_name);
781 static tree get_prev_label (tree function_name);
782 static void rs6000_darwin_file_start (void);
785 static tree rs6000_build_builtin_va_list (void);
786 static tree rs6000_gimplify_va_arg (tree, tree, tree *, tree *);
787 static bool rs6000_must_pass_in_stack (enum machine_mode, tree);
788 static bool rs6000_scalar_mode_supported_p (enum machine_mode);
789 static bool rs6000_vector_mode_supported_p (enum machine_mode);
790 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
792 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
794 static int get_vsel_insn (enum machine_mode);
795 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
796 static tree rs6000_stack_protect_fail (void);
798 const int INSN_NOT_AVAILABLE = -1;
799 static enum machine_mode rs6000_eh_return_filter_mode (void);
801 /* Hash table stuff for keeping track of TOC entries. */
803 struct toc_hash_struct GTY(())
805 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
806 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
808 enum machine_mode key_mode;
812 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
814 /* Default register names. */
815 char rs6000_reg_names[][8] =
817 "0", "1", "2", "3", "4", "5", "6", "7",
818 "8", "9", "10", "11", "12", "13", "14", "15",
819 "16", "17", "18", "19", "20", "21", "22", "23",
820 "24", "25", "26", "27", "28", "29", "30", "31",
821 "0", "1", "2", "3", "4", "5", "6", "7",
822 "8", "9", "10", "11", "12", "13", "14", "15",
823 "16", "17", "18", "19", "20", "21", "22", "23",
824 "24", "25", "26", "27", "28", "29", "30", "31",
825 "mq", "lr", "ctr","ap",
826 "0", "1", "2", "3", "4", "5", "6", "7",
828 /* AltiVec registers. */
829 "0", "1", "2", "3", "4", "5", "6", "7",
830 "8", "9", "10", "11", "12", "13", "14", "15",
831 "16", "17", "18", "19", "20", "21", "22", "23",
832 "24", "25", "26", "27", "28", "29", "30", "31",
835 "spe_acc", "spefscr",
836 /* Soft frame pointer. */
840 #ifdef TARGET_REGNAMES
841 static const char alt_reg_names[][8] =
843 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
844 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
845 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
846 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
847 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
848 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
849 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
850 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
851 "mq", "lr", "ctr", "ap",
852 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
854 /* AltiVec registers. */
855 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
856 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
857 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
858 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
861 "spe_acc", "spefscr",
862 /* Soft frame pointer. */
867 #ifndef MASK_STRICT_ALIGN
868 #define MASK_STRICT_ALIGN 0
870 #ifndef TARGET_PROFILE_KERNEL
871 #define TARGET_PROFILE_KERNEL 0
874 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
875 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
877 /* Initialize the GCC target structure. */
878 #undef TARGET_ATTRIBUTE_TABLE
879 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
880 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
881 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
883 #undef TARGET_ASM_ALIGNED_DI_OP
884 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
886 /* Default unaligned ops are only provided for ELF. Find the ops needed
887 for non-ELF systems. */
888 #ifndef OBJECT_FORMAT_ELF
890 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
892 #undef TARGET_ASM_UNALIGNED_HI_OP
893 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
894 #undef TARGET_ASM_UNALIGNED_SI_OP
895 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
896 #undef TARGET_ASM_UNALIGNED_DI_OP
897 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
900 #undef TARGET_ASM_UNALIGNED_HI_OP
901 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
902 #undef TARGET_ASM_UNALIGNED_SI_OP
903 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
904 #undef TARGET_ASM_UNALIGNED_DI_OP
905 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
906 #undef TARGET_ASM_ALIGNED_DI_OP
907 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
911 /* This hook deals with fixups for relocatable code and DI-mode objects
913 #undef TARGET_ASM_INTEGER
914 #define TARGET_ASM_INTEGER rs6000_assemble_integer
916 #ifdef HAVE_GAS_HIDDEN
917 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
918 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
921 #undef TARGET_HAVE_TLS
922 #define TARGET_HAVE_TLS HAVE_AS_TLS
924 #undef TARGET_CANNOT_FORCE_CONST_MEM
925 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
927 #undef TARGET_ASM_FUNCTION_PROLOGUE
928 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
929 #undef TARGET_ASM_FUNCTION_EPILOGUE
930 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
932 #undef TARGET_SCHED_VARIABLE_ISSUE
933 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
935 #undef TARGET_SCHED_ISSUE_RATE
936 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
937 #undef TARGET_SCHED_ADJUST_COST
938 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
939 #undef TARGET_SCHED_ADJUST_PRIORITY
940 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
941 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
942 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
943 #undef TARGET_SCHED_INIT
944 #define TARGET_SCHED_INIT rs6000_sched_init
945 #undef TARGET_SCHED_FINISH
946 #define TARGET_SCHED_FINISH rs6000_sched_finish
947 #undef TARGET_SCHED_REORDER
948 #define TARGET_SCHED_REORDER rs6000_sched_reorder
949 #undef TARGET_SCHED_REORDER2
950 #define TARGET_SCHED_REORDER2 rs6000_sched_reorder2
952 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
953 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
955 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
956 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
957 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
958 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN rs6000_builtin_mul_widen_even
959 #undef TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
960 #define TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD rs6000_builtin_mul_widen_odd
962 #undef TARGET_INIT_BUILTINS
963 #define TARGET_INIT_BUILTINS rs6000_init_builtins
965 #undef TARGET_EXPAND_BUILTIN
966 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
968 #undef TARGET_MANGLE_FUNDAMENTAL_TYPE
969 #define TARGET_MANGLE_FUNDAMENTAL_TYPE rs6000_mangle_fundamental_type
971 #undef TARGET_INIT_LIBFUNCS
972 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
975 #undef TARGET_BINDS_LOCAL_P
976 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
979 #undef TARGET_MS_BITFIELD_LAYOUT_P
980 #define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p
982 #undef TARGET_ASM_OUTPUT_MI_THUNK
983 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
985 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
986 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
988 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
989 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
991 #undef TARGET_INVALID_WITHIN_DOLOOP
992 #define TARGET_INVALID_WITHIN_DOLOOP rs6000_invalid_within_doloop
994 #undef TARGET_RTX_COSTS
995 #define TARGET_RTX_COSTS rs6000_rtx_costs
996 #undef TARGET_ADDRESS_COST
997 #define TARGET_ADDRESS_COST hook_int_rtx_0
999 #undef TARGET_VECTOR_OPAQUE_P
1000 #define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
1002 #undef TARGET_DWARF_REGISTER_SPAN
1003 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
1005 /* On rs6000, function arguments are promoted, as are function return
1007 #undef TARGET_PROMOTE_FUNCTION_ARGS
1008 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
1009 #undef TARGET_PROMOTE_FUNCTION_RETURN
1010 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
1012 #undef TARGET_RETURN_IN_MEMORY
1013 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
1015 #undef TARGET_SETUP_INCOMING_VARARGS
1016 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
1018 /* Always strict argument naming on rs6000. */
1019 #undef TARGET_STRICT_ARGUMENT_NAMING
1020 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
1021 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
1022 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
1023 #undef TARGET_SPLIT_COMPLEX_ARG
1024 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_tree_true
1025 #undef TARGET_MUST_PASS_IN_STACK
1026 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
1027 #undef TARGET_PASS_BY_REFERENCE
1028 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
1029 #undef TARGET_ARG_PARTIAL_BYTES
1030 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
1032 #undef TARGET_BUILD_BUILTIN_VA_LIST
1033 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
1035 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1036 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1038 #undef TARGET_EH_RETURN_FILTER_MODE
1039 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1041 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1042 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1044 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1045 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1047 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1048 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1050 #undef TARGET_HANDLE_OPTION
1051 #define TARGET_HANDLE_OPTION rs6000_handle_option
1053 #undef TARGET_DEFAULT_TARGET_FLAGS
1054 #define TARGET_DEFAULT_TARGET_FLAGS \
1057 #undef TARGET_STACK_PROTECT_FAIL
1058 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
1060 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1061 The PowerPC architecture requires only weak consistency among
1062 processors--that is, memory accesses between processors need not be
1063 sequentially consistent and memory accesses among processors can occur
1064 in any order. The ability to order memory accesses weakly provides
1065 opportunities for more efficient use of the system bus. Unless a
1066 dependency exists, the 604e allows read operations to precede store
1068 #undef TARGET_RELAXED_ORDERING
1069 #define TARGET_RELAXED_ORDERING true
1072 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
1073 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
1076 /* Use a 32-bit anchor range. This leads to sequences like:
1078 addis tmp,anchor,high
1081 where tmp itself acts as an anchor, and can be shared between
1082 accesses to the same 64k page. */
1083 #undef TARGET_MIN_ANCHOR_OFFSET
1084 #define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1
1085 #undef TARGET_MAX_ANCHOR_OFFSET
1086 #define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff
1087 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
1088 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p
1090 struct gcc_target targetm = TARGET_INITIALIZER;
1093 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1096 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1098 /* The GPRs can hold any mode, but values bigger than one register
1099 cannot go past R31. */
1100 if (INT_REGNO_P (regno))
1101 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1103 /* The float registers can only hold floating modes and DImode.
1104 This also excludes decimal float modes. */
1105 if (FP_REGNO_P (regno))
1107 (SCALAR_FLOAT_MODE_P (mode)
1108 && !DECIMAL_FLOAT_MODE_P (mode)
1109 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1110 || (GET_MODE_CLASS (mode) == MODE_INT
1111 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD);
1113 /* The CR register can only hold CC modes. */
1114 if (CR_REGNO_P (regno))
1115 return GET_MODE_CLASS (mode) == MODE_CC;
1117 if (XER_REGNO_P (regno))
1118 return mode == PSImode;
1120 /* AltiVec only in AldyVec registers. */
1121 if (ALTIVEC_REGNO_P (regno))
1122 return ALTIVEC_VECTOR_MODE (mode);
1124 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1125 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1128 /* We cannot put TImode anywhere except general register and it must be
1129 able to fit within the register set. */
1131 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1134 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1136 rs6000_init_hard_regno_mode_ok (void)
1140 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1141 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1142 if (rs6000_hard_regno_mode_ok (r, m))
1143 rs6000_hard_regno_mode_ok_p[m][r] = true;
1146 /* If not otherwise specified by a target, make 'long double' equivalent to
1149 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1150 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1153 /* Override command line options. Mostly we process the processor
1154 type and sometimes adjust other TARGET_ options. */
1157 rs6000_override_options (const char *default_cpu)
1160 struct rs6000_cpu_select *ptr;
1163 /* Simplifications for entries below. */
1166 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1167 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1170 /* This table occasionally claims that a processor does not support
1171 a particular feature even though it does, but the feature is slower
1172 than the alternative. Thus, it shouldn't be relied on as a
1173 complete description of the processor's support.
1175 Please keep this list in order, and don't forget to update the
1176 documentation in invoke.texi when adding a new processor or
1180 const char *const name; /* Canonical processor name. */
1181 const enum processor_type processor; /* Processor type enum value. */
1182 const int target_enable; /* Target flags to enable. */
1183 } const processor_target_table[]
1184 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1185 {"403", PROCESSOR_PPC403,
1186 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1187 {"405", PROCESSOR_PPC405,
1188 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1189 {"405fp", PROCESSOR_PPC405,
1190 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1191 {"440", PROCESSOR_PPC440,
1192 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB},
1193 {"440fp", PROCESSOR_PPC440,
1194 POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB},
1195 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1196 {"601", PROCESSOR_PPC601,
1197 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1198 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1199 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1200 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1201 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1202 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1203 {"620", PROCESSOR_PPC620,
1204 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1205 {"630", PROCESSOR_PPC630,
1206 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1207 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1208 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1209 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1210 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1211 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1212 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1213 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1214 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1215 /* 8548 has a dummy entry for now. */
1216 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1217 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1218 {"970", PROCESSOR_POWER4,
1219 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1220 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1221 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1222 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1223 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1224 {"G5", PROCESSOR_POWER4,
1225 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1226 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1227 {"power2", PROCESSOR_POWER,
1228 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1229 {"power3", PROCESSOR_PPC630,
1230 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1231 {"power4", PROCESSOR_POWER4,
1232 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1233 {"power5", PROCESSOR_POWER5,
1234 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1235 | MASK_MFCRF | MASK_POPCNTB},
1236 {"power5+", PROCESSOR_POWER5,
1237 POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
1238 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND},
1239 {"power6", PROCESSOR_POWER6,
1240 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1242 {"power6x", PROCESSOR_POWER6,
1243 POWERPC_7400_MASK | MASK_POWERPC64 | MASK_MFCRF | MASK_POPCNTB
1244 | MASK_FPRND | MASK_MFPGPR},
1245 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1246 {"powerpc64", PROCESSOR_POWERPC64,
1247 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1248 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1249 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1250 {"rios2", PROCESSOR_RIOS2,
1251 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1252 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1253 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1254 {"rs64", PROCESSOR_RS64A,
1255 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}
1258 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1260 /* Some OSs don't support saving the high part of 64-bit registers on
1261 context switch. Other OSs don't support saving Altivec registers.
1262 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1263 settings; if the user wants either, the user must explicitly specify
1264 them and we won't interfere with the user's specification. */
1267 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1268 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT
1269 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1270 | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_MULHW
1271 | MASK_DLMZB | MASK_MFPGPR)
1274 rs6000_init_hard_regno_mode_ok ();
1276 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1277 #ifdef OS_MISSING_POWERPC64
1278 if (OS_MISSING_POWERPC64)
1279 set_masks &= ~MASK_POWERPC64;
1281 #ifdef OS_MISSING_ALTIVEC
1282 if (OS_MISSING_ALTIVEC)
1283 set_masks &= ~MASK_ALTIVEC;
1286 /* Don't override by the processor default if given explicitly. */
1287 set_masks &= ~target_flags_explicit;
1289 /* Identify the processor type. */
1290 rs6000_select[0].string = default_cpu;
1291 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1293 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1295 ptr = &rs6000_select[i];
1296 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1298 for (j = 0; j < ptt_size; j++)
1299 if (! strcmp (ptr->string, processor_target_table[j].name))
1301 if (ptr->set_tune_p)
1302 rs6000_cpu = processor_target_table[j].processor;
1304 if (ptr->set_arch_p)
1306 target_flags &= ~set_masks;
1307 target_flags |= (processor_target_table[j].target_enable
1314 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1321 /* If we are optimizing big endian systems for space, use the load/store
1322 multiple and string instructions. */
1323 if (BYTES_BIG_ENDIAN && optimize_size)
1324 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1326 /* Don't allow -mmultiple or -mstring on little endian systems
1327 unless the cpu is a 750, because the hardware doesn't support the
1328 instructions used in little endian mode, and causes an alignment
1329 trap. The 750 does not cause an alignment trap (except when the
1330 target is unaligned). */
1332 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1334 if (TARGET_MULTIPLE)
1336 target_flags &= ~MASK_MULTIPLE;
1337 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1338 warning (0, "-mmultiple is not supported on little endian systems");
1343 target_flags &= ~MASK_STRING;
1344 if ((target_flags_explicit & MASK_STRING) != 0)
1345 warning (0, "-mstring is not supported on little endian systems");
1349 /* Set debug flags */
1350 if (rs6000_debug_name)
1352 if (! strcmp (rs6000_debug_name, "all"))
1353 rs6000_debug_stack = rs6000_debug_arg = 1;
1354 else if (! strcmp (rs6000_debug_name, "stack"))
1355 rs6000_debug_stack = 1;
1356 else if (! strcmp (rs6000_debug_name, "arg"))
1357 rs6000_debug_arg = 1;
1359 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1362 if (rs6000_traceback_name)
1364 if (! strncmp (rs6000_traceback_name, "full", 4))
1365 rs6000_traceback = traceback_full;
1366 else if (! strncmp (rs6000_traceback_name, "part", 4))
1367 rs6000_traceback = traceback_part;
1368 else if (! strncmp (rs6000_traceback_name, "no", 2))
1369 rs6000_traceback = traceback_none;
1371 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1372 rs6000_traceback_name);
1375 if (!rs6000_explicit_options.long_double)
1376 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1378 #ifndef POWERPC_LINUX
1379 if (!rs6000_explicit_options.ieee)
1380 rs6000_ieeequad = 1;
1383 /* Set Altivec ABI as default for powerpc64 linux. */
1384 if (TARGET_ELF && TARGET_64BIT)
1386 rs6000_altivec_abi = 1;
1387 TARGET_ALTIVEC_VRSAVE = 1;
1390 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1391 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1393 rs6000_darwin64_abi = 1;
1395 darwin_one_byte_bool = 1;
1397 /* Default to natural alignment, for better performance. */
1398 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1401 /* Place FP constants in the constant pool instead of TOC
1402 if section anchors enabled. */
1403 if (flag_section_anchors)
1404 TARGET_NO_FP_IN_TOC = 1;
1406 /* Handle -mtls-size option. */
1407 rs6000_parse_tls_size_option ();
1409 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1410 SUBTARGET_OVERRIDE_OPTIONS;
1412 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1413 SUBSUBTARGET_OVERRIDE_OPTIONS;
1415 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1416 SUB3TARGET_OVERRIDE_OPTIONS;
1422 error ("AltiVec and E500 instructions cannot coexist");
1424 /* The e500 does not have string instructions, and we set
1425 MASK_STRING above when optimizing for size. */
1426 if ((target_flags & MASK_STRING) != 0)
1427 target_flags = target_flags & ~MASK_STRING;
1429 else if (rs6000_select[1].string != NULL)
1431 /* For the powerpc-eabispe configuration, we set all these by
1432 default, so let's unset them if we manually set another
1433 CPU that is not the E500. */
1434 if (!rs6000_explicit_options.abi)
1436 if (!rs6000_explicit_options.spe)
1438 if (!rs6000_explicit_options.float_gprs)
1439 rs6000_float_gprs = 0;
1440 if (!rs6000_explicit_options.isel)
1442 if (!rs6000_explicit_options.long_double)
1443 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1446 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1447 && rs6000_cpu != PROCESSOR_POWER5
1448 && rs6000_cpu != PROCESSOR_POWER6);
1449 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1450 || rs6000_cpu == PROCESSOR_POWER5);
1451 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
1452 || rs6000_cpu == PROCESSOR_POWER5
1453 || rs6000_cpu == PROCESSOR_POWER6);
1455 rs6000_sched_restricted_insns_priority
1456 = (rs6000_sched_groups ? 1 : 0);
1458 /* Handle -msched-costly-dep option. */
1459 rs6000_sched_costly_dep
1460 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1462 if (rs6000_sched_costly_dep_str)
1464 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1465 rs6000_sched_costly_dep = no_dep_costly;
1466 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1467 rs6000_sched_costly_dep = all_deps_costly;
1468 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1469 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1470 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1471 rs6000_sched_costly_dep = store_to_load_dep_costly;
1473 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1476 /* Handle -minsert-sched-nops option. */
1477 rs6000_sched_insert_nops
1478 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1480 if (rs6000_sched_insert_nops_str)
1482 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1483 rs6000_sched_insert_nops = sched_finish_none;
1484 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1485 rs6000_sched_insert_nops = sched_finish_pad_groups;
1486 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1487 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1489 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1492 #ifdef TARGET_REGNAMES
1493 /* If the user desires alternate register names, copy in the
1494 alternate names now. */
1495 if (TARGET_REGNAMES)
1496 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1499 /* Set aix_struct_return last, after the ABI is determined.
1500 If -maix-struct-return or -msvr4-struct-return was explicitly
1501 used, don't override with the ABI default. */
1502 if (!rs6000_explicit_options.aix_struct_ret)
1503 aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
1505 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
1506 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1509 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1511 /* We can only guarantee the availability of DI pseudo-ops when
1512 assembling for 64-bit targets. */
1515 targetm.asm_out.aligned_op.di = NULL;
1516 targetm.asm_out.unaligned_op.di = NULL;
1519 /* Set branch target alignment, if not optimizing for size. */
1522 if (rs6000_align_branch_targets)
1524 if (align_functions <= 0)
1525 align_functions = 16;
1526 if (align_jumps <= 0)
1528 if (align_loops <= 0)
1531 if (align_jumps_max_skip <= 0)
1532 align_jumps_max_skip = 15;
1533 if (align_loops_max_skip <= 0)
1534 align_loops_max_skip = 15;
1537 /* Arrange to save and restore machine status around nested functions. */
1538 init_machine_status = rs6000_init_machine_status;
1540 /* We should always be splitting complex arguments, but we can't break
1541 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1542 if (DEFAULT_ABI != ABI_AIX)
1543 targetm.calls.split_complex_arg = NULL;
1545 /* Initialize rs6000_cost with the appropriate target costs. */
1547 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1551 case PROCESSOR_RIOS1:
1552 rs6000_cost = &rios1_cost;
1555 case PROCESSOR_RIOS2:
1556 rs6000_cost = &rios2_cost;
1559 case PROCESSOR_RS64A:
1560 rs6000_cost = &rs64a_cost;
1563 case PROCESSOR_MPCCORE:
1564 rs6000_cost = &mpccore_cost;
1567 case PROCESSOR_PPC403:
1568 rs6000_cost = &ppc403_cost;
1571 case PROCESSOR_PPC405:
1572 rs6000_cost = &ppc405_cost;
1575 case PROCESSOR_PPC440:
1576 rs6000_cost = &ppc440_cost;
1579 case PROCESSOR_PPC601:
1580 rs6000_cost = &ppc601_cost;
1583 case PROCESSOR_PPC603:
1584 rs6000_cost = &ppc603_cost;
1587 case PROCESSOR_PPC604:
1588 rs6000_cost = &ppc604_cost;
1591 case PROCESSOR_PPC604e:
1592 rs6000_cost = &ppc604e_cost;
1595 case PROCESSOR_PPC620:
1596 rs6000_cost = &ppc620_cost;
1599 case PROCESSOR_PPC630:
1600 rs6000_cost = &ppc630_cost;
1603 case PROCESSOR_PPC750:
1604 case PROCESSOR_PPC7400:
1605 rs6000_cost = &ppc750_cost;
1608 case PROCESSOR_PPC7450:
1609 rs6000_cost = &ppc7450_cost;
1612 case PROCESSOR_PPC8540:
1613 rs6000_cost = &ppc8540_cost;
1616 case PROCESSOR_POWER4:
1617 case PROCESSOR_POWER5:
1618 rs6000_cost = &power4_cost;
1621 case PROCESSOR_POWER6:
1622 rs6000_cost = &power6_cost;
1630 /* Implement targetm.vectorize.builtin_mask_for_load. */
1632 rs6000_builtin_mask_for_load (void)
1635 return altivec_builtin_mask_for_load;
1640 /* Implement targetm.vectorize.builtin_mul_widen_even. */
1642 rs6000_builtin_mul_widen_even (tree type)
1644 if (!TARGET_ALTIVEC)
1647 switch (TYPE_MODE (type))
1650 return TYPE_UNSIGNED (type) ?
1651 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUH] :
1652 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESH];
1655 return TYPE_UNSIGNED (type) ?
1656 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULEUB] :
1657 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULESB];
1663 /* Implement targetm.vectorize.builtin_mul_widen_odd. */
1665 rs6000_builtin_mul_widen_odd (tree type)
1667 if (!TARGET_ALTIVEC)
1670 switch (TYPE_MODE (type))
1673 return TYPE_UNSIGNED (type) ?
1674 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUH] :
1675 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSH];
1678 return TYPE_UNSIGNED (type) ?
1679 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOUB] :
1680 rs6000_builtin_decls[ALTIVEC_BUILTIN_VMULOSB];
1686 /* Handle generic options of the form -mfoo=yes/no.
1687 NAME is the option name.
1688 VALUE is the option value.
1689 FLAG is the pointer to the flag where to store a 1 or 0, depending on
1690 whether the option value is 'yes' or 'no' respectively. */
1692 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
1696 else if (!strcmp (value, "yes"))
1698 else if (!strcmp (value, "no"))
1701 error ("unknown -m%s= option specified: '%s'", name, value);
1704 /* Validate and record the size specified with the -mtls-size option. */
1707 rs6000_parse_tls_size_option (void)
1709 if (rs6000_tls_size_string == 0)
1711 else if (strcmp (rs6000_tls_size_string, "16") == 0)
1712 rs6000_tls_size = 16;
1713 else if (strcmp (rs6000_tls_size_string, "32") == 0)
1714 rs6000_tls_size = 32;
1715 else if (strcmp (rs6000_tls_size_string, "64") == 0)
1716 rs6000_tls_size = 64;
1718 error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
1722 optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
1724 if (DEFAULT_ABI == ABI_DARWIN)
1725 /* The Darwin libraries never set errno, so we might as well
1726 avoid calling them when that's the only reason we would. */
1727 flag_errno_math = 0;
1729 /* Double growth factor to counter reduced min jump length. */
1730 set_param_value ("max-grow-copy-bb-insns", 16);
1732 /* Enable section anchors by default.
1733 Skip section anchors for Objective C and Objective C++
1734 until front-ends fixed. */
1735 if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
1736 flag_section_anchors = 1;
1739 /* Implement TARGET_HANDLE_OPTION. */
1742 rs6000_handle_option (size_t code, const char *arg, int value)
1747 target_flags &= ~(MASK_POWER | MASK_POWER2
1748 | MASK_MULTIPLE | MASK_STRING);
1749 target_flags_explicit |= (MASK_POWER | MASK_POWER2
1750 | MASK_MULTIPLE | MASK_STRING);
1752 case OPT_mno_powerpc:
1753 target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
1754 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1755 target_flags_explicit |= (MASK_POWERPC | MASK_PPC_GPOPT
1756 | MASK_PPC_GFXOPT | MASK_POWERPC64);
1759 target_flags &= ~MASK_MINIMAL_TOC;
1760 TARGET_NO_FP_IN_TOC = 0;
1761 TARGET_NO_SUM_IN_TOC = 0;
1762 target_flags_explicit |= MASK_MINIMAL_TOC;
1763 #ifdef TARGET_USES_SYSV4_OPT
1764 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
1765 just the same as -mminimal-toc. */
1766 target_flags |= MASK_MINIMAL_TOC;
1767 target_flags_explicit |= MASK_MINIMAL_TOC;
1771 #ifdef TARGET_USES_SYSV4_OPT
1773 /* Make -mtoc behave like -mminimal-toc. */
1774 target_flags |= MASK_MINIMAL_TOC;
1775 target_flags_explicit |= MASK_MINIMAL_TOC;
1779 #ifdef TARGET_USES_AIX64_OPT
1784 target_flags |= MASK_POWERPC64 | MASK_POWERPC;
1785 target_flags |= ~target_flags_explicit & MASK_PPC_GFXOPT;
1786 target_flags_explicit |= MASK_POWERPC64 | MASK_POWERPC;
1789 #ifdef TARGET_USES_AIX64_OPT
1794 target_flags &= ~MASK_POWERPC64;
1795 target_flags_explicit |= MASK_POWERPC64;
1798 case OPT_minsert_sched_nops_:
1799 rs6000_sched_insert_nops_str = arg;
1802 case OPT_mminimal_toc:
1805 TARGET_NO_FP_IN_TOC = 0;
1806 TARGET_NO_SUM_IN_TOC = 0;
1813 target_flags |= (MASK_MULTIPLE | MASK_STRING);
1814 target_flags_explicit |= (MASK_MULTIPLE | MASK_STRING);
1821 target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1822 target_flags_explicit |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
1826 case OPT_mpowerpc_gpopt:
1827 case OPT_mpowerpc_gfxopt:
1830 target_flags |= MASK_POWERPC;
1831 target_flags_explicit |= MASK_POWERPC;
1835 case OPT_maix_struct_return:
1836 case OPT_msvr4_struct_return:
1837 rs6000_explicit_options.aix_struct_ret = true;
1841 rs6000_parse_yes_no_option ("vrsave", arg, &(TARGET_ALTIVEC_VRSAVE));
1845 rs6000_explicit_options.isel = true;
1846 rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
1850 rs6000_explicit_options.spe = true;
1851 rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
1852 /* No SPE means 64-bit long doubles, even if an E500. */
1854 rs6000_long_double_type_size = 64;
1858 rs6000_debug_name = arg;
1861 #ifdef TARGET_USES_SYSV4_OPT
1863 rs6000_abi_name = arg;
1867 rs6000_sdata_name = arg;
1870 case OPT_mtls_size_:
1871 rs6000_tls_size_string = arg;
1874 case OPT_mrelocatable:
1877 target_flags |= MASK_MINIMAL_TOC;
1878 target_flags_explicit |= MASK_MINIMAL_TOC;
1879 TARGET_NO_FP_IN_TOC = 1;
1883 case OPT_mrelocatable_lib:
1886 target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
1887 target_flags_explicit |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
1888 TARGET_NO_FP_IN_TOC = 1;
1892 target_flags &= ~MASK_RELOCATABLE;
1893 target_flags_explicit |= MASK_RELOCATABLE;
1899 if (!strcmp (arg, "altivec"))
1901 rs6000_explicit_options.abi = true;
1902 rs6000_altivec_abi = 1;
1905 else if (! strcmp (arg, "no-altivec"))
1907 /* ??? Don't set rs6000_explicit_options.abi here, to allow
1908 the default for rs6000_spe_abi to be chosen later. */
1909 rs6000_altivec_abi = 0;
1911 else if (! strcmp (arg, "spe"))
1913 rs6000_explicit_options.abi = true;
1915 rs6000_altivec_abi = 0;
1916 if (!TARGET_SPE_ABI)
1917 error ("not configured for ABI: '%s'", arg);
1919 else if (! strcmp (arg, "no-spe"))
1921 rs6000_explicit_options.abi = true;
1925 /* These are here for testing during development only, do not
1926 document in the manual please. */
1927 else if (! strcmp (arg, "d64"))
1929 rs6000_darwin64_abi = 1;
1930 warning (0, "Using darwin64 ABI");
1932 else if (! strcmp (arg, "d32"))
1934 rs6000_darwin64_abi = 0;
1935 warning (0, "Using old darwin ABI");
1938 else if (! strcmp (arg, "ibmlongdouble"))
1940 rs6000_explicit_options.ieee = true;
1941 rs6000_ieeequad = 0;
1942 warning (0, "Using IBM extended precision long double");
1944 else if (! strcmp (arg, "ieeelongdouble"))
1946 rs6000_explicit_options.ieee = true;
1947 rs6000_ieeequad = 1;
1948 warning (0, "Using IEEE extended precision long double");
1953 error ("unknown ABI specified: '%s'", arg);
1959 rs6000_select[1].string = arg;
1963 rs6000_select[2].string = arg;
1966 case OPT_mtraceback_:
1967 rs6000_traceback_name = arg;
1970 case OPT_mfloat_gprs_:
1971 rs6000_explicit_options.float_gprs = true;
1972 if (! strcmp (arg, "yes") || ! strcmp (arg, "single"))
1973 rs6000_float_gprs = 1;
1974 else if (! strcmp (arg, "double"))
1975 rs6000_float_gprs = 2;
1976 else if (! strcmp (arg, "no"))
1977 rs6000_float_gprs = 0;
1980 error ("invalid option for -mfloat-gprs: '%s'", arg);
1985 case OPT_mlong_double_:
1986 rs6000_explicit_options.long_double = true;
1987 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1988 if (value != 64 && value != 128)
1990 error ("Unknown switch -mlong-double-%s", arg);
1991 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1995 rs6000_long_double_type_size = value;
1998 case OPT_msched_costly_dep_:
1999 rs6000_sched_costly_dep_str = arg;
2003 rs6000_explicit_options.alignment = true;
2004 if (! strcmp (arg, "power"))
2006 /* On 64-bit Darwin, power alignment is ABI-incompatible with
2007 some C library functions, so warn about it. The flag may be
2008 useful for performance studies from time to time though, so
2009 don't disable it entirely. */
2010 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
2011 warning (0, "-malign-power is not supported for 64-bit Darwin;"
2012 " it is incompatible with the installed C and C++ libraries");
2013 rs6000_alignment_flags = MASK_ALIGN_POWER;
2015 else if (! strcmp (arg, "natural"))
2016 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
2019 error ("unknown -malign-XXXXX option specified: '%s'", arg);
2027 /* Do anything needed at the start of the asm file. */
2030 rs6000_file_start (void)
2034 const char *start = buffer;
2035 struct rs6000_cpu_select *ptr;
2036 const char *default_cpu = TARGET_CPU_DEFAULT;
2037 FILE *file = asm_out_file;
2039 default_file_start ();
2041 #ifdef TARGET_BI_ARCH
2042 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
2046 if (flag_verbose_asm)
2048 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
2049 rs6000_select[0].string = default_cpu;
2051 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
2053 ptr = &rs6000_select[i];
2054 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
2056 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
2061 if (PPC405_ERRATUM77)
2063 fprintf (file, "%s PPC405CR_ERRATUM77", start);
2067 #ifdef USING_ELFOS_H
2068 switch (rs6000_sdata)
2070 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
2071 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
2072 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
2073 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
2076 if (rs6000_sdata && g_switch_value)
2078 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
2088 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
2090 switch_to_section (toc_section);
2091 switch_to_section (text_section);
2096 /* Return nonzero if this function is known to have a null epilogue. */
2099 direct_return (void)
2101 if (reload_completed)
2103 rs6000_stack_t *info = rs6000_stack_info ();
2105 if (info->first_gp_reg_save == 32
2106 && info->first_fp_reg_save == 64
2107 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
2108 && ! info->lr_save_p
2109 && ! info->cr_save_p
2110 && info->vrsave_mask == 0
2118 /* Return the number of instructions it takes to form a constant in an
2119 integer register. */
2122 num_insns_constant_wide (HOST_WIDE_INT value)
2124 /* signed constant loadable with {cal|addi} */
2125 if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000)
2128 /* constant loadable with {cau|addis} */
2129 else if ((value & 0xffff) == 0
2130 && (value >> 31 == -1 || value >> 31 == 0))
2133 #if HOST_BITS_PER_WIDE_INT == 64
2134 else if (TARGET_POWERPC64)
2136 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
2137 HOST_WIDE_INT high = value >> 31;
2139 if (high == 0 || high == -1)
2145 return num_insns_constant_wide (high) + 1;
2147 return (num_insns_constant_wide (high)
2148 + num_insns_constant_wide (low) + 1);
2157 num_insns_constant (rtx op, enum machine_mode mode)
2159 HOST_WIDE_INT low, high;
2161 switch (GET_CODE (op))
2164 #if HOST_BITS_PER_WIDE_INT == 64
2165 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
2166 && mask64_operand (op, mode))
2170 return num_insns_constant_wide (INTVAL (op));
2178 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2179 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
2180 return num_insns_constant_wide ((HOST_WIDE_INT) l);
2183 if (mode == VOIDmode || mode == DImode)
2185 high = CONST_DOUBLE_HIGH (op);
2186 low = CONST_DOUBLE_LOW (op);
2193 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
2194 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
2195 high = l[WORDS_BIG_ENDIAN == 0];
2196 low = l[WORDS_BIG_ENDIAN != 0];
2200 return (num_insns_constant_wide (low)
2201 + num_insns_constant_wide (high));
2204 if ((high == 0 && low >= 0)
2205 || (high == -1 && low < 0))
2206 return num_insns_constant_wide (low);
2208 else if (mask64_operand (op, mode))
2212 return num_insns_constant_wide (high) + 1;
2215 return (num_insns_constant_wide (high)
2216 + num_insns_constant_wide (low) + 1);
2224 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
2225 If the mode of OP is MODE_VECTOR_INT, this simply returns the
2226 corresponding element of the vector, but for V4SFmode and V2SFmode,
2227 the corresponding "float" is interpreted as an SImode integer. */
2229 static HOST_WIDE_INT
2230 const_vector_elt_as_int (rtx op, unsigned int elt)
2232 rtx tmp = CONST_VECTOR_ELT (op, elt);
2233 if (GET_MODE (op) == V4SFmode
2234 || GET_MODE (op) == V2SFmode)
2235 tmp = gen_lowpart (SImode, tmp);
2236 return INTVAL (tmp);
2239 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
2240 or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used
2241 depends on STEP and COPIES, one of which will be 1. If COPIES > 1,
2242 all items are set to the same value and contain COPIES replicas of the
2243 vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's
2244 operand and the others are set to the value of the operand's msb. */
2247 vspltis_constant (rtx op, unsigned step, unsigned copies)
2249 enum machine_mode mode = GET_MODE (op);
2250 enum machine_mode inner = GET_MODE_INNER (mode);
2253 unsigned nunits = GET_MODE_NUNITS (mode);
2254 unsigned bitsize = GET_MODE_BITSIZE (inner);
2255 unsigned mask = GET_MODE_MASK (inner);
2257 HOST_WIDE_INT val = const_vector_elt_as_int (op, nunits - 1);
2258 HOST_WIDE_INT splat_val = val;
2259 HOST_WIDE_INT msb_val = val > 0 ? 0 : -1;
2261 /* Construct the value to be splatted, if possible. If not, return 0. */
2262 for (i = 2; i <= copies; i *= 2)
2264 HOST_WIDE_INT small_val;
2266 small_val = splat_val >> bitsize;
2268 if (splat_val != ((small_val << bitsize) | (small_val & mask)))
2270 splat_val = small_val;
2273 /* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */
2274 if (EASY_VECTOR_15 (splat_val))
2277 /* Also check if we can splat, and then add the result to itself. Do so if
2278 the value is positive, of if the splat instruction is using OP's mode;
2279 for splat_val < 0, the splat and the add should use the same mode. */
2280 else if (EASY_VECTOR_15_ADD_SELF (splat_val)
2281 && (splat_val >= 0 || (step == 1 && copies == 1)))
2287 /* Check if VAL is present in every STEP-th element, and the
2288 other elements are filled with its most significant bit. */
2289 for (i = 0; i < nunits - 1; ++i)
2291 HOST_WIDE_INT desired_val;
2292 if (((i + 1) & (step - 1)) == 0)
2295 desired_val = msb_val;
2297 if (desired_val != const_vector_elt_as_int (op, i))
2305 /* Return true if OP is of the given MODE and can be synthesized
2306 with a vspltisb, vspltish or vspltisw. */
2309 easy_altivec_constant (rtx op, enum machine_mode mode)
2311 unsigned step, copies;
2313 if (mode == VOIDmode)
2314 mode = GET_MODE (op);
2315 else if (mode != GET_MODE (op))
2318 /* Start with a vspltisw. */
2319 step = GET_MODE_NUNITS (mode) / 4;
2322 if (vspltis_constant (op, step, copies))
2325 /* Then try with a vspltish. */
2331 if (vspltis_constant (op, step, copies))
2334 /* And finally a vspltisb. */
2340 if (vspltis_constant (op, step, copies))
2346 /* Generate a VEC_DUPLICATE representing a vspltis[bhw] instruction whose
2347 result is OP. Abort if it is not possible. */
2350 gen_easy_altivec_constant (rtx op)
2352 enum machine_mode mode = GET_MODE (op);
2353 int nunits = GET_MODE_NUNITS (mode);
2354 rtx last = CONST_VECTOR_ELT (op, nunits - 1);
2355 unsigned step = nunits / 4;
2356 unsigned copies = 1;
2358 /* Start with a vspltisw. */
2359 if (vspltis_constant (op, step, copies))
2360 return gen_rtx_VEC_DUPLICATE (V4SImode, gen_lowpart (SImode, last));
2362 /* Then try with a vspltish. */
2368 if (vspltis_constant (op, step, copies))
2369 return gen_rtx_VEC_DUPLICATE (V8HImode, gen_lowpart (HImode, last));
2371 /* And finally a vspltisb. */
2377 if (vspltis_constant (op, step, copies))
2378 return gen_rtx_VEC_DUPLICATE (V16QImode, gen_lowpart (QImode, last));
2384 output_vec_const_move (rtx *operands)
2387 enum machine_mode mode;
2392 mode = GET_MODE (dest);
2397 if (zero_constant (vec, mode))
2398 return "vxor %0,%0,%0";
2400 splat_vec = gen_easy_altivec_constant (vec);
2401 gcc_assert (GET_CODE (splat_vec) == VEC_DUPLICATE);
2402 operands[1] = XEXP (splat_vec, 0);
2403 if (!EASY_VECTOR_15 (INTVAL (operands[1])))
2406 switch (GET_MODE (splat_vec))
2409 return "vspltisw %0,%1";
2412 return "vspltish %0,%1";
2415 return "vspltisb %0,%1";
2422 gcc_assert (TARGET_SPE);
2424 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2425 pattern of V1DI, V4HI, and V2SF.
2427 FIXME: We should probably return # and add post reload
2428 splitters for these, but this way is so easy ;-). */
2429 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2430 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
2431 operands[1] = CONST_VECTOR_ELT (vec, 0);
2432 operands[2] = CONST_VECTOR_ELT (vec, 1);
2434 return "li %0,%1\n\tevmergelo %0,%0,%0";
2436 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
2439 /* Initialize vector TARGET to VALS. */
2442 rs6000_expand_vector_init (rtx target, rtx vals)
2444 enum machine_mode mode = GET_MODE (target);
2445 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2446 int n_elts = GET_MODE_NUNITS (mode);
2447 int n_var = 0, one_var = -1;
2448 bool all_same = true, all_const_zero = true;
2452 for (i = 0; i < n_elts; ++i)
2454 x = XVECEXP (vals, 0, i);
2455 if (!CONSTANT_P (x))
2456 ++n_var, one_var = i;
2457 else if (x != CONST0_RTX (inner_mode))
2458 all_const_zero = false;
2460 if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0)))
2466 if (mode != V4SFmode && all_const_zero)
2468 /* Zero register. */
2469 emit_insn (gen_rtx_SET (VOIDmode, target,
2470 gen_rtx_XOR (mode, target, target)));
2473 else if (mode != V4SFmode && easy_vector_constant (vals, mode))
2475 /* Splat immediate. */
2476 emit_insn (gen_rtx_SET (VOIDmode, target, vals));
2480 ; /* Splat vector element. */
2483 /* Load from constant pool. */
2484 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
2489 /* Store value to stack temp. Load vector element. Splat. */
2492 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2493 emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
2494 XVECEXP (vals, 0, 0));
2495 x = gen_rtx_UNSPEC (VOIDmode,
2496 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2497 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2499 gen_rtx_SET (VOIDmode,
2502 x = gen_rtx_VEC_SELECT (inner_mode, target,
2503 gen_rtx_PARALLEL (VOIDmode,
2504 gen_rtvec (1, const0_rtx)));
2505 emit_insn (gen_rtx_SET (VOIDmode, target,
2506 gen_rtx_VEC_DUPLICATE (mode, x)));
2510 /* One field is non-constant. Load constant then overwrite
2514 rtx copy = copy_rtx (vals);
2516 /* Load constant part of vector, substitute neighboring value for
2518 XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts);
2519 rs6000_expand_vector_init (target, copy);
2521 /* Insert variable. */
2522 rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), one_var);
2526 /* Construct the vector in memory one field at a time
2527 and load the whole vector. */
2528 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2529 for (i = 0; i < n_elts; i++)
2530 emit_move_insn (adjust_address_nv (mem, inner_mode,
2531 i * GET_MODE_SIZE (inner_mode)),
2532 XVECEXP (vals, 0, i));
2533 emit_move_insn (target, mem);
2536 /* Set field ELT of TARGET to VAL. */
2539 rs6000_expand_vector_set (rtx target, rtx val, int elt)
2541 enum machine_mode mode = GET_MODE (target);
2542 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2543 rtx reg = gen_reg_rtx (mode);
2545 int width = GET_MODE_SIZE (inner_mode);
2548 /* Load single variable value. */
2549 mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode), 0);
2550 emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val);
2551 x = gen_rtx_UNSPEC (VOIDmode,
2552 gen_rtvec (1, const0_rtx), UNSPEC_LVE);
2553 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2555 gen_rtx_SET (VOIDmode,
2559 /* Linear sequence. */
2560 mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
2561 for (i = 0; i < 16; ++i)
2562 XVECEXP (mask, 0, i) = GEN_INT (i);
2564 /* Set permute mask to insert element into target. */
2565 for (i = 0; i < width; ++i)
2566 XVECEXP (mask, 0, elt*width + i)
2567 = GEN_INT (i + 0x10);
2568 x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
2569 x = gen_rtx_UNSPEC (mode,
2570 gen_rtvec (3, target, reg,
2571 force_reg (V16QImode, x)),
2573 emit_insn (gen_rtx_SET (VOIDmode, target, x));
2576 /* Extract field ELT from VEC into TARGET. */
2579 rs6000_expand_vector_extract (rtx target, rtx vec, int elt)
2581 enum machine_mode mode = GET_MODE (vec);
2582 enum machine_mode inner_mode = GET_MODE_INNER (mode);
2585 /* Allocate mode-sized buffer. */
2586 mem = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
2588 /* Add offset to field within buffer matching vector element. */
2589 mem = adjust_address_nv (mem, mode, elt * GET_MODE_SIZE (inner_mode));
2591 /* Store single field into mode-sized buffer. */
2592 x = gen_rtx_UNSPEC (VOIDmode,
2593 gen_rtvec (1, const0_rtx), UNSPEC_STVE);
2594 emit_insn (gen_rtx_PARALLEL (VOIDmode,
2596 gen_rtx_SET (VOIDmode,
2599 emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0));
2602 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
2603 implement ANDing by the mask IN. */
2605 build_mask64_2_operands (rtx in, rtx *out)
2607 #if HOST_BITS_PER_WIDE_INT >= 64
2608 unsigned HOST_WIDE_INT c, lsb, m1, m2;
2611 gcc_assert (GET_CODE (in) == CONST_INT);
2616 /* Assume c initially something like 0x00fff000000fffff. The idea
2617 is to rotate the word so that the middle ^^^^^^ group of zeros
2618 is at the MS end and can be cleared with an rldicl mask. We then
2619 rotate back and clear off the MS ^^ group of zeros with a
2621 c = ~c; /* c == 0xff000ffffff00000 */
2622 lsb = c & -c; /* lsb == 0x0000000000100000 */
2623 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
2624 c = ~c; /* c == 0x00fff000000fffff */
2625 c &= -lsb; /* c == 0x00fff00000000000 */
2626 lsb = c & -c; /* lsb == 0x0000100000000000 */
2627 c = ~c; /* c == 0xff000fffffffffff */
2628 c &= -lsb; /* c == 0xff00000000000000 */
2630 while ((lsb >>= 1) != 0)
2631 shift++; /* shift == 44 on exit from loop */
2632 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
2633 m1 = ~m1; /* m1 == 0x000000ffffffffff */
2634 m2 = ~c; /* m2 == 0x00ffffffffffffff */
2638 /* Assume c initially something like 0xff000f0000000000. The idea
2639 is to rotate the word so that the ^^^ middle group of zeros
2640 is at the LS end and can be cleared with an rldicr mask. We then
2641 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
2643 lsb = c & -c; /* lsb == 0x0000010000000000 */
2644 m2 = -lsb; /* m2 == 0xffffff0000000000 */
2645 c = ~c; /* c == 0x00fff0ffffffffff */
2646 c &= -lsb; /* c == 0x00fff00000000000 */
2647 lsb = c & -c; /* lsb == 0x0000100000000000 */
2648 c = ~c; /* c == 0xff000fffffffffff */
2649 c &= -lsb; /* c == 0xff00000000000000 */
2651 while ((lsb >>= 1) != 0)
2652 shift++; /* shift == 44 on exit from loop */
2653 m1 = ~c; /* m1 == 0x00ffffffffffffff */
2654 m1 >>= shift; /* m1 == 0x0000000000000fff */
2655 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
2658 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
2659 masks will be all 1's. We are guaranteed more than one transition. */
2660 out[0] = GEN_INT (64 - shift);
2661 out[1] = GEN_INT (m1);
2662 out[2] = GEN_INT (shift);
2663 out[3] = GEN_INT (m2);
2671 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
2674 invalid_e500_subreg (rtx op, enum machine_mode mode)
2676 /* Reject (subreg:SI (reg:DF)). */
2677 if (GET_CODE (op) == SUBREG
2679 && REG_P (SUBREG_REG (op))
2680 && GET_MODE (SUBREG_REG (op)) == DFmode)
2683 /* Reject (subreg:DF (reg:DI)). */
2684 if (GET_CODE (op) == SUBREG
2686 && REG_P (SUBREG_REG (op))
2687 && GET_MODE (SUBREG_REG (op)) == DImode)
2693 /* AIX increases natural record alignment to doubleword if the first
2694 field is an FP double while the FP fields remain word aligned. */
2697 rs6000_special_round_type_align (tree type, unsigned int computed,
2698 unsigned int specified)
2700 unsigned int align = MAX (computed, specified);
2701 tree field = TYPE_FIELDS (type);
2703 /* Skip all non field decls */
2704 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2705 field = TREE_CHAIN (field);
2707 if (field != NULL && field != type)
2709 type = TREE_TYPE (field);
2710 while (TREE_CODE (type) == ARRAY_TYPE)
2711 type = TREE_TYPE (type);
2713 if (type != error_mark_node && TYPE_MODE (type) == DFmode)
2714 align = MAX (align, 64);
2720 /* Darwin increases record alignment to the natural alignment of
2724 darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
2725 unsigned int specified)
2727 unsigned int align = MAX (computed, specified);
2729 if (TYPE_PACKED (type))
2732 /* Find the first field, looking down into aggregates. */
2734 tree field = TYPE_FIELDS (type);
2735 /* Skip all non field decls */
2736 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2737 field = TREE_CHAIN (field);
2740 type = TREE_TYPE (field);
2741 while (TREE_CODE (type) == ARRAY_TYPE)
2742 type = TREE_TYPE (type);
2743 } while (AGGREGATE_TYPE_P (type));
2745 if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
2746 align = MAX (align, TYPE_ALIGN (type));
2751 /* Return 1 for an operand in small memory on V.4/eabi. */
2754 small_data_operand (rtx op ATTRIBUTE_UNUSED,
2755 enum machine_mode mode ATTRIBUTE_UNUSED)
2760 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
2763 if (DEFAULT_ABI != ABI_V4)
2766 if (GET_CODE (op) == SYMBOL_REF)
2769 else if (GET_CODE (op) != CONST
2770 || GET_CODE (XEXP (op, 0)) != PLUS
2771 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
2772 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
2777 rtx sum = XEXP (op, 0);
2778 HOST_WIDE_INT summand;
2780 /* We have to be careful here, because it is the referenced address
2781 that must be 32k from _SDA_BASE_, not just the symbol. */
2782 summand = INTVAL (XEXP (sum, 1));
2783 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
2786 sym_ref = XEXP (sum, 0);
2789 return SYMBOL_REF_SMALL_P (sym_ref);
2795 /* Return true if either operand is a general purpose register. */
2798 gpr_or_gpr_p (rtx op0, rtx op1)
2800 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
2801 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
2805 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
2808 constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
2810 switch (GET_CODE (op))
2813 if (RS6000_SYMBOL_REF_TLS_P (op))
2815 else if (CONSTANT_POOL_ADDRESS_P (op))
2817 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
2825 else if (! strcmp (XSTR (op, 0), toc_label_name))
2834 return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
2835 && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
2837 return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
2846 constant_pool_expr_p (rtx op)
2850 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
2854 toc_relative_expr_p (rtx op)
2858 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
2862 legitimate_constant_pool_address_p (rtx x)
2865 && GET_CODE (x) == PLUS
2866 && GET_CODE (XEXP (x, 0)) == REG
2867 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
2868 && constant_pool_expr_p (XEXP (x, 1)));
2872 legitimate_small_data_p (enum machine_mode mode, rtx x)
2874 return (DEFAULT_ABI == ABI_V4
2875 && !flag_pic && !TARGET_TOC
2876 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
2877 && small_data_operand (x, mode));
2880 /* SPE offset addressing is limited to 5-bits worth of double words. */
2881 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
2884 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
2886 unsigned HOST_WIDE_INT offset, extra;
2888 if (GET_CODE (x) != PLUS)
2890 if (GET_CODE (XEXP (x, 0)) != REG)
2892 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
2894 if (legitimate_constant_pool_address_p (x))
2896 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2899 offset = INTVAL (XEXP (x, 1));
2907 /* AltiVec vector modes. Only reg+reg addressing is valid and
2908 constant offset zero should not occur due to canonicalization.
2909 Allow any offset when not strict before reload. */
2916 /* SPE vector modes. */
2917 return SPE_CONST_OFFSET_OK (offset);
2920 if (TARGET_E500_DOUBLE)
2921 return SPE_CONST_OFFSET_OK (offset);
2924 /* On e500v2, we may have:
2926 (subreg:DF (mem:DI (plus (reg) (const_int))) 0).
2928 Which gets addressed with evldd instructions. */
2929 if (TARGET_E500_DOUBLE)
2930 return SPE_CONST_OFFSET_OK (offset);
2932 if (mode == DFmode || !TARGET_POWERPC64)
2934 else if (offset & 3)
2940 if (mode == TFmode || !TARGET_POWERPC64)
2942 else if (offset & 3)
2953 return (offset < 0x10000) && (offset + extra < 0x10000);
2957 legitimate_indexed_address_p (rtx x, int strict)
2961 if (GET_CODE (x) != PLUS)
2967 /* Recognize the rtl generated by reload which we know will later be
2968 replaced with proper base and index regs. */
2970 && reload_in_progress
2971 && (REG_P (op0) || GET_CODE (op0) == PLUS)
2975 return (REG_P (op0) && REG_P (op1)
2976 && ((INT_REG_OK_FOR_BASE_P (op0, strict)
2977 && INT_REG_OK_FOR_INDEX_P (op1, strict))
2978 || (INT_REG_OK_FOR_BASE_P (op1, strict)
2979 && INT_REG_OK_FOR_INDEX_P (op0, strict))));
2983 legitimate_indirect_address_p (rtx x, int strict)
2985 return GET_CODE (x) == REG && INT_REG_OK_FOR_BASE_P (x, strict);
2989 macho_lo_sum_memory_operand (rtx x, enum machine_mode mode)
2991 if (!TARGET_MACHO || !flag_pic
2992 || mode != SImode || GET_CODE (x) != MEM)
2996 if (GET_CODE (x) != LO_SUM)
2998 if (GET_CODE (XEXP (x, 0)) != REG)
3000 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0))
3004 return CONSTANT_P (x);
3008 legitimate_lo_sum_address_p (enum machine_mode mode, rtx x, int strict)
3010 if (GET_CODE (x) != LO_SUM)
3012 if (GET_CODE (XEXP (x, 0)) != REG)
3014 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
3016 /* Restrict addressing for DI because of our SUBREG hackery. */
3017 if (TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
3021 if (TARGET_ELF || TARGET_MACHO)
3023 if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
3027 if (GET_MODE_NUNITS (mode) != 1)
3029 if (GET_MODE_BITSIZE (mode) > 64
3030 || (GET_MODE_BITSIZE (mode) > 32 && !TARGET_POWERPC64
3031 && !(TARGET_HARD_FLOAT && TARGET_FPRS && mode == DFmode)))
3034 return CONSTANT_P (x);
3041 /* Try machine-dependent ways of modifying an illegitimate address
3042 to be legitimate. If we find one, return the new, valid address.
3043 This is used from only one place: `memory_address' in explow.c.
3045 OLDX is the address as it was before break_out_memory_refs was
3046 called. In some cases it is useful to look at this to decide what
3049 MODE is passed so that this function can use GO_IF_LEGITIMATE_ADDRESS.
3051 It is always safe for this function to do nothing. It exists to
3052 recognize opportunities to optimize the output.
3054 On RS/6000, first check for the sum of a register with a constant
3055 integer that is out of range. If so, generate code to add the
3056 constant with the low-order 16 bits masked to the register and force
3057 this result into another register (this can be done with `cau').
3058 Then generate an address of REG+(CONST&0xffff), allowing for the
3059 possibility of bit 16 being a one.
3061 Then check for the sum of a register and something not constant, try to
3062 load the other things into a register and return the sum. */
3065 rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
3066 enum machine_mode mode)
3068 if (GET_CODE (x) == SYMBOL_REF)
3070 enum tls_model model = SYMBOL_REF_TLS_MODEL (x);
3072 return rs6000_legitimize_tls_address (x, model);
3075 if (GET_CODE (x) == PLUS
3076 && GET_CODE (XEXP (x, 0)) == REG
3077 && GET_CODE (XEXP (x, 1)) == CONST_INT
3078 && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) >= 0x10000)
3080 HOST_WIDE_INT high_int, low_int;
3082 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
3083 high_int = INTVAL (XEXP (x, 1)) - low_int;
3084 sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0),
3085 GEN_INT (high_int)), 0);
3086 return gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));
3088 else if (GET_CODE (x) == PLUS
3089 && GET_CODE (XEXP (x, 0)) == REG
3090 && GET_CODE (XEXP (x, 1)) != CONST_INT
3091 && GET_MODE_NUNITS (mode) == 1
3092 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3094 || (((mode != DImode && mode != DFmode) || TARGET_E500_DOUBLE)
3096 && (TARGET_POWERPC64 || mode != DImode)
3099 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
3100 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
3102 else if (ALTIVEC_VECTOR_MODE (mode))
3106 /* Make sure both operands are registers. */
3107 if (GET_CODE (x) == PLUS)
3108 return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)),
3109 force_reg (Pmode, XEXP (x, 1)));
3111 reg = force_reg (Pmode, x);
3114 else if (SPE_VECTOR_MODE (mode)
3115 || (TARGET_E500_DOUBLE && (mode == DFmode
3116 || mode == DImode)))
3120 /* We accept [reg + reg] and [reg + OFFSET]. */
3122 if (GET_CODE (x) == PLUS)
3124 rtx op1 = XEXP (x, 0);
3125 rtx op2 = XEXP (x, 1);
3127 op1 = force_reg (Pmode, op1);
3129 if (GET_CODE (op2) != REG
3130 && (GET_CODE (op2) != CONST_INT
3131 || !SPE_CONST_OFFSET_OK (INTVAL (op2))))
3132 op2 = force_reg (Pmode, op2);
3134 return gen_rtx_PLUS (Pmode, op1, op2);
3137 return force_reg (Pmode, x);
3143 && GET_CODE (x) != CONST_INT
3144 && GET_CODE (x) != CONST_DOUBLE
3146 && GET_MODE_NUNITS (mode) == 1
3147 && (GET_MODE_BITSIZE (mode) <= 32
3148 || ((TARGET_HARD_FLOAT && TARGET_FPRS) && mode == DFmode)))
3150 rtx reg = gen_reg_rtx (Pmode);
3151 emit_insn (gen_elf_high (reg, x));
3152 return gen_rtx_LO_SUM (Pmode, reg, x);
3154 else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
3157 && ! MACHO_DYNAMIC_NO_PIC_P
3159 && GET_CODE (x) != CONST_INT
3160 && GET_CODE (x) != CONST_DOUBLE
3162 && ((TARGET_HARD_FLOAT && TARGET_FPRS) || mode != DFmode)
3166 rtx reg = gen_reg_rtx (Pmode);
3167 emit_insn (gen_macho_high (reg, x));
3168 return gen_rtx_LO_SUM (Pmode, reg, x);
3171 && constant_pool_expr_p (x)
3172 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
3174 return create_TOC_reference (x);
3180 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
3181 We need to emit DTP-relative relocations. */
3184 rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
3189 fputs ("\t.long\t", file);
3192 fputs (DOUBLE_INT_ASM_OP, file);
3197 output_addr_const (file, x);
3198 fputs ("@dtprel+0x8000", file);
3201 /* Construct the SYMBOL_REF for the tls_get_addr function. */
3203 static GTY(()) rtx rs6000_tls_symbol;
3205 rs6000_tls_get_addr (void)
3207 if (!rs6000_tls_symbol)
3208 rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr");
3210 return rs6000_tls_symbol;
3213 /* Construct the SYMBOL_REF for TLS GOT references. */
3215 static GTY(()) rtx rs6000_got_symbol;
3217 rs6000_got_sym (void)
3219 if (!rs6000_got_symbol)
3221 rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
3222 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL;
3223 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL;
3226 return rs6000_got_symbol;
3229 /* ADDR contains a thread-local SYMBOL_REF. Generate code to compute
3230 this (thread-local) address. */
3233 rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
3237 dest = gen_reg_rtx (Pmode);
3238 if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 16)
3244 tlsreg = gen_rtx_REG (Pmode, 13);
3245 insn = gen_tls_tprel_64 (dest, tlsreg, addr);
3249 tlsreg = gen_rtx_REG (Pmode, 2);
3250 insn = gen_tls_tprel_32 (dest, tlsreg, addr);
3254 else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32)
3258 tmp = gen_reg_rtx (Pmode);
3261 tlsreg = gen_rtx_REG (Pmode, 13);
3262 insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr);
3266 tlsreg = gen_rtx_REG (Pmode, 2);
3267 insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr);
3271 insn = gen_tls_tprel_lo_64 (dest, tmp, addr);
3273 insn = gen_tls_tprel_lo_32 (dest, tmp, addr);
3278 rtx r3, got, tga, tmp1, tmp2, eqv;
3280 /* We currently use relocations like @got@tlsgd for tls, which
3281 means the linker will handle allocation of tls entries, placing
3282 them in the .got section. So use a pointer to the .got section,
3283 not one to secondary TOC sections used by 64-bit -mminimal-toc,
3284 or to secondary GOT sections used by 32-bit -fPIC. */
3286 got = gen_rtx_REG (Pmode, 2);
3290 got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
3293 rtx gsym = rs6000_got_sym ();
3294 got = gen_reg_rtx (Pmode);
3296 rs6000_emit_move (got, gsym, Pmode);
3299 rtx tempLR, tmp3, mem;
3302 tempLR = gen_reg_rtx (Pmode);
3303 tmp1 = gen_reg_rtx (Pmode);
3304 tmp2 = gen_reg_rtx (Pmode);
3305 tmp3 = gen_reg_rtx (Pmode);
3306 mem = gen_const_mem (Pmode, tmp1);
3308 first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, gsym));
3309 emit_move_insn (tmp1, tempLR);
3310 emit_move_insn (tmp2, mem);
3311 emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
3312 last = emit_move_insn (got, tmp3);
3313 REG_NOTES (last) = gen_rtx_EXPR_LIST (REG_EQUAL, gsym,
3315 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
3317 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
3323 if (model == TLS_MODEL_GLOBAL_DYNAMIC)
3325 r3 = gen_rtx_REG (Pmode, 3);
3327 insn = gen_tls_gd_64 (r3, got, addr);
3329 insn = gen_tls_gd_32 (r3, got, addr);
3332 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3333 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3334 insn = emit_call_insn (insn);
3335 CONST_OR_PURE_CALL_P (insn) = 1;
3336 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3337 insn = get_insns ();
3339 emit_libcall_block (insn, dest, r3, addr);
3341 else if (model == TLS_MODEL_LOCAL_DYNAMIC)
3343 r3 = gen_rtx_REG (Pmode, 3);
3345 insn = gen_tls_ld_64 (r3, got);
3347 insn = gen_tls_ld_32 (r3, got);
3350 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
3351 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
3352 insn = emit_call_insn (insn);
3353 CONST_OR_PURE_CALL_P (insn) = 1;
3354 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
3355 insn = get_insns ();
3357 tmp1 = gen_reg_rtx (Pmode);
3358 eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
3360 emit_libcall_block (insn, tmp1, r3, eqv);
3361 if (rs6000_tls_size == 16)
3364 insn = gen_tls_dtprel_64 (dest, tmp1, addr);
3366 insn = gen_tls_dtprel_32 (dest, tmp1, addr);
3368 else if (rs6000_tls_size == 32)
3370 tmp2 = gen_reg_rtx (Pmode);
3372 insn = gen_tls_dtprel_ha_64 (tmp2, tmp1, addr);
3374 insn = gen_tls_dtprel_ha_32 (tmp2, tmp1, addr);
3377 insn = gen_tls_dtprel_lo_64 (dest, tmp2, addr);
3379 insn = gen_tls_dtprel_lo_32 (dest, tmp2, addr);
3383 tmp2 = gen_reg_rtx (Pmode);
3385 insn = gen_tls_got_dtprel_64 (tmp2, got, addr);
3387 insn = gen_tls_got_dtprel_32 (tmp2, got, addr);
3389 insn = gen_rtx_SET (Pmode, dest,
3390 gen_rtx_PLUS (Pmode, tmp2, tmp1));
3396 /* IE, or 64 bit offset LE. */
3397 tmp2 = gen_reg_rtx (Pmode);
3399 insn = gen_tls_got_tprel_64 (tmp2, got, addr);
3401 insn = gen_tls_got_tprel_32 (tmp2, got, addr);
3404 insn = gen_tls_tls_64 (dest, tmp2, addr);
3406 insn = gen_tls_tls_32 (dest, tmp2, addr);
3414 /* Return 1 if X contains a thread-local symbol. */
3417 rs6000_tls_referenced_p (rtx x)
3419 if (! TARGET_HAVE_TLS)
3422 return for_each_rtx (&x, &rs6000_tls_symbol_ref_1, 0);
3425 /* Return 1 if *X is a thread-local symbol. This is the same as
3426 rs6000_tls_symbol_ref except for the type of the unused argument. */
3429 rs6000_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
3431 return RS6000_SYMBOL_REF_TLS_P (*x);
3434 /* The convention appears to be to define this wherever it is used.
3435 With legitimize_reload_address now defined here, REG_MODE_OK_FOR_BASE_P
3436 is now used here. */
3437 #ifndef REG_MODE_OK_FOR_BASE_P
3438 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
3441 /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS. Returns a value to
3442 replace the input X, or the original X if no replacement is called for.
3443 The output parameter *WIN is 1 if the calling macro should goto WIN,
3446 For RS/6000, we wish to handle large displacements off a base
3447 register by splitting the addend across an addiu/addis and the mem insn.
3448 This cuts number of extra insns needed from 3 to 1.
3450 On Darwin, we use this to generate code for floating point constants.
3451 A movsf_low is generated so we wind up with 2 instructions rather than 3.
3452 The Darwin code is inside #if TARGET_MACHO because only then is
3453 machopic_function_base_name() defined. */
3455 rs6000_legitimize_reload_address (rtx x, enum machine_mode mode,
3456 int opnum, int type,
3457 int ind_levels ATTRIBUTE_UNUSED, int *win)
3459 /* We must recognize output that we have already generated ourselves. */
3460 if (GET_CODE (x) == PLUS
3461 && GET_CODE (XEXP (x, 0)) == PLUS
3462 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3463 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3464 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3466 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3467 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3468 opnum, (enum reload_type)type);
3474 if (DEFAULT_ABI == ABI_DARWIN && flag_pic
3475 && GET_CODE (x) == LO_SUM
3476 && GET_CODE (XEXP (x, 0)) == PLUS
3477 && XEXP (XEXP (x, 0), 0) == pic_offset_table_rtx
3478 && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH
3479 && GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 0)) == CONST
3480 && XEXP (XEXP (XEXP (x, 0), 1), 0) == XEXP (x, 1)
3481 && GET_CODE (XEXP (XEXP (x, 1), 0)) == MINUS
3482 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 0)) == SYMBOL_REF
3483 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 1)) == SYMBOL_REF)
3485 /* Result of previous invocation of this function on Darwin
3486 floating point constant. */
3487 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3488 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3489 opnum, (enum reload_type)type);
3495 /* Force ld/std non-word aligned offset into base register by wrapping
3497 if (GET_CODE (x) == PLUS
3498 && GET_CODE (XEXP (x, 0)) == REG
3499 && REGNO (XEXP (x, 0)) < 32
3500 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3501 && GET_CODE (XEXP (x, 1)) == CONST_INT
3502 && (INTVAL (XEXP (x, 1)) & 3) != 0
3503 && !ALTIVEC_VECTOR_MODE (mode)
3504 && GET_MODE_SIZE (mode) >= UNITS_PER_WORD
3505 && TARGET_POWERPC64)
3507 x = gen_rtx_PLUS (GET_MODE (x), x, GEN_INT (0));
3508 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3509 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3510 opnum, (enum reload_type) type);
3515 if (GET_CODE (x) == PLUS
3516 && GET_CODE (XEXP (x, 0)) == REG
3517 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
3518 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3519 && GET_CODE (XEXP (x, 1)) == CONST_INT
3520 && !SPE_VECTOR_MODE (mode)
3521 && !(TARGET_E500_DOUBLE && (mode == DFmode
3523 && !ALTIVEC_VECTOR_MODE (mode))
3525 HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
3526 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
3528 = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;
3530 /* Check for 32-bit overflow. */
3531 if (high + low != val)
3537 /* Reload the high part into a base reg; leave the low part
3538 in the mem directly. */
3540 x = gen_rtx_PLUS (GET_MODE (x),
3541 gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
3545 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3546 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3547 opnum, (enum reload_type)type);
3552 if (GET_CODE (x) == SYMBOL_REF
3553 && !ALTIVEC_VECTOR_MODE (mode)
3554 && !SPE_VECTOR_MODE (mode)
3556 && DEFAULT_ABI == ABI_DARWIN
3557 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
3559 && DEFAULT_ABI == ABI_V4
3562 /* Don't do this for TFmode, since the result isn't offsettable.
3563 The same goes for DImode without 64-bit gprs and DFmode
3566 && (mode != DImode || TARGET_POWERPC64)
3567 && (mode != DFmode || TARGET_POWERPC64
3568 || (TARGET_FPRS && TARGET_HARD_FLOAT)))
3573 rtx offset = gen_rtx_CONST (Pmode,
3574 gen_rtx_MINUS (Pmode, x,
3575 machopic_function_base_sym ()));
3576 x = gen_rtx_LO_SUM (GET_MODE (x),
3577 gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
3578 gen_rtx_HIGH (Pmode, offset)), offset);
3582 x = gen_rtx_LO_SUM (GET_MODE (x),
3583 gen_rtx_HIGH (Pmode, x), x);
3585 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3586 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3587 opnum, (enum reload_type)type);
3592 /* Reload an offset address wrapped by an AND that represents the
3593 masking of the lower bits. Strip the outer AND and let reload
3594 convert the offset address into an indirect address. */
3596 && ALTIVEC_VECTOR_MODE (mode)
3597 && GET_CODE (x) == AND
3598 && GET_CODE (XEXP (x, 0)) == PLUS
3599 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
3600 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
3601 && GET_CODE (XEXP (x, 1)) == CONST_INT
3602 && INTVAL (XEXP (x, 1)) == -16)
3610 && constant_pool_expr_p (x)
3611 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
3613 x = create_TOC_reference (x);
3621 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
3622 that is a valid memory address for an instruction.
3623 The MODE argument is the machine mode for the MEM expression
3624 that wants to use this address.
3626 On the RS/6000, there are four valid address: a SYMBOL_REF that
3627 refers to a constant pool entry of an address (or the sum of it
3628 plus a constant), a short (16-bit signed) constant plus a register,
3629 the sum of two registers, or a register indirect, possibly with an
3630 auto-increment. For DFmode and DImode with a constant plus register,
3631 we must ensure that both words are addressable or PowerPC64 with offset
3634 For modes spanning multiple registers (DFmode in 32-bit GPRs,
3635 32-bit DImode, TImode, TFmode), indexed addressing cannot be used because
3636 adjacent memory cells are accessed by adding word-sized offsets
3637 during assembly output. */
3639 rs6000_legitimate_address (enum machine_mode mode, rtx x, int reg_ok_strict)
3641 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */
3643 && ALTIVEC_VECTOR_MODE (mode)
3644 && GET_CODE (x) == AND
3645 && GET_CODE (XEXP (x, 1)) == CONST_INT
3646 && INTVAL (XEXP (x, 1)) == -16)
3649 if (RS6000_SYMBOL_REF_TLS_P (x))
3651 if (legitimate_indirect_address_p (x, reg_ok_strict))
3653 if ((GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
3654 && !ALTIVEC_VECTOR_MODE (mode)
3655 && !SPE_VECTOR_MODE (mode)
3657 /* Restrict addressing for DI because of our SUBREG hackery. */
3658 && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
3660 && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict))
3662 if (legitimate_small_data_p (mode, x))
3664 if (legitimate_constant_pool_address_p (x))
3666 /* If not REG_OK_STRICT (before reload) let pass any stack offset. */
3668 && GET_CODE (x) == PLUS
3669 && GET_CODE (XEXP (x, 0)) == REG
3670 && (XEXP (x, 0) == virtual_stack_vars_rtx
3671 || XEXP (x, 0) == arg_pointer_rtx)
3672 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3674 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict))
3678 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3680 || ((mode != DFmode || TARGET_E500_DOUBLE) && mode != TFmode))
3681 && (TARGET_POWERPC64 || mode != DImode)
3682 && legitimate_indexed_address_p (x, reg_ok_strict))
3684 if (legitimate_lo_sum_address_p (mode, x, reg_ok_strict))
3689 /* Go to LABEL if ADDR (a legitimate address expression)
3690 has an effect that depends on the machine mode it is used for.
3692 On the RS/6000 this is true of all integral offsets (since AltiVec
3693 modes don't allow them) or is a pre-increment or decrement.
3695 ??? Except that due to conceptual problems in offsettable_address_p
3696 we can't really report the problems of integral offsets. So leave
3697 this assuming that the adjustable offset must be valid for the
3698 sub-words of a TFmode operand, which is what we had before. */
3701 rs6000_mode_dependent_address (rtx addr)
3703 switch (GET_CODE (addr))
3706 if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
3708 unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
3709 return val + 12 + 0x8000 >= 0x10000;
3718 return TARGET_UPDATE;
3727 /* More elaborate version of recog's offsettable_memref_p predicate
3728 that works around the ??? note of rs6000_mode_dependent_address.
3729 In particular it accepts
3731 (mem:DI (plus:SI (reg/f:SI 31 31) (const_int 32760 [0x7ff8])))
3733 in 32-bit mode, that the recog predicate rejects. */
3736 rs6000_offsettable_memref_p (rtx op)
3741 /* First mimic offsettable_memref_p. */
3742 if (offsettable_address_p (1, GET_MODE (op), XEXP (op, 0)))
3745 /* offsettable_address_p invokes rs6000_mode_dependent_address, but
3746 the latter predicate knows nothing about the mode of the memory
3747 reference and, therefore, assumes that it is the largest supported
3748 mode (TFmode). As a consequence, legitimate offsettable memory
3749 references are rejected. rs6000_legitimate_offset_address_p contains
3750 the correct logic for the PLUS case of rs6000_mode_dependent_address. */
3751 return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0), 1);
3754 /* Return number of consecutive hard regs needed starting at reg REGNO
3755 to hold something of mode MODE.
3756 This is ordinarily the length in words of a value of mode MODE
3757 but can be less for certain modes in special long registers.
3759 For the SPE, GPRs are 64 bits but only 32 bits are visible in
3760 scalar instructions. The upper 32 bits are only available to the
3763 POWER and PowerPC GPRs hold 32 bits worth;
3764 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
3767 rs6000_hard_regno_nregs (int regno, enum machine_mode mode)
3769 if (FP_REGNO_P (regno))
3770 return (GET_MODE_SIZE (mode) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD;
3772 if (TARGET_E500_DOUBLE && mode == DFmode)
3775 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
3776 return (GET_MODE_SIZE (mode) + UNITS_PER_SPE_WORD - 1) / UNITS_PER_SPE_WORD;
3778 if (ALTIVEC_REGNO_P (regno))
3780 (GET_MODE_SIZE (mode) + UNITS_PER_ALTIVEC_WORD - 1) / UNITS_PER_ALTIVEC_WORD;
3782 return (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
3785 /* Change register usage conditional on target flags. */
3787 rs6000_conditional_register_usage (void)
3791 /* Set MQ register fixed (already call_used) if not POWER
3792 architecture (RIOS1, RIOS2, RSC, and PPC601) so that it will not
3797 /* 64-bit AIX and Linux reserve GPR13 for thread-private data. */
3799 fixed_regs[13] = call_used_regs[13]
3800 = call_really_used_regs[13] = 1;
3802 /* Conditionally disable FPRs. */
3803 if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
3804 for (i = 32; i < 64; i++)
3805 fixed_regs[i] = call_used_regs[i]
3806 = call_really_used_regs[i] = 1;
3808 /* The TOC register is not killed across calls in a way that is
3809 visible to the compiler. */
3810 if (DEFAULT_ABI == ABI_AIX)
3811 call_really_used_regs[2] = 0;
3813 if (DEFAULT_ABI == ABI_V4
3814 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3816 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3818 if (DEFAULT_ABI == ABI_V4
3819 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3821 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3822 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3823 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3825 if (DEFAULT_ABI == ABI_DARWIN
3826 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
3827 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3828 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3829 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3831 if (TARGET_TOC && TARGET_MINIMAL_TOC)
3832 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3833 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3836 global_regs[VSCR_REGNO] = 1;
3840 global_regs[SPEFSCR_REGNO] = 1;
3841 fixed_regs[FIXED_SCRATCH]
3842 = call_used_regs[FIXED_SCRATCH]
3843 = call_really_used_regs[FIXED_SCRATCH] = 1;
3846 if (! TARGET_ALTIVEC)
3848 for (i = FIRST_ALTIVEC_REGNO; i <= LAST_ALTIVEC_REGNO; ++i)
3849 fixed_regs[i] = call_used_regs[i] = call_really_used_regs[i] = 1;
3850 call_really_used_regs[VRSAVE_REGNO] = 1;
3853 if (TARGET_ALTIVEC_ABI)
3854 for (i = FIRST_ALTIVEC_REGNO; i < FIRST_ALTIVEC_REGNO + 20; ++i)
3855 call_used_regs[i] = call_really_used_regs[i] = 1;
3858 /* Try to output insns to set TARGET equal to the constant C if it can
3859 be done in less than N insns. Do all computations in MODE.
3860 Returns the place where the output has been placed if it can be
3861 done and the insns have been emitted. If it would take more than N
3862 insns, zero is returned and no insns and emitted. */
3865 rs6000_emit_set_const (rtx dest, enum machine_mode mode,
3866 rtx source, int n ATTRIBUTE_UNUSED)
3868 rtx result, insn, set;
3869 HOST_WIDE_INT c0, c1;
3876 dest = gen_reg_rtx (mode);
3877 emit_insn (gen_rtx_SET (VOIDmode, dest, source));
3881 result = no_new_pseudos ? dest : gen_reg_rtx (SImode);
3883 emit_insn (gen_rtx_SET (VOIDmode, result,
3884 GEN_INT (INTVAL (source)
3885 & (~ (HOST_WIDE_INT) 0xffff))));
3886 emit_insn (gen_rtx_SET (VOIDmode, dest,
3887 gen_rtx_IOR (SImode, result,
3888 GEN_INT (INTVAL (source) & 0xffff))));
3893 switch (GET_CODE (source))
3896 c0 = INTVAL (source);
3901 #if HOST_BITS_PER_WIDE_INT >= 64
3902 c0 = CONST_DOUBLE_LOW (source);
3905 c0 = CONST_DOUBLE_LOW (source);
3906 c1 = CONST_DOUBLE_HIGH (source);
3914 result = rs6000_emit_set_long_const (dest, c0, c1);
3921 insn = get_last_insn ();
3922 set = single_set (insn);
3923 if (! CONSTANT_P (SET_SRC (set)))
3924 set_unique_reg_note (insn, REG_EQUAL, source);
3929 /* Having failed to find a 3 insn sequence in rs6000_emit_set_const,
3930 fall back to a straight forward decomposition. We do this to avoid
3931 exponential run times encountered when looking for longer sequences
3932 with rs6000_emit_set_const. */
3934 rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c1, HOST_WIDE_INT c2)
3936 if (!TARGET_POWERPC64)
3938 rtx operand1, operand2;
3940 operand1 = operand_subword_force (dest, WORDS_BIG_ENDIAN == 0,
3942 operand2 = operand_subword_force (dest, WORDS_BIG_ENDIAN != 0,
3944 emit_move_insn (operand1, GEN_INT (c1));
3945 emit_move_insn (operand2, GEN_INT (c2));
3949 HOST_WIDE_INT ud1, ud2, ud3, ud4;
3952 ud2 = (c1 & 0xffff0000) >> 16;
3953 #if HOST_BITS_PER_WIDE_INT >= 64
3957 ud4 = (c2 & 0xffff0000) >> 16;
3959 if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000))
3960 || (ud4 == 0 && ud3 == 0 && ud2 == 0 && ! (ud1 & 0x8000)))
3963 emit_move_insn (dest, GEN_INT (((ud1 ^ 0x8000) - 0x8000)));
3965 emit_move_insn (dest, GEN_INT (ud1));
3968 else if ((ud4 == 0xffff && ud3 == 0xffff && (ud2 & 0x8000))
3969 || (ud4 == 0 && ud3 == 0 && ! (ud2 & 0x8000)))
3972 emit_move_insn (dest, GEN_INT (((ud2 << 16) ^ 0x80000000)
3975 emit_move_insn (dest, GEN_INT (ud2 << 16));
3977 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
3979 else if ((ud4 == 0xffff && (ud3 & 0x8000))
3980 || (ud4 == 0 && ! (ud3 & 0x8000)))
3983 emit_move_insn (dest, GEN_INT (((ud3 << 16) ^ 0x80000000)
3986 emit_move_insn (dest, GEN_INT (ud3 << 16));
3989 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud2)));
3990 emit_move_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (16)));
3992 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
3997 emit_move_insn (dest, GEN_INT (((ud4 << 16) ^ 0x80000000)
4000 emit_move_insn (dest, GEN_INT (ud4 << 16));
4003 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud3)));
4005 emit_move_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32)));
4007 emit_move_insn (dest, gen_rtx_IOR (DImode, dest,
4008 GEN_INT (ud2 << 16)));
4010 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
4016 /* Helper for the following. Get rid of [r+r] memory refs
4017 in cases where it won't work (TImode, TFmode). */