1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the
20 Free Software Foundation, 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
25 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
43 #include "basic-block.h"
44 #include "integrate.h"
50 #include "target-def.h"
51 #include "langhooks.h"
53 #include "cfglayout.h"
54 #include "sched-int.h"
55 #include "tree-gimple.h"
58 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
61 #include "gstab.h" /* for N_SLINE */
64 #ifndef TARGET_NO_PROTOTYPE
65 #define TARGET_NO_PROTOTYPE 0
68 #define min(A,B) ((A) < (B) ? (A) : (B))
69 #define max(A,B) ((A) > (B) ? (A) : (B))
71 /* Structure used to define the rs6000 stack */
72 typedef struct rs6000_stack {
73 int first_gp_reg_save; /* first callee saved GP register used */
74 int first_fp_reg_save; /* first callee saved FP register used */
75 int first_altivec_reg_save; /* first callee saved AltiVec register used */
76 int lr_save_p; /* true if the link reg needs to be saved */
77 int cr_save_p; /* true if the CR reg needs to be saved */
78 unsigned int vrsave_mask; /* mask of vec registers to save */
79 int toc_save_p; /* true if the TOC needs to be saved */
80 int push_p; /* true if we need to allocate stack space */
81 int calls_p; /* true if the function makes any calls */
82 int world_save_p; /* true if we're saving *everything*:
83 r13-r31, cr, f14-f31, vrsave, v20-v31 */
84 enum rs6000_abi abi; /* which ABI to use */
85 int gp_save_offset; /* offset to save GP regs from initial SP */
86 int fp_save_offset; /* offset to save FP regs from initial SP */
87 int altivec_save_offset; /* offset to save AltiVec regs from initial SP */
88 int lr_save_offset; /* offset to save LR from initial SP */
89 int cr_save_offset; /* offset to save CR from initial SP */
90 int vrsave_save_offset; /* offset to save VRSAVE from initial SP */
91 int spe_gp_save_offset; /* offset to save spe 64-bit gprs */
92 int toc_save_offset; /* offset to save the TOC pointer */
93 int varargs_save_offset; /* offset to save the varargs registers */
94 int ehrd_offset; /* offset to EH return data */
95 int reg_size; /* register size (4 or 8) */
96 int varargs_size; /* size to hold V.4 args passed in regs */
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 lr_size; /* size to hold LR if not in save_size */
106 int vrsave_size; /* size to hold VRSAVE if not in save_size */
107 int altivec_padding_size; /* size of altivec alignment padding if
109 int spe_gp_size; /* size of 64-bit GPR save size for SPE */
110 int spe_padding_size;
111 int toc_size; /* size to hold TOC if not in save_size */
112 HOST_WIDE_INT total_size; /* total bytes allocated for stack */
113 int spe_64bit_regs_used;
116 /* Target cpu type */
118 enum processor_type rs6000_cpu;
119 struct rs6000_cpu_select rs6000_select[3] =
121 /* switch name, tune arch */
122 { (const char *)0, "--with-cpu=", 1, 1 },
123 { (const char *)0, "-mcpu=", 1, 1 },
124 { (const char *)0, "-mtune=", 1, 0 },
127 /* Always emit branch hint bits. */
128 static GTY(()) bool rs6000_always_hint;
130 /* Schedule instructions for group formation. */
131 static GTY(()) bool rs6000_sched_groups;
133 /* Support adjust_priority scheduler hook
134 and -mprioritize-restricted-insns= option. */
135 const char *rs6000_sched_restricted_insns_priority_str;
136 int rs6000_sched_restricted_insns_priority;
138 /* Support for -msched-costly-dep option. */
139 const char *rs6000_sched_costly_dep_str;
140 enum rs6000_dependence_cost rs6000_sched_costly_dep;
142 /* Support for -minsert-sched-nops option. */
143 const char *rs6000_sched_insert_nops_str;
144 enum rs6000_nop_insertion rs6000_sched_insert_nops;
146 /* Support targetm.vectorize.builtin_mask_for_load. */
147 static GTY(()) tree altivec_builtin_mask_for_load;
149 /* Size of long double */
150 const char *rs6000_long_double_size_string;
151 int rs6000_long_double_type_size;
153 /* Whether -mabi=altivec has appeared */
154 int rs6000_altivec_abi;
156 /* Whether VRSAVE instructions should be generated. */
157 int rs6000_altivec_vrsave;
159 /* String from -mvrsave= option. */
160 const char *rs6000_altivec_vrsave_string;
162 /* Nonzero if we want SPE ABI extensions. */
165 /* Whether isel instructions should be generated. */
168 /* Whether SPE simd instructions should be generated. */
171 /* Nonzero if floating point operations are done in the GPRs. */
172 int rs6000_float_gprs = 0;
174 /* Nonzero if we want Darwin's struct-by-value-in-regs ABI. */
175 int rs6000_darwin64_abi;
177 /* String from -mfloat-gprs=. */
178 const char *rs6000_float_gprs_string;
180 /* String from -misel=. */
181 const char *rs6000_isel_string;
183 /* String from -mspe=. */
184 const char *rs6000_spe_string;
186 /* Set to nonzero once AIX common-mode calls have been defined. */
187 static GTY(()) int common_mode_defined;
189 /* Save information from a "cmpxx" operation until the branch or scc is
191 rtx rs6000_compare_op0, rs6000_compare_op1;
192 int rs6000_compare_fp_p;
194 /* Label number of label created for -mrelocatable, to call to so we can
195 get the address of the GOT section */
196 int rs6000_pic_labelno;
199 /* Which abi to adhere to */
200 const char *rs6000_abi_name;
202 /* Semantics of the small data area */
203 enum rs6000_sdata_type rs6000_sdata = SDATA_DATA;
205 /* Which small data model to use */
206 const char *rs6000_sdata_name = (char *)0;
208 /* Counter for labels which are to be placed in .fixup. */
209 int fixuplabelno = 0;
212 /* Bit size of immediate TLS offsets and string from which it is decoded. */
213 int rs6000_tls_size = 32;
214 const char *rs6000_tls_size_string;
216 /* ABI enumeration available for subtarget to use. */
217 enum rs6000_abi rs6000_current_abi;
219 /* ABI string from -mabi= option. */
220 const char *rs6000_abi_string;
222 /* Whether to use variant of AIX ABI for PowerPC64 Linux. */
226 const char *rs6000_debug_name;
227 int rs6000_debug_stack; /* debug stack applications */
228 int rs6000_debug_arg; /* debug argument handling */
230 /* Value is TRUE if register/mode pair is accepatable. */
231 bool rs6000_hard_regno_mode_ok_p[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
234 static GTY(()) tree opaque_V2SI_type_node;
235 static GTY(()) tree opaque_V2SF_type_node;
236 static GTY(()) tree opaque_p_V2SI_type_node;
237 static GTY(()) tree V16QI_type_node;
238 static GTY(()) tree V2SI_type_node;
239 static GTY(()) tree V2SF_type_node;
240 static GTY(()) tree V4HI_type_node;
241 static GTY(()) tree V4SI_type_node;
242 static GTY(()) tree V4SF_type_node;
243 static GTY(()) tree V8HI_type_node;
244 static GTY(()) tree unsigned_V16QI_type_node;
245 static GTY(()) tree unsigned_V8HI_type_node;
246 static GTY(()) tree unsigned_V4SI_type_node;
247 static GTY(()) tree bool_char_type_node; /* __bool char */
248 static GTY(()) tree bool_short_type_node; /* __bool short */
249 static GTY(()) tree bool_int_type_node; /* __bool int */
250 static GTY(()) tree pixel_type_node; /* __pixel */
251 static GTY(()) tree bool_V16QI_type_node; /* __vector __bool char */
252 static GTY(()) tree bool_V8HI_type_node; /* __vector __bool short */
253 static GTY(()) tree bool_V4SI_type_node; /* __vector __bool int */
254 static GTY(()) tree pixel_V8HI_type_node; /* __vector __pixel */
256 int rs6000_warn_altivec_long = 1; /* On by default. */
257 const char *rs6000_warn_altivec_long_switch;
259 const char *rs6000_traceback_name;
261 traceback_default = 0,
267 /* Flag to say the TOC is initialized */
269 char toc_label_name[10];
271 /* Alias set for saves and restores from the rs6000 stack. */
272 static GTY(()) int rs6000_sr_alias_set;
274 /* Call distance, overridden by -mlongcall and #pragma longcall(1).
275 The only place that looks at this is rs6000_set_default_type_attributes;
276 everywhere else should rely on the presence or absence of a longcall
277 attribute on the function declaration. Exception: init_cumulative_args
278 looks at it too, for libcalls. */
279 int rs6000_default_long_calls;
280 const char *rs6000_longcall_switch;
282 /* Control alignment for fields within structures. */
283 /* String from -malign-XXXXX. */
284 const char *rs6000_alignment_string;
285 int rs6000_alignment_flags;
287 struct builtin_description
289 /* mask is not const because we're going to alter it below. This
290 nonsense will go away when we rewrite the -march infrastructure
291 to give us more target flag bits. */
293 const enum insn_code icode;
294 const char *const name;
295 const enum rs6000_builtins code;
298 /* Target cpu costs. */
300 struct processor_costs {
301 const int mulsi; /* cost of SImode multiplication. */
302 const int mulsi_const; /* cost of SImode multiplication by constant. */
303 const int mulsi_const9; /* cost of SImode mult by short constant. */
304 const int muldi; /* cost of DImode multiplication. */
305 const int divsi; /* cost of SImode division. */
306 const int divdi; /* cost of DImode division. */
307 const int fp; /* cost of simple SFmode and DFmode insns. */
308 const int dmul; /* cost of DFmode multiplication (and fmadd). */
309 const int sdiv; /* cost of SFmode division (fdivs). */
310 const int ddiv; /* cost of DFmode division (fdiv). */
313 const struct processor_costs *rs6000_cost;
315 /* Processor costs (relative to an add) */
317 /* Instruction size costs on 32bit processors. */
319 struct processor_costs size32_cost = {
320 COSTS_N_INSNS (1), /* mulsi */
321 COSTS_N_INSNS (1), /* mulsi_const */
322 COSTS_N_INSNS (1), /* mulsi_const9 */
323 COSTS_N_INSNS (1), /* muldi */
324 COSTS_N_INSNS (1), /* divsi */
325 COSTS_N_INSNS (1), /* divdi */
326 COSTS_N_INSNS (1), /* fp */
327 COSTS_N_INSNS (1), /* dmul */
328 COSTS_N_INSNS (1), /* sdiv */
329 COSTS_N_INSNS (1), /* ddiv */
332 /* Instruction size costs on 64bit processors. */
334 struct processor_costs size64_cost = {
335 COSTS_N_INSNS (1), /* mulsi */
336 COSTS_N_INSNS (1), /* mulsi_const */
337 COSTS_N_INSNS (1), /* mulsi_const9 */
338 COSTS_N_INSNS (1), /* muldi */
339 COSTS_N_INSNS (1), /* divsi */
340 COSTS_N_INSNS (1), /* divdi */
341 COSTS_N_INSNS (1), /* fp */
342 COSTS_N_INSNS (1), /* dmul */
343 COSTS_N_INSNS (1), /* sdiv */
344 COSTS_N_INSNS (1), /* ddiv */
347 /* Instruction costs on RIOS1 processors. */
349 struct processor_costs rios1_cost = {
350 COSTS_N_INSNS (5), /* mulsi */
351 COSTS_N_INSNS (4), /* mulsi_const */
352 COSTS_N_INSNS (3), /* mulsi_const9 */
353 COSTS_N_INSNS (5), /* muldi */
354 COSTS_N_INSNS (19), /* divsi */
355 COSTS_N_INSNS (19), /* divdi */
356 COSTS_N_INSNS (2), /* fp */
357 COSTS_N_INSNS (2), /* dmul */
358 COSTS_N_INSNS (19), /* sdiv */
359 COSTS_N_INSNS (19), /* ddiv */
362 /* Instruction costs on RIOS2 processors. */
364 struct processor_costs rios2_cost = {
365 COSTS_N_INSNS (2), /* mulsi */
366 COSTS_N_INSNS (2), /* mulsi_const */
367 COSTS_N_INSNS (2), /* mulsi_const9 */
368 COSTS_N_INSNS (2), /* muldi */
369 COSTS_N_INSNS (13), /* divsi */
370 COSTS_N_INSNS (13), /* divdi */
371 COSTS_N_INSNS (2), /* fp */
372 COSTS_N_INSNS (2), /* dmul */
373 COSTS_N_INSNS (17), /* sdiv */
374 COSTS_N_INSNS (17), /* ddiv */
377 /* Instruction costs on RS64A processors. */
379 struct processor_costs rs64a_cost = {
380 COSTS_N_INSNS (20), /* mulsi */
381 COSTS_N_INSNS (12), /* mulsi_const */
382 COSTS_N_INSNS (8), /* mulsi_const9 */
383 COSTS_N_INSNS (34), /* muldi */
384 COSTS_N_INSNS (65), /* divsi */
385 COSTS_N_INSNS (67), /* divdi */
386 COSTS_N_INSNS (4), /* fp */
387 COSTS_N_INSNS (4), /* dmul */
388 COSTS_N_INSNS (31), /* sdiv */
389 COSTS_N_INSNS (31), /* ddiv */
392 /* Instruction costs on MPCCORE processors. */
394 struct processor_costs mpccore_cost = {
395 COSTS_N_INSNS (2), /* mulsi */
396 COSTS_N_INSNS (2), /* mulsi_const */
397 COSTS_N_INSNS (2), /* mulsi_const9 */
398 COSTS_N_INSNS (2), /* muldi */
399 COSTS_N_INSNS (6), /* divsi */
400 COSTS_N_INSNS (6), /* divdi */
401 COSTS_N_INSNS (4), /* fp */
402 COSTS_N_INSNS (5), /* dmul */
403 COSTS_N_INSNS (10), /* sdiv */
404 COSTS_N_INSNS (17), /* ddiv */
407 /* Instruction costs on PPC403 processors. */
409 struct processor_costs ppc403_cost = {
410 COSTS_N_INSNS (4), /* mulsi */
411 COSTS_N_INSNS (4), /* mulsi_const */
412 COSTS_N_INSNS (4), /* mulsi_const9 */
413 COSTS_N_INSNS (4), /* muldi */
414 COSTS_N_INSNS (33), /* divsi */
415 COSTS_N_INSNS (33), /* divdi */
416 COSTS_N_INSNS (11), /* fp */
417 COSTS_N_INSNS (11), /* dmul */
418 COSTS_N_INSNS (11), /* sdiv */
419 COSTS_N_INSNS (11), /* ddiv */
422 /* Instruction costs on PPC405 processors. */
424 struct processor_costs ppc405_cost = {
425 COSTS_N_INSNS (5), /* mulsi */
426 COSTS_N_INSNS (4), /* mulsi_const */
427 COSTS_N_INSNS (3), /* mulsi_const9 */
428 COSTS_N_INSNS (5), /* muldi */
429 COSTS_N_INSNS (35), /* divsi */
430 COSTS_N_INSNS (35), /* divdi */
431 COSTS_N_INSNS (11), /* fp */
432 COSTS_N_INSNS (11), /* dmul */
433 COSTS_N_INSNS (11), /* sdiv */
434 COSTS_N_INSNS (11), /* ddiv */
437 /* Instruction costs on PPC440 processors. */
439 struct processor_costs ppc440_cost = {
440 COSTS_N_INSNS (3), /* mulsi */
441 COSTS_N_INSNS (2), /* mulsi_const */
442 COSTS_N_INSNS (2), /* mulsi_const9 */
443 COSTS_N_INSNS (3), /* muldi */
444 COSTS_N_INSNS (34), /* divsi */
445 COSTS_N_INSNS (34), /* divdi */
446 COSTS_N_INSNS (5), /* fp */
447 COSTS_N_INSNS (5), /* dmul */
448 COSTS_N_INSNS (19), /* sdiv */
449 COSTS_N_INSNS (33), /* ddiv */
452 /* Instruction costs on PPC601 processors. */
454 struct processor_costs ppc601_cost = {
455 COSTS_N_INSNS (5), /* mulsi */
456 COSTS_N_INSNS (5), /* mulsi_const */
457 COSTS_N_INSNS (5), /* mulsi_const9 */
458 COSTS_N_INSNS (5), /* muldi */
459 COSTS_N_INSNS (36), /* divsi */
460 COSTS_N_INSNS (36), /* divdi */
461 COSTS_N_INSNS (4), /* fp */
462 COSTS_N_INSNS (5), /* dmul */
463 COSTS_N_INSNS (17), /* sdiv */
464 COSTS_N_INSNS (31), /* ddiv */
467 /* Instruction costs on PPC603 processors. */
469 struct processor_costs ppc603_cost = {
470 COSTS_N_INSNS (5), /* mulsi */
471 COSTS_N_INSNS (3), /* mulsi_const */
472 COSTS_N_INSNS (2), /* mulsi_const9 */
473 COSTS_N_INSNS (5), /* muldi */
474 COSTS_N_INSNS (37), /* divsi */
475 COSTS_N_INSNS (37), /* divdi */
476 COSTS_N_INSNS (3), /* fp */
477 COSTS_N_INSNS (4), /* dmul */
478 COSTS_N_INSNS (18), /* sdiv */
479 COSTS_N_INSNS (33), /* ddiv */
482 /* Instruction costs on PPC604 processors. */
484 struct processor_costs ppc604_cost = {
485 COSTS_N_INSNS (4), /* mulsi */
486 COSTS_N_INSNS (4), /* mulsi_const */
487 COSTS_N_INSNS (4), /* mulsi_const9 */
488 COSTS_N_INSNS (4), /* muldi */
489 COSTS_N_INSNS (20), /* divsi */
490 COSTS_N_INSNS (20), /* divdi */
491 COSTS_N_INSNS (3), /* fp */
492 COSTS_N_INSNS (3), /* dmul */
493 COSTS_N_INSNS (18), /* sdiv */
494 COSTS_N_INSNS (32), /* ddiv */
497 /* Instruction costs on PPC604e processors. */
499 struct processor_costs ppc604e_cost = {
500 COSTS_N_INSNS (2), /* mulsi */
501 COSTS_N_INSNS (2), /* mulsi_const */
502 COSTS_N_INSNS (2), /* mulsi_const9 */
503 COSTS_N_INSNS (2), /* muldi */
504 COSTS_N_INSNS (20), /* divsi */
505 COSTS_N_INSNS (20), /* divdi */
506 COSTS_N_INSNS (3), /* fp */
507 COSTS_N_INSNS (3), /* dmul */
508 COSTS_N_INSNS (18), /* sdiv */
509 COSTS_N_INSNS (32), /* ddiv */
512 /* Instruction costs on PPC620 processors. */
514 struct processor_costs ppc620_cost = {
515 COSTS_N_INSNS (5), /* mulsi */
516 COSTS_N_INSNS (4), /* mulsi_const */
517 COSTS_N_INSNS (3), /* mulsi_const9 */
518 COSTS_N_INSNS (7), /* muldi */
519 COSTS_N_INSNS (21), /* divsi */
520 COSTS_N_INSNS (37), /* divdi */
521 COSTS_N_INSNS (3), /* fp */
522 COSTS_N_INSNS (3), /* dmul */
523 COSTS_N_INSNS (18), /* sdiv */
524 COSTS_N_INSNS (32), /* ddiv */
527 /* Instruction costs on PPC630 processors. */
529 struct processor_costs ppc630_cost = {
530 COSTS_N_INSNS (5), /* mulsi */
531 COSTS_N_INSNS (4), /* mulsi_const */
532 COSTS_N_INSNS (3), /* mulsi_const9 */
533 COSTS_N_INSNS (7), /* muldi */
534 COSTS_N_INSNS (21), /* divsi */
535 COSTS_N_INSNS (37), /* divdi */
536 COSTS_N_INSNS (3), /* fp */
537 COSTS_N_INSNS (3), /* dmul */
538 COSTS_N_INSNS (17), /* sdiv */
539 COSTS_N_INSNS (21), /* ddiv */
542 /* Instruction costs on PPC750 and PPC7400 processors. */
544 struct processor_costs ppc750_cost = {
545 COSTS_N_INSNS (5), /* mulsi */
546 COSTS_N_INSNS (3), /* mulsi_const */
547 COSTS_N_INSNS (2), /* mulsi_const9 */
548 COSTS_N_INSNS (5), /* muldi */
549 COSTS_N_INSNS (17), /* divsi */
550 COSTS_N_INSNS (17), /* divdi */
551 COSTS_N_INSNS (3), /* fp */
552 COSTS_N_INSNS (3), /* dmul */
553 COSTS_N_INSNS (17), /* sdiv */
554 COSTS_N_INSNS (31), /* ddiv */
557 /* Instruction costs on PPC7450 processors. */
559 struct processor_costs ppc7450_cost = {
560 COSTS_N_INSNS (4), /* mulsi */
561 COSTS_N_INSNS (3), /* mulsi_const */
562 COSTS_N_INSNS (3), /* mulsi_const9 */
563 COSTS_N_INSNS (4), /* muldi */
564 COSTS_N_INSNS (23), /* divsi */
565 COSTS_N_INSNS (23), /* divdi */
566 COSTS_N_INSNS (5), /* fp */
567 COSTS_N_INSNS (5), /* dmul */
568 COSTS_N_INSNS (21), /* sdiv */
569 COSTS_N_INSNS (35), /* ddiv */
572 /* Instruction costs on PPC8540 processors. */
574 struct processor_costs ppc8540_cost = {
575 COSTS_N_INSNS (4), /* mulsi */
576 COSTS_N_INSNS (4), /* mulsi_const */
577 COSTS_N_INSNS (4), /* mulsi_const9 */
578 COSTS_N_INSNS (4), /* muldi */
579 COSTS_N_INSNS (19), /* divsi */
580 COSTS_N_INSNS (19), /* divdi */
581 COSTS_N_INSNS (4), /* fp */
582 COSTS_N_INSNS (4), /* dmul */
583 COSTS_N_INSNS (29), /* sdiv */
584 COSTS_N_INSNS (29), /* ddiv */
587 /* Instruction costs on POWER4 and POWER5 processors. */
589 struct processor_costs power4_cost = {
590 COSTS_N_INSNS (3), /* mulsi */
591 COSTS_N_INSNS (2), /* mulsi_const */
592 COSTS_N_INSNS (2), /* mulsi_const9 */
593 COSTS_N_INSNS (4), /* muldi */
594 COSTS_N_INSNS (18), /* divsi */
595 COSTS_N_INSNS (34), /* divdi */
596 COSTS_N_INSNS (3), /* fp */
597 COSTS_N_INSNS (3), /* dmul */
598 COSTS_N_INSNS (17), /* sdiv */
599 COSTS_N_INSNS (17), /* ddiv */
603 static bool rs6000_function_ok_for_sibcall (tree, tree);
604 static rtx rs6000_generate_compare (enum rtx_code);
605 static void rs6000_maybe_dead (rtx);
606 static void rs6000_emit_stack_tie (void);
607 static void rs6000_frame_related (rtx, rtx, HOST_WIDE_INT, rtx, rtx);
608 static rtx spe_synthesize_frame_save (rtx);
609 static bool spe_func_has_64bit_regs_p (void);
610 static void emit_frame_save (rtx, rtx, enum machine_mode, unsigned int,
612 static rtx gen_frame_mem_offset (enum machine_mode, rtx, int);
613 static void rs6000_emit_allocate_stack (HOST_WIDE_INT, int);
614 static unsigned rs6000_hash_constant (rtx);
615 static unsigned toc_hash_function (const void *);
616 static int toc_hash_eq (const void *, const void *);
617 static int constant_pool_expr_1 (rtx, int *, int *);
618 static bool constant_pool_expr_p (rtx);
619 static bool legitimate_small_data_p (enum machine_mode, rtx);
620 static bool legitimate_indexed_address_p (rtx, int);
621 static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
622 static struct machine_function * rs6000_init_machine_status (void);
623 static bool rs6000_assemble_integer (rtx, unsigned int, int);
624 #ifdef HAVE_GAS_HIDDEN
625 static void rs6000_assemble_visibility (tree, int);
627 static int rs6000_ra_ever_killed (void);
628 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
629 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
630 static void rs6000_eliminate_indexed_memrefs (rtx operands[2]);
631 static const char *rs6000_mangle_fundamental_type (tree);
632 extern const struct attribute_spec rs6000_attribute_table[];
633 static void rs6000_set_default_type_attributes (tree);
634 static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
635 static void rs6000_output_function_epilogue (FILE *, HOST_WIDE_INT);
636 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT,
638 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
639 static bool rs6000_return_in_memory (tree, tree);
640 static void rs6000_file_start (void);
642 static unsigned int rs6000_elf_section_type_flags (tree, const char *, int);
643 static void rs6000_elf_asm_out_constructor (rtx, int);
644 static void rs6000_elf_asm_out_destructor (rtx, int);
645 static void rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT);
646 static void rs6000_elf_unique_section (tree, int);
647 static void rs6000_elf_select_rtx_section (enum machine_mode, rtx,
648 unsigned HOST_WIDE_INT);
649 static void rs6000_elf_encode_section_info (tree, rtx, int)
651 static bool rs6000_elf_in_small_data_p (tree);
654 static void rs6000_xcoff_asm_globalize_label (FILE *, const char *);
655 static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree);
656 static void rs6000_xcoff_select_section (tree, int, unsigned HOST_WIDE_INT);
657 static void rs6000_xcoff_unique_section (tree, int);
658 static void rs6000_xcoff_select_rtx_section (enum machine_mode, rtx,
659 unsigned HOST_WIDE_INT);
660 static const char * rs6000_xcoff_strip_name_encoding (const char *);
661 static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int);
662 static void rs6000_xcoff_file_start (void);
663 static void rs6000_xcoff_file_end (void);
666 static bool rs6000_binds_local_p (tree);
668 static int rs6000_variable_issue (FILE *, int, rtx, int);
669 static bool rs6000_rtx_costs (rtx, int, int, int *);
670 static int rs6000_adjust_cost (rtx, rtx, rtx, int);
671 static bool is_microcoded_insn (rtx);
672 static int is_dispatch_slot_restricted (rtx);
673 static bool is_cracked_insn (rtx);
674 static bool is_branch_slot_insn (rtx);
675 static int rs6000_adjust_priority (rtx, int);
676 static int rs6000_issue_rate (void);
677 static bool rs6000_is_costly_dependence (rtx, rtx, rtx, int, int);
678 static rtx get_next_active_insn (rtx, rtx);
679 static bool insn_terminates_group_p (rtx , enum group_termination);
680 static bool is_costly_group (rtx *, rtx);
681 static int force_new_group (int, FILE *, rtx *, rtx, bool *, int, int *);
682 static int redefine_groups (FILE *, int, rtx, rtx);
683 static int pad_groups (FILE *, int, rtx, rtx);
684 static void rs6000_sched_finish (FILE *, int);
685 static int rs6000_use_sched_lookahead (void);
686 static tree rs6000_builtin_mask_for_load (void);
688 static void rs6000_init_builtins (void);
689 static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
690 static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
691 static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx);
692 static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
693 static void altivec_init_builtins (void);
694 static void rs6000_common_init_builtins (void);
695 static void rs6000_init_libfuncs (void);
697 static void enable_mask_for_builtins (struct builtin_description *, int,
698 enum rs6000_builtins,
699 enum rs6000_builtins);
700 static tree build_opaque_vector_type (tree, int);
701 static void spe_init_builtins (void);
702 static rtx spe_expand_builtin (tree, rtx, bool *);
703 static rtx spe_expand_stv_builtin (enum insn_code, tree);
704 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
705 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
706 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
707 static rs6000_stack_t *rs6000_stack_info (void);
708 static void debug_stack_info (rs6000_stack_t *);
710 static rtx altivec_expand_builtin (tree, rtx, bool *);
711 static rtx altivec_expand_ld_builtin (tree, rtx, bool *);
712 static rtx altivec_expand_st_builtin (tree, rtx, bool *);
713 static rtx altivec_expand_dst_builtin (tree, rtx, bool *);
714 static rtx altivec_expand_abs_builtin (enum insn_code, tree, rtx);
715 static rtx altivec_expand_predicate_builtin (enum insn_code,
716 const char *, tree, rtx);
717 static rtx altivec_expand_lv_builtin (enum insn_code, tree, rtx);
718 static rtx altivec_expand_stv_builtin (enum insn_code, tree);
719 static void rs6000_parse_abi_options (void);
720 static void rs6000_parse_alignment_option (void);
721 static void rs6000_parse_tls_size_option (void);
722 static void rs6000_parse_yes_no_option (const char *, const char *, int *);
723 static void rs6000_parse_float_gprs_option (void);
724 static int first_altivec_reg_to_save (void);
725 static unsigned int compute_vrsave_mask (void);
726 static void compute_save_world_info (rs6000_stack_t *info_ptr);
727 static void is_altivec_return_reg (rtx, void *);
728 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
729 int easy_vector_constant (rtx, enum machine_mode);
730 static bool is_ev64_opaque_type (tree);
731 static rtx rs6000_dwarf_register_span (rtx);
732 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
733 static rtx rs6000_tls_get_addr (void);
734 static rtx rs6000_got_sym (void);
735 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
736 static const char *rs6000_get_some_local_dynamic_name (void);
737 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
738 static rtx rs6000_complex_function_value (enum machine_mode);
739 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
740 enum machine_mode, tree);
741 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
743 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
744 tree, HOST_WIDE_INT);
745 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
748 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
751 static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, tree, int, bool);
752 static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
753 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
754 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
755 enum machine_mode, tree,
757 static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
759 static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
761 static const char *invalid_arg_for_unprototyped_fn (tree, tree, tree);
763 static void macho_branch_islands (void);
764 static void add_compiler_branch_island (tree, tree, int);
765 static int no_previous_def (tree function_name);
766 static tree get_prev_label (tree function_name);
767 static void rs6000_darwin_file_start (void);
770 static tree rs6000_build_builtin_va_list (void);
771 static tree rs6000_gimplify_va_arg (tree, tree, tree *, tree *);
772 static bool rs6000_must_pass_in_stack (enum machine_mode, tree);
773 static bool rs6000_vector_mode_supported_p (enum machine_mode);
774 static int get_vec_cmp_insn (enum rtx_code, enum machine_mode,
776 static rtx rs6000_emit_vector_compare (enum rtx_code, rtx, rtx,
778 static int get_vsel_insn (enum machine_mode);
779 static void rs6000_emit_vector_select (rtx, rtx, rtx, rtx);
782 const int INSN_NOT_AVAILABLE = -1;
783 static enum machine_mode rs6000_eh_return_filter_mode (void);
785 /* Hash table stuff for keeping track of TOC entries. */
787 struct toc_hash_struct GTY(())
789 /* `key' will satisfy CONSTANT_P; in fact, it will satisfy
790 ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
792 enum machine_mode key_mode;
796 static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
798 /* Default register names. */
799 char rs6000_reg_names[][8] =
801 "0", "1", "2", "3", "4", "5", "6", "7",
802 "8", "9", "10", "11", "12", "13", "14", "15",
803 "16", "17", "18", "19", "20", "21", "22", "23",
804 "24", "25", "26", "27", "28", "29", "30", "31",
805 "0", "1", "2", "3", "4", "5", "6", "7",
806 "8", "9", "10", "11", "12", "13", "14", "15",
807 "16", "17", "18", "19", "20", "21", "22", "23",
808 "24", "25", "26", "27", "28", "29", "30", "31",
809 "mq", "lr", "ctr","ap",
810 "0", "1", "2", "3", "4", "5", "6", "7",
812 /* AltiVec registers. */
813 "0", "1", "2", "3", "4", "5", "6", "7",
814 "8", "9", "10", "11", "12", "13", "14", "15",
815 "16", "17", "18", "19", "20", "21", "22", "23",
816 "24", "25", "26", "27", "28", "29", "30", "31",
822 #ifdef TARGET_REGNAMES
823 static const char alt_reg_names[][8] =
825 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
826 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
827 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
828 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
829 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
830 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
831 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
832 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
833 "mq", "lr", "ctr", "ap",
834 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
836 /* AltiVec registers. */
837 "%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
838 "%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
839 "%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
840 "%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
847 #ifndef MASK_STRICT_ALIGN
848 #define MASK_STRICT_ALIGN 0
850 #ifndef TARGET_PROFILE_KERNEL
851 #define TARGET_PROFILE_KERNEL 0
854 /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */
855 #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO))
857 /* Initialize the GCC target structure. */
858 #undef TARGET_ATTRIBUTE_TABLE
859 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
860 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
861 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
863 #undef TARGET_ASM_ALIGNED_DI_OP
864 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
866 /* Default unaligned ops are only provided for ELF. Find the ops needed
867 for non-ELF systems. */
868 #ifndef OBJECT_FORMAT_ELF
870 /* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on
872 #undef TARGET_ASM_UNALIGNED_HI_OP
873 #define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2,"
874 #undef TARGET_ASM_UNALIGNED_SI_OP
875 #define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4,"
876 #undef TARGET_ASM_UNALIGNED_DI_OP
877 #define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8,"
880 #undef TARGET_ASM_UNALIGNED_HI_OP
881 #define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
882 #undef TARGET_ASM_UNALIGNED_SI_OP
883 #define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t"
884 #undef TARGET_ASM_UNALIGNED_DI_OP
885 #define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t"
886 #undef TARGET_ASM_ALIGNED_DI_OP
887 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
891 /* This hook deals with fixups for relocatable code and DI-mode objects
893 #undef TARGET_ASM_INTEGER
894 #define TARGET_ASM_INTEGER rs6000_assemble_integer
896 #ifdef HAVE_GAS_HIDDEN
897 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
898 #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
901 #undef TARGET_HAVE_TLS
902 #define TARGET_HAVE_TLS HAVE_AS_TLS
904 #undef TARGET_CANNOT_FORCE_CONST_MEM
905 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
907 #undef TARGET_ASM_FUNCTION_PROLOGUE
908 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
909 #undef TARGET_ASM_FUNCTION_EPILOGUE
910 #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
912 #undef TARGET_SCHED_VARIABLE_ISSUE
913 #define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue
915 #undef TARGET_SCHED_ISSUE_RATE
916 #define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate
917 #undef TARGET_SCHED_ADJUST_COST
918 #define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost
919 #undef TARGET_SCHED_ADJUST_PRIORITY
920 #define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority
921 #undef TARGET_SCHED_IS_COSTLY_DEPENDENCE
922 #define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence
923 #undef TARGET_SCHED_FINISH
924 #define TARGET_SCHED_FINISH rs6000_sched_finish
926 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
927 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead
929 #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
930 #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
932 #undef TARGET_INIT_BUILTINS
933 #define TARGET_INIT_BUILTINS rs6000_init_builtins
935 #undef TARGET_EXPAND_BUILTIN
936 #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
938 #undef TARGET_MANGLE_FUNDAMENTAL_TYPE
939 #define TARGET_MANGLE_FUNDAMENTAL_TYPE rs6000_mangle_fundamental_type
941 #undef TARGET_INIT_LIBFUNCS
942 #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
945 #undef TARGET_BINDS_LOCAL_P
946 #define TARGET_BINDS_LOCAL_P rs6000_binds_local_p
949 #undef TARGET_ASM_OUTPUT_MI_THUNK
950 #define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
952 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
953 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
955 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
956 #define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall
958 #undef TARGET_RTX_COSTS
959 #define TARGET_RTX_COSTS rs6000_rtx_costs
960 #undef TARGET_ADDRESS_COST
961 #define TARGET_ADDRESS_COST hook_int_rtx_0
963 #undef TARGET_VECTOR_OPAQUE_P
964 #define TARGET_VECTOR_OPAQUE_P is_ev64_opaque_type
966 #undef TARGET_DWARF_REGISTER_SPAN
967 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
969 /* On rs6000, function arguments are promoted, as are function return
971 #undef TARGET_PROMOTE_FUNCTION_ARGS
972 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
973 #undef TARGET_PROMOTE_FUNCTION_RETURN
974 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
976 #undef TARGET_RETURN_IN_MEMORY
977 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
979 #undef TARGET_SETUP_INCOMING_VARARGS
980 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
982 /* Always strict argument naming on rs6000. */
983 #undef TARGET_STRICT_ARGUMENT_NAMING
984 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
985 #undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
986 #define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
987 #undef TARGET_SPLIT_COMPLEX_ARG
988 #define TARGET_SPLIT_COMPLEX_ARG hook_bool_tree_true
989 #undef TARGET_MUST_PASS_IN_STACK
990 #define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack
991 #undef TARGET_PASS_BY_REFERENCE
992 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
993 #undef TARGET_ARG_PARTIAL_BYTES
994 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
996 #undef TARGET_BUILD_BUILTIN_VA_LIST
997 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
999 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
1000 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1002 #undef TARGET_EH_RETURN_FILTER_MODE
1003 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1005 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1006 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1008 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1009 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1011 /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
1012 The PowerPC architecture requires only weak consistency among
1013 processors--that is, memory accesses between processors need not be
1014 sequentially consistent and memory accesses among processors can occur
1015 in any order. The ability to order memory accesses weakly provides
1016 opportunities for more efficient use of the system bus. Unless a
1017 dependency exists, the 604e allows read operations to precede store
1019 #undef TARGET_RELAXED_ORDERING
1020 #define TARGET_RELAXED_ORDERING true
1022 struct gcc_target targetm = TARGET_INITIALIZER;
1025 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1028 rs6000_hard_regno_mode_ok (int regno, enum machine_mode mode)
1030 /* The GPRs can hold any mode, but values bigger than one register
1031 cannot go past R31. */
1032 if (INT_REGNO_P (regno))
1033 return INT_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
1035 /* The float registers can only hold floating modes and DImode. */
1036 if (FP_REGNO_P (regno))
1038 (GET_MODE_CLASS (mode) == MODE_FLOAT
1039 && FP_REGNO_P (regno + HARD_REGNO_NREGS (regno, mode) - 1))
1040 || (GET_MODE_CLASS (mode) == MODE_INT
1041 && GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD);
1043 /* The CR register can only hold CC modes. */
1044 if (CR_REGNO_P (regno))
1045 return GET_MODE_CLASS (mode) == MODE_CC;
1047 if (XER_REGNO_P (regno))
1048 return mode == PSImode;
1050 /* AltiVec only in AldyVec registers. */
1051 if (ALTIVEC_REGNO_P (regno))
1052 return ALTIVEC_VECTOR_MODE (mode);
1054 /* ...but GPRs can hold SIMD data on the SPE in one register. */
1055 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
1058 /* We cannot put TImode anywhere except general register and it must be
1059 able to fit within the register set. */
1061 return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
1064 /* Initialize rs6000_hard_regno_mode_ok_p table. */
1066 rs6000_init_hard_regno_mode_ok (void)
1070 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
1071 for (m = 0; m < NUM_MACHINE_MODES; ++m)
1072 if (rs6000_hard_regno_mode_ok (r, m))
1073 rs6000_hard_regno_mode_ok_p[m][r] = true;
1076 /* If not otherwise specified by a target, make 'long double' equivalent to
1079 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
1080 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
1083 /* Override command line options. Mostly we process the processor
1084 type and sometimes adjust other TARGET_ options. */
1087 rs6000_override_options (const char *default_cpu)
1090 struct rs6000_cpu_select *ptr;
1093 /* Simplifications for entries below. */
1096 POWERPC_BASE_MASK = MASK_POWERPC | MASK_NEW_MNEMONICS,
1097 POWERPC_7400_MASK = POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_ALTIVEC
1100 /* This table occasionally claims that a processor does not support
1101 a particular feature even though it does, but the feature is slower
1102 than the alternative. Thus, it shouldn't be relied on as a
1103 complete description of the processor's support.
1105 Please keep this list in order, and don't forget to update the
1106 documentation in invoke.texi when adding a new processor or
1110 const char *const name; /* Canonical processor name. */
1111 const enum processor_type processor; /* Processor type enum value. */
1112 const int target_enable; /* Target flags to enable. */
1113 } const processor_target_table[]
1114 = {{"401", PROCESSOR_PPC403, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1115 {"403", PROCESSOR_PPC403,
1116 POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN},
1117 {"405", PROCESSOR_PPC405, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1118 {"405fp", PROCESSOR_PPC405, POWERPC_BASE_MASK},
1119 {"440", PROCESSOR_PPC440, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1120 {"440fp", PROCESSOR_PPC440, POWERPC_BASE_MASK},
1121 {"505", PROCESSOR_MPCCORE, POWERPC_BASE_MASK},
1122 {"601", PROCESSOR_PPC601,
1123 MASK_POWER | POWERPC_BASE_MASK | MASK_MULTIPLE | MASK_STRING},
1124 {"602", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1125 {"603", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1126 {"603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1127 {"604", PROCESSOR_PPC604, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1128 {"604e", PROCESSOR_PPC604e, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1129 {"620", PROCESSOR_PPC620,
1130 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1131 {"630", PROCESSOR_PPC630,
1132 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1133 {"740", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1134 {"7400", PROCESSOR_PPC7400, POWERPC_7400_MASK},
1135 {"7450", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1136 {"750", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1137 {"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1138 {"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1139 {"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1140 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1141 /* 8548 has a dummy entry for now. */
1142 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1143 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1144 {"970", PROCESSOR_POWER4,
1145 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1146 {"common", PROCESSOR_COMMON, MASK_NEW_MNEMONICS},
1147 {"ec603e", PROCESSOR_PPC603, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
1148 {"G3", PROCESSOR_PPC750, POWERPC_BASE_MASK | MASK_PPC_GFXOPT},
1149 {"G4", PROCESSOR_PPC7450, POWERPC_7400_MASK},
1150 {"G5", PROCESSOR_POWER4,
1151 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
1152 {"power", PROCESSOR_POWER, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1153 {"power2", PROCESSOR_POWER,
1154 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1155 {"power3", PROCESSOR_PPC630,
1156 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
1157 {"power4", PROCESSOR_POWER4,
1158 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1159 {"power5", PROCESSOR_POWER5,
1160 POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
1161 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
1162 {"powerpc64", PROCESSOR_POWERPC64,
1163 POWERPC_BASE_MASK | MASK_POWERPC64},
1164 {"rios", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1165 {"rios1", PROCESSOR_RIOS1, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1166 {"rios2", PROCESSOR_RIOS2,
1167 MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING},
1168 {"rsc", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1169 {"rsc1", PROCESSOR_PPC601, MASK_POWER | MASK_MULTIPLE | MASK_STRING},
1170 {"rs64a", PROCESSOR_RS64A, POWERPC_BASE_MASK | MASK_POWERPC64},
1173 const size_t ptt_size = ARRAY_SIZE (processor_target_table);
1175 /* Some OSs don't support saving the high part of 64-bit registers on
1176 context switch. Other OSs don't support saving Altivec registers.
1177 On those OSs, we don't touch the MASK_POWERPC64 or MASK_ALTIVEC
1178 settings; if the user wants either, the user must explicitly specify
1179 them and we won't interfere with the user's specification. */
1182 POWER_MASKS = MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
1183 POWERPC_MASKS = (POWERPC_BASE_MASK | MASK_PPC_GPOPT
1184 | MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_ALTIVEC
1188 rs6000_init_hard_regno_mode_ok ();
1190 set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
1191 #ifdef OS_MISSING_POWERPC64
1192 if (OS_MISSING_POWERPC64)
1193 set_masks &= ~MASK_POWERPC64;
1195 #ifdef OS_MISSING_ALTIVEC
1196 if (OS_MISSING_ALTIVEC)
1197 set_masks &= ~MASK_ALTIVEC;
1200 /* Don't override by the processor default if given explicitly. */
1201 set_masks &= ~target_flags_explicit;
1203 /* Identify the processor type. */
1204 rs6000_select[0].string = default_cpu;
1205 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
1207 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1209 ptr = &rs6000_select[i];
1210 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1212 for (j = 0; j < ptt_size; j++)
1213 if (! strcmp (ptr->string, processor_target_table[j].name))
1215 if (ptr->set_tune_p)
1216 rs6000_cpu = processor_target_table[j].processor;
1218 if (ptr->set_arch_p)
1220 target_flags &= ~set_masks;
1221 target_flags |= (processor_target_table[j].target_enable
1228 error ("bad value (%s) for %s switch", ptr->string, ptr->name);
1235 /* If we are optimizing big endian systems for space, use the load/store
1236 multiple and string instructions. */
1237 if (BYTES_BIG_ENDIAN && optimize_size)
1238 target_flags |= ~target_flags_explicit & (MASK_MULTIPLE | MASK_STRING);
1240 /* Don't allow -mmultiple or -mstring on little endian systems
1241 unless the cpu is a 750, because the hardware doesn't support the
1242 instructions used in little endian mode, and causes an alignment
1243 trap. The 750 does not cause an alignment trap (except when the
1244 target is unaligned). */
1246 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750)
1248 if (TARGET_MULTIPLE)
1250 target_flags &= ~MASK_MULTIPLE;
1251 if ((target_flags_explicit & MASK_MULTIPLE) != 0)
1252 warning ("-mmultiple is not supported on little endian systems");
1257 target_flags &= ~MASK_STRING;
1258 if ((target_flags_explicit & MASK_STRING) != 0)
1259 warning ("-mstring is not supported on little endian systems");
1263 /* Set debug flags */
1264 if (rs6000_debug_name)
1266 if (! strcmp (rs6000_debug_name, "all"))
1267 rs6000_debug_stack = rs6000_debug_arg = 1;
1268 else if (! strcmp (rs6000_debug_name, "stack"))
1269 rs6000_debug_stack = 1;
1270 else if (! strcmp (rs6000_debug_name, "arg"))
1271 rs6000_debug_arg = 1;
1273 error ("unknown -mdebug-%s switch", rs6000_debug_name);
1276 if (rs6000_traceback_name)
1278 if (! strncmp (rs6000_traceback_name, "full", 4))
1279 rs6000_traceback = traceback_full;
1280 else if (! strncmp (rs6000_traceback_name, "part", 4))
1281 rs6000_traceback = traceback_part;
1282 else if (! strncmp (rs6000_traceback_name, "no", 2))
1283 rs6000_traceback = traceback_none;
1285 error ("unknown -mtraceback arg %qs; expecting %<full%>, %<partial%> or %<none%>",
1286 rs6000_traceback_name);
1289 /* Set size of long double */
1290 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1291 if (rs6000_long_double_size_string)
1294 int size = strtol (rs6000_long_double_size_string, &tail, 10);
1295 if (*tail != '\0' || (size != 64 && size != 128))
1296 error ("Unknown switch -mlong-double-%s",
1297 rs6000_long_double_size_string);
1299 rs6000_long_double_type_size = size;
1302 /* Set Altivec ABI as default for powerpc64 linux. */
1303 if (TARGET_ELF && TARGET_64BIT)
1305 rs6000_altivec_abi = 1;
1306 rs6000_altivec_vrsave = 1;
1309 /* Set the Darwin64 ABI as default for 64-bit Darwin. */
1310 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1312 rs6000_darwin64_abi = 1;
1313 /* Setting to empty string is same as "-mone-byte-bool". */
1315 darwin_one_byte_bool = "";
1317 /* Default to natural alignment, for better performance. */
1318 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1321 /* Handle -mabi= options. */
1322 rs6000_parse_abi_options ();
1324 /* Handle -malign-XXXXX option. */
1325 rs6000_parse_alignment_option ();
1327 rs6000_parse_float_gprs_option ();
1329 /* Handle generic -mFOO=YES/NO options. */
1330 rs6000_parse_yes_no_option ("vrsave", rs6000_altivec_vrsave_string,
1331 &rs6000_altivec_vrsave);
1332 rs6000_parse_yes_no_option ("isel", rs6000_isel_string,
1334 rs6000_parse_yes_no_option ("spe", rs6000_spe_string, &rs6000_spe);
1336 /* Handle -mtls-size option. */
1337 rs6000_parse_tls_size_option ();
1339 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1340 SUBTARGET_OVERRIDE_OPTIONS;
1342 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1343 SUBSUBTARGET_OVERRIDE_OPTIONS;
1345 #ifdef SUB3TARGET_OVERRIDE_OPTIONS
1346 SUB3TARGET_OVERRIDE_OPTIONS;
1352 error ("AltiVec and E500 instructions cannot coexist");
1354 /* The e500 does not have string instructions, and we set
1355 MASK_STRING above when optimizing for size. */
1356 if ((target_flags & MASK_STRING) != 0)
1357 target_flags = target_flags & ~MASK_STRING;
1359 /* No SPE means 64-bit long doubles, even if an E500. */
1360 if (rs6000_spe_string != 0
1361 && !strcmp (rs6000_spe_string, "no"))
1362 rs6000_long_double_type_size = 64;
1364 else if (rs6000_select[1].string != NULL)
1366 /* For the powerpc-eabispe configuration, we set all these by
1367 default, so let's unset them if we manually set another
1368 CPU that is not the E500. */
1369 if (rs6000_abi_string == 0)
1371 if (rs6000_spe_string == 0)
1373 if (rs6000_float_gprs_string == 0)
1374 rs6000_float_gprs = 0;
1375 if (rs6000_isel_string == 0)
1377 if (rs6000_long_double_size_string == 0)
1378 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
1381 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
1382 && rs6000_cpu != PROCESSOR_POWER5);
1383 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
1384 || rs6000_cpu == PROCESSOR_POWER5);
1386 /* Handle -m(no-)longcall option. This is a bit of a cheap hack,
1387 using TARGET_OPTIONS to handle a toggle switch, but we're out of
1388 bits in target_flags so TARGET_SWITCHES cannot be used.
1389 Assumption here is that rs6000_longcall_switch points into the
1390 text of the complete option, rather than being a copy, so we can
1391 scan back for the presence or absence of the no- modifier. */
1392 if (rs6000_longcall_switch)
1394 const char *base = rs6000_longcall_switch;
1395 while (base[-1] != 'm') base--;
1397 if (*rs6000_longcall_switch != '\0')
1398 error ("invalid option %qs", base);
1399 rs6000_default_long_calls = (base[0] != 'n');
1402 /* Handle -m(no-)warn-altivec-long similarly. */
1403 if (rs6000_warn_altivec_long_switch)
1405 const char *base = rs6000_warn_altivec_long_switch;
1406 while (base[-1] != 'm') base--;
1408 if (*rs6000_warn_altivec_long_switch != '\0')
1409 error ("invalid option %qs", base);
1410 rs6000_warn_altivec_long = (base[0] != 'n');
1413 /* Handle -mprioritize-restricted-insns option. */
1414 rs6000_sched_restricted_insns_priority
1415 = (rs6000_sched_groups ? 1 : 0);
1416 if (rs6000_sched_restricted_insns_priority_str)
1417 rs6000_sched_restricted_insns_priority =
1418 atoi (rs6000_sched_restricted_insns_priority_str);
1420 /* Handle -msched-costly-dep option. */
1421 rs6000_sched_costly_dep
1422 = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
1423 if (rs6000_sched_costly_dep_str)
1425 if (! strcmp (rs6000_sched_costly_dep_str, "no"))
1426 rs6000_sched_costly_dep = no_dep_costly;
1427 else if (! strcmp (rs6000_sched_costly_dep_str, "all"))
1428 rs6000_sched_costly_dep = all_deps_costly;
1429 else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load"))
1430 rs6000_sched_costly_dep = true_store_to_load_dep_costly;
1431 else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load"))
1432 rs6000_sched_costly_dep = store_to_load_dep_costly;
1434 rs6000_sched_costly_dep = atoi (rs6000_sched_costly_dep_str);
1437 /* Handle -minsert-sched-nops option. */
1438 rs6000_sched_insert_nops
1439 = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
1440 if (rs6000_sched_insert_nops_str)
1442 if (! strcmp (rs6000_sched_insert_nops_str, "no"))
1443 rs6000_sched_insert_nops = sched_finish_none;
1444 else if (! strcmp (rs6000_sched_insert_nops_str, "pad"))
1445 rs6000_sched_insert_nops = sched_finish_pad_groups;
1446 else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact"))
1447 rs6000_sched_insert_nops = sched_finish_regroup_exact;
1449 rs6000_sched_insert_nops = atoi (rs6000_sched_insert_nops_str);
1452 #ifdef TARGET_REGNAMES
1453 /* If the user desires alternate register names, copy in the
1454 alternate names now. */
1455 if (TARGET_REGNAMES)
1456 memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names));
1459 /* Set TARGET_AIX_STRUCT_RET last, after the ABI is determined.
1460 If -maix-struct-return or -msvr4-struct-return was explicitly
1461 used, don't override with the ABI default. */
1462 if ((target_flags_explicit & MASK_AIX_STRUCT_RET) == 0)
1464 if (DEFAULT_ABI == ABI_V4 && !DRAFT_V4_STRUCT_RET)
1465 target_flags = (target_flags & ~MASK_AIX_STRUCT_RET);
1467 target_flags |= MASK_AIX_STRUCT_RET;
1470 if (TARGET_LONG_DOUBLE_128
1471 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN))
1472 REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
1474 /* Allocate an alias set for register saves & restores from stack. */
1475 rs6000_sr_alias_set = new_alias_set ();
1478 ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1);
1480 /* We can only guarantee the availability of DI pseudo-ops when
1481 assembling for 64-bit targets. */
1484 targetm.asm_out.aligned_op.di = NULL;
1485 targetm.asm_out.unaligned_op.di = NULL;
1488 /* Set branch target alignment, if not optimizing for size. */
1491 if (rs6000_sched_groups)
1493 if (align_functions <= 0)
1494 align_functions = 16;
1495 if (align_jumps <= 0)
1497 if (align_loops <= 0)
1500 if (align_jumps_max_skip <= 0)
1501 align_jumps_max_skip = 15;
1502 if (align_loops_max_skip <= 0)
1503 align_loops_max_skip = 15;
1506 /* Arrange to save and restore machine status around nested functions. */
1507 init_machine_status = rs6000_init_machine_status;
1509 /* We should always be splitting complex arguments, but we can't break
1510 Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */
1511 if (DEFAULT_ABI != ABI_AIX)
1512 targetm.calls.split_complex_arg = NULL;
1514 /* Initialize rs6000_cost with the appropriate target costs. */
1516 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
1520 case PROCESSOR_RIOS1:
1521 rs6000_cost = &rios1_cost;
1524 case PROCESSOR_RIOS2:
1525 rs6000_cost = &rios2_cost;
1528 case PROCESSOR_RS64A:
1529 rs6000_cost = &rs64a_cost;
1532 case PROCESSOR_MPCCORE:
1533 rs6000_cost = &mpccore_cost;
1536 case PROCESSOR_PPC403:
1537 rs6000_cost = &ppc403_cost;
1540 case PROCESSOR_PPC405:
1541 rs6000_cost = &ppc405_cost;
1544 case PROCESSOR_PPC440:
1545 rs6000_cost = &ppc440_cost;
1548 case PROCESSOR_PPC601:
1549 rs6000_cost = &ppc601_cost;
1552 case PROCESSOR_PPC603:
1553 rs6000_cost = &ppc603_cost;
1556 case PROCESSOR_PPC604:
1557 rs6000_cost = &ppc604_cost;
1560 case PROCESSOR_PPC604e:
1561 rs6000_cost = &ppc604e_cost;
1564 case PROCESSOR_PPC620:
1565 rs6000_cost = &ppc620_cost;
1568 case PROCESSOR_PPC630:
1569 rs6000_cost = &ppc630_cost;
1572 case PROCESSOR_PPC750:
1573 case PROCESSOR_PPC7400:
1574 rs6000_cost = &ppc750_cost;
1577 case PROCESSOR_PPC7450:
1578 rs6000_cost = &ppc7450_cost;
1581 case PROCESSOR_PPC8540:
1582 rs6000_cost = &ppc8540_cost;
1585 case PROCESSOR_POWER4:
1586 case PROCESSOR_POWER5:
1587 rs6000_cost = &power4_cost;
1595 /* Implement targetm.vectorize.builtin_mask_for_load. */
1597 rs6000_builtin_mask_for_load (void)
1600 return altivec_builtin_mask_for_load;
1605 /* Handle generic options of the form -mfoo=yes/no.
1606 NAME is the option name.
1607 VALUE is the option value.
1608 FLAG is the pointer to the flag where to store a 1 or 0, depending on
1609 whether the option value is 'yes' or 'no' respectively. */
1611 rs6000_parse_yes_no_option (const char *name, const char *value, int *flag)
1615 else if (!strcmp (value, "yes"))
1617 else if (!strcmp (value, "no"))
1620 error ("unknown -m%s= option specified: '%s'", name, value);
1623 /* Handle -mabi= options. */
1625 rs6000_parse_abi_options (void)
1627 if (rs6000_abi_string == 0)
1629 else if (! strcmp (rs6000_abi_string, "altivec"))
1631 rs6000_altivec_abi = 1;
1634 else if (! strcmp (rs6000_abi_string, "no-altivec"))
1635 rs6000_altivec_abi = 0;
1636 else if (! strcmp (rs6000_abi_string, "spe"))
1639 rs6000_altivec_abi = 0;
1640 if (!TARGET_SPE_ABI)
1641 error ("not configured for ABI: '%s'", rs6000_abi_string);
1644 /* These are here for testing during development only, do not
1645 document in the manual please. */
1646 else if (! strcmp (rs6000_abi_string, "d64"))
1648 rs6000_darwin64_abi = 1;
1649 warning ("Using darwin64 ABI");
1651 else if (! strcmp (rs6000_abi_string, "d32"))
1653 rs6000_darwin64_abi = 0;
1654 warning ("Using old darwin ABI");
1657 else if (! strcmp (rs6000_abi_string, "no-spe"))
1660 error ("unknown ABI specified: '%s'", rs6000_abi_string);
1663 /* Handle -mfloat-gprs= options. */
1665 rs6000_parse_float_gprs_option (void)
1667 if (rs6000_float_gprs_string == 0)
1669 else if (! strcmp (rs6000_float_gprs_string, "yes")
1670 || ! strcmp (rs6000_float_gprs_string, "single"))
1671 rs6000_float_gprs = 1;
1672 else if (! strcmp (rs6000_float_gprs_string, "double"))
1673 rs6000_float_gprs = 2;
1674 else if (! strcmp (rs6000_float_gprs_string, "no"))
1675 rs6000_float_gprs = 0;
1677 error ("invalid option for -mfloat-gprs");
1680 /* Handle -malign-XXXXXX options. */
1682 rs6000_parse_alignment_option (void)
1684 if (rs6000_alignment_string == 0)
1686 else if (! strcmp (rs6000_alignment_string, "power"))
1688 /* On 64-bit Darwin, power alignment is ABI-incompatible with
1689 some C library functions, so warn about it. The flag may be
1690 useful for performance studies from time to time though, so
1691 don't disable it entirely. */
1692 if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
1693 warning ("-malign-power is not supported for 64-bit Darwin;"
1694 " it is incompatible with the installed C and C++ libraries");
1695 rs6000_alignment_flags = MASK_ALIGN_POWER;
1697 else if (! strcmp (rs6000_alignment_string, "natural"))
1698 rs6000_alignment_flags = MASK_ALIGN_NATURAL;
1700 error ("unknown -malign-XXXXX option specified: '%s'",
1701 rs6000_alignment_string);
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)
1726 /* Do anything needed at the start of the asm file. */
1729 rs6000_file_start (void)
1733 const char *start = buffer;
1734 struct rs6000_cpu_select *ptr;
1735 const char *default_cpu = TARGET_CPU_DEFAULT;
1736 FILE *file = asm_out_file;
1738 default_file_start ();
1740 #ifdef TARGET_BI_ARCH
1741 if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)
1745 if (flag_verbose_asm)
1747 sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
1748 rs6000_select[0].string = default_cpu;
1750 for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
1752 ptr = &rs6000_select[i];
1753 if (ptr->string != (char *)0 && ptr->string[0] != '\0')
1755 fprintf (file, "%s %s%s", start, ptr->name, ptr->string);
1760 #ifdef USING_ELFOS_H
1761 switch (rs6000_sdata)
1763 case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break;
1764 case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break;
1765 case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break;
1766 case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break;
1769 if (rs6000_sdata && g_switch_value)
1771 fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
1781 if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
1789 /* Return nonzero if this function is known to have a null epilogue. */
1792 direct_return (void)
1794 if (reload_completed)
1796 rs6000_stack_t *info = rs6000_stack_info ();
1798 if (info->first_gp_reg_save == 32
1799 && info->first_fp_reg_save == 64
1800 && info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
1801 && ! info->lr_save_p
1802 && ! info->cr_save_p
1803 && info->vrsave_mask == 0
1811 /* Return the number of instructions it takes to form a constant in an
1812 integer register. */
1815 num_insns_constant_wide (HOST_WIDE_INT value)
1817 /* signed constant loadable with {cal|addi} */
1818 if (CONST_OK_FOR_LETTER_P (value, 'I'))
1821 /* constant loadable with {cau|addis} */
1822 else if (CONST_OK_FOR_LETTER_P (value, 'L'))
1825 #if HOST_BITS_PER_WIDE_INT == 64
1826 else if (TARGET_POWERPC64)
1828 HOST_WIDE_INT low = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
1829 HOST_WIDE_INT high = value >> 31;
1831 if (high == 0 || high == -1)
1837 return num_insns_constant_wide (high) + 1;
1839 return (num_insns_constant_wide (high)
1840 + num_insns_constant_wide (low) + 1);
1849 num_insns_constant (rtx op, enum machine_mode mode)
1851 if (GET_CODE (op) == CONST_INT)
1853 #if HOST_BITS_PER_WIDE_INT == 64
1854 if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1
1855 && mask64_operand (op, mode))
1859 return num_insns_constant_wide (INTVAL (op));
1862 else if (GET_CODE (op) == CONST_DOUBLE && mode == SFmode)
1867 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1868 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
1869 return num_insns_constant_wide ((HOST_WIDE_INT) l);
1872 else if (GET_CODE (op) == CONST_DOUBLE)
1878 int endian = (WORDS_BIG_ENDIAN == 0);
1880 if (mode == VOIDmode || mode == DImode)
1882 high = CONST_DOUBLE_HIGH (op);
1883 low = CONST_DOUBLE_LOW (op);
1887 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1888 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
1890 low = l[1 - endian];
1894 return (num_insns_constant_wide (low)
1895 + num_insns_constant_wide (high));
1899 if (high == 0 && low >= 0)
1900 return num_insns_constant_wide (low);
1902 else if (high == -1 && low < 0)
1903 return num_insns_constant_wide (low);
1905 else if (mask64_operand (op, mode))
1909 return num_insns_constant_wide (high) + 1;
1912 return (num_insns_constant_wide (high)
1913 + num_insns_constant_wide (low) + 1);
1921 /* Returns the constant for the splat instruction, if exists. */
1924 easy_vector_splat_const (int cst, enum machine_mode mode)
1929 if (EASY_VECTOR_15 (cst)
1930 || EASY_VECTOR_15_ADD_SELF (cst))
1932 if ((cst & 0xffff) != ((cst >> 16) & 0xffff))
1938 if (EASY_VECTOR_15 (cst)
1939 || EASY_VECTOR_15_ADD_SELF (cst))
1941 if ((cst & 0xff) != ((cst >> 8) & 0xff))
1947 if (EASY_VECTOR_15 (cst)
1948 || EASY_VECTOR_15_ADD_SELF (cst))
1956 /* Return nonzero if all elements of a vector have the same value. */
1959 easy_vector_same (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
1963 units = CONST_VECTOR_NUNITS (op);
1965 cst = INTVAL (CONST_VECTOR_ELT (op, 0));
1966 for (i = 1; i < units; ++i)
1967 if (INTVAL (CONST_VECTOR_ELT (op, i)) != cst)
1969 if (i == units && easy_vector_splat_const (cst, mode))
1974 /* Generate easy_vector_constant out of a easy_vector_constant_add_self. */
1977 gen_easy_vector_constant_add_self (rtx op)
1981 units = GET_MODE_NUNITS (GET_MODE (op));
1982 v = rtvec_alloc (units);
1984 for (i = 0; i < units; i++)
1986 GEN_INT (INTVAL (CONST_VECTOR_ELT (op, i)) >> 1);
1987 return gen_rtx_raw_CONST_VECTOR (GET_MODE (op), v);
1991 output_vec_const_move (rtx *operands)
1994 enum machine_mode mode;
2000 cst = INTVAL (CONST_VECTOR_ELT (vec, 0));
2001 cst2 = INTVAL (CONST_VECTOR_ELT (vec, 1));
2002 mode = GET_MODE (dest);
2006 if (zero_constant (vec, mode))
2007 return "vxor %0,%0,%0";
2008 else if (easy_vector_constant (vec, mode))
2010 operands[1] = GEN_INT (cst);
2014 if (EASY_VECTOR_15 (cst))
2016 operands[1] = GEN_INT (cst);
2017 return "vspltisw %0,%1";
2019 else if (EASY_VECTOR_15_ADD_SELF (cst))
2025 if (EASY_VECTOR_15 (cst))
2027 operands[1] = GEN_INT (cst);
2028 return "vspltish %0,%1";
2030 else if (EASY_VECTOR_15_ADD_SELF (cst))
2036 if (EASY_VECTOR_15 (cst))
2038 operands[1] = GEN_INT (cst);
2039 return "vspltisb %0,%1";
2041 else if (EASY_VECTOR_15_ADD_SELF (cst))
2054 /* Vector constant 0 is handled as a splitter of V2SI, and in the
2055 pattern of V1DI, V4HI, and V2SF.
2057 FIXME: We should probably return # and add post reload
2058 splitters for these, but this way is so easy ;-). */
2059 operands[1] = GEN_INT (cst);
2060 operands[2] = GEN_INT (cst2);
2062 return "li %0,%1\n\tevmergelo %0,%0,%0";
2064 return "li %0,%1\n\tevmergelo %0,%0,%0\n\tli %0,%2";
2071 mask64_1or2_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED,
2074 if (GET_CODE (op) == CONST_INT)
2076 HOST_WIDE_INT c, lsb;
2081 /* Disallow all zeros. */
2085 /* We can use a single rlwinm insn if no upper bits of C are set
2086 AND there are zero, one or two transitions in the _whole_ of
2088 one_ok = !(c & ~(HOST_WIDE_INT)0xffffffff);
2090 /* We don't change the number of transitions by inverting,
2091 so make sure we start with the LS bit zero. */
2095 /* Find the first transition. */
2098 /* Invert to look for a second transition. */
2101 /* Erase first transition. */
2104 /* Find the second transition. */
2107 /* Invert to look for a third transition. */
2110 /* Erase second transition. */
2113 if (one_ok && !(allow_one || c))
2116 /* Find the third transition (if any). */
2119 /* Match if all the bits above are 1's (or c is zero). */
2125 /* Generates shifts and masks for a pair of rldicl or rldicr insns to
2126 implement ANDing by the mask IN. */
2128 build_mask64_2_operands (rtx in, rtx *out)
2130 #if HOST_BITS_PER_WIDE_INT >= 64
2131 unsigned HOST_WIDE_INT c, lsb, m1, m2;
2134 if (GET_CODE (in) != CONST_INT)
2140 /* Assume c initially something like 0x00fff000000fffff. The idea
2141 is to rotate the word so that the middle ^^^^^^ group of zeros
2142 is at the MS end and can be cleared with an rldicl mask. We then
2143 rotate back and clear off the MS ^^ group of zeros with a
2145 c = ~c; /* c == 0xff000ffffff00000 */
2146 lsb = c & -c; /* lsb == 0x0000000000100000 */
2147 m1 = -lsb; /* m1 == 0xfffffffffff00000 */
2148 c = ~c; /* c == 0x00fff000000fffff */
2149 c &= -lsb; /* c == 0x00fff00000000000 */
2150 lsb = c & -c; /* lsb == 0x0000100000000000 */
2151 c = ~c; /* c == 0xff000fffffffffff */
2152 c &= -lsb; /* c == 0xff00000000000000 */
2154 while ((lsb >>= 1) != 0)
2155 shift++; /* shift == 44 on exit from loop */
2156 m1 <<= 64 - shift; /* m1 == 0xffffff0000000000 */
2157 m1 = ~m1; /* m1 == 0x000000ffffffffff */
2158 m2 = ~c; /* m2 == 0x00ffffffffffffff */
2162 /* Assume c initially something like 0xff000f0000000000. The idea
2163 is to rotate the word so that the ^^^ middle group of zeros
2164 is at the LS end and can be cleared with an rldicr mask. We then
2165 rotate back and clear off the LS group of ^^^^^^^^^^ zeros with
2167 lsb = c & -c; /* lsb == 0x0000010000000000 */
2168 m2 = -lsb; /* m2 == 0xffffff0000000000 */
2169 c = ~c; /* c == 0x00fff0ffffffffff */
2170 c &= -lsb; /* c == 0x00fff00000000000 */
2171 lsb = c & -c; /* lsb == 0x0000100000000000 */
2172 c = ~c; /* c == 0xff000fffffffffff */
2173 c &= -lsb; /* c == 0xff00000000000000 */
2175 while ((lsb >>= 1) != 0)
2176 shift++; /* shift == 44 on exit from loop */
2177 m1 = ~c; /* m1 == 0x00ffffffffffffff */
2178 m1 >>= shift; /* m1 == 0x0000000000000fff */
2179 m1 = ~m1; /* m1 == 0xfffffffffffff000 */
2182 /* Note that when we only have two 0->1 and 1->0 transitions, one of the
2183 masks will be all 1's. We are guaranteed more than one transition. */
2184 out[0] = GEN_INT (64 - shift);
2185 out[1] = GEN_INT (m1);
2186 out[2] = GEN_INT (shift);
2187 out[3] = GEN_INT (m2);
2195 /* Return TRUE if OP is an invalid SUBREG operation on the e500. */
2198 invalid_e500_subreg (rtx op, enum machine_mode mode)
2200 /* Reject (subreg:SI (reg:DF)). */
2201 if (GET_CODE (op) == SUBREG
2203 && REG_P (SUBREG_REG (op))
2204 && GET_MODE (SUBREG_REG (op)) == DFmode)
2207 /* Reject (subreg:DF (reg:DI)). */
2208 if (GET_CODE (op) == SUBREG
2210 && REG_P (SUBREG_REG (op))
2211 && GET_MODE (SUBREG_REG (op)) == DImode)
2217 /* Darwin, AIX increases natural record alignment to doubleword if the first
2218 field is an FP double while the FP fields remain word aligned. */
2221 rs6000_special_round_type_align (tree type, int computed, int specified)
2223 tree field = TYPE_FIELDS (type);
2225 /* Skip all non field decls */
2226 while (field != NULL && TREE_CODE (field) != FIELD_DECL)
2227 field = TREE_CHAIN (field);
2229 if (field == NULL || field == type || DECL_MODE (field) != DFmode)
2230 return MAX (computed, specified);
2232 return MAX (MAX (computed, specified), 64);
2235 /* Return 1 for an operand in small memory on V.4/eabi. */
2238 small_data_operand (rtx op ATTRIBUTE_UNUSED,
2239 enum machine_mode mode ATTRIBUTE_UNUSED)
2244 if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA)
2247 if (DEFAULT_ABI != ABI_V4)
2250 if (GET_CODE (op) == SYMBOL_REF)
2253 else if (GET_CODE (op) != CONST
2254 || GET_CODE (XEXP (op, 0)) != PLUS
2255 || GET_CODE (XEXP (XEXP (op, 0), 0)) != SYMBOL_REF
2256 || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT)
2261 rtx sum = XEXP (op, 0);
2262 HOST_WIDE_INT summand;
2264 /* We have to be careful here, because it is the referenced address
2265 that must be 32k from _SDA_BASE_, not just the symbol. */
2266 summand = INTVAL (XEXP (sum, 1));
2267 if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
2270 sym_ref = XEXP (sum, 0);
2273 return SYMBOL_REF_SMALL_P (sym_ref);
2279 /* Return true, if operand is a memory operand and has a
2280 displacement divisible by 4. */
2283 word_offset_memref_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
2288 if (!memory_operand (op, mode))
2291 addr = XEXP (op, 0);
2292 if (GET_CODE (addr) == PLUS
2293 && GET_CODE (XEXP (addr, 0)) == REG
2294 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2295 off = INTVAL (XEXP (addr, 1));
2297 return (off % 4) == 0;
2300 /* Return true if the operand is an indirect or indexed memory operand. */
2303 indexed_or_indirect_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
2306 if (!memory_operand (op, mode))
2309 addr = XEXP (op, 0);
2310 if (GET_CODE (addr) == REG)
2312 if (GET_CODE (addr) == PLUS
2313 && GET_CODE (XEXP (addr, 0)) == REG
2314 && GET_CODE (XEXP (addr, 1)) == REG)
2319 /* Return true if either operand is a general purpose register. */
2322 gpr_or_gpr_p (rtx op0, rtx op1)
2324 return ((REG_P (op0) && INT_REGNO_P (REGNO (op0)))
2325 || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
2329 /* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
2332 constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
2334 switch (GET_CODE (op))
2337 if (RS6000_SYMBOL_REF_TLS_P (op))
2339 else if (CONSTANT_POOL_ADDRESS_P (op))
2341 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
2349 else if (! strcmp (XSTR (op, 0), toc_label_name))
2358 return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
2359 && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
2361 return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
2370 constant_pool_expr_p (rtx op)
2374 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
2378 toc_relative_expr_p (rtx op)
2382 return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
2386 legitimate_constant_pool_address_p (rtx x)
2389 && GET_CODE (x) == PLUS
2390 && GET_CODE (XEXP (x, 0)) == REG
2391 && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
2392 && constant_pool_expr_p (XEXP (x, 1)));
2396 legitimate_small_data_p (enum machine_mode mode, rtx x)
2398 return (DEFAULT_ABI == ABI_V4
2399 && !flag_pic && !TARGET_TOC
2400 && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)
2401 && small_data_operand (x, mode));
2404 /* SPE offset addressing is limited to 5-bits worth of double words. */
2405 #define SPE_CONST_OFFSET_OK(x) (((x) & ~0xf8) == 0)
2408 rs6000_legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
2410 unsigned HOST_WIDE_INT offset, extra;
2412 if (GET_CODE (x) != PLUS)
2414 if (GET_CODE (XEXP (x, 0)) != REG)
2416 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
2418 if (legitimate_constant_pool_address_p (x))
2420 if (GET_CODE (XEXP (x, 1)) != CONST_INT)
2423 offset = INTVAL (XEXP (x, 1));
2431 /* AltiVec vector modes. Only reg+reg addressing is valid here,
2432 which leaves the only valid constant offset of zero, which by
2433 canonicalization rules is also invalid. */
2440 /* SPE vector modes. */
2441 return SPE_CONST_OFFSET_OK (offset);
2444 if (TARGET_E500_DOUBLE)
2445 return SPE_CONST_OFFSET_OK (offset);
2448 /* On e500v2, we may have:
2450 (subreg:DF (mem:DI (plus (reg) (const_int))) 0).
2452 Which gets addressed with evldd instructions. */
2453 if (TARGET_E500_DOUBLE)
2454 return SPE_CONST_OFFSET_OK (offset);
2456 if (mode == DFmode || !TARGET_POWERPC64)
2458 else if (offset & 3)
2464 if (mode == TFmode || !TARGET_POWERPC64)
2466 else if (offset & 3)
2477 return (offset < 0x10000) && (offset + extra < 0x10000);
2481 legitimate_indexed_address_p (rtx x, int strict)
2485 if (GET_CODE (x) != PLUS)
2491 if (!REG_P (op0) || !REG_P (op1))
2494 return ((INT_REG_OK_FOR_BASE_P (op0, strict)
2495 && INT_REG_OK_FOR_INDEX_P (op1, strict))
2496 || (INT_REG_OK_FOR_BASE_P (op1, strict)
2497 && INT_REG_OK_FOR_INDEX_P (op0, strict)));
2501 legitimate_indirect_address_p (rtx x, int strict)
2503 return GET_CODE (x) == REG && INT_REG_OK_FOR_BASE_P (x, strict);
2507 macho_lo_sum_memory_operand (rtx x, enum machine_mode mode)
2509 if (!TARGET_MACHO || !flag_pic
2510 || mode != SImode || GET_CODE (x) != MEM)
2514 if (GET_CODE (x) != LO_SUM)
2516 if (GET_CODE (XEXP (x, 0)) != REG)
2518 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0))
2522 return CONSTANT_P (x);
2526 legitimate_lo_sum_address_p (enum machine_mode mode, rtx x, int strict)
2528 if (GET_CODE (x) != LO_SUM)
2530 if (GET_CODE (XEXP (x, 0)) != REG)
2532 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
2534 /* Restrict addressing for DI because of our SUBREG hackery. */
2535 if (TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
2539 if (TARGET_ELF || TARGET_MACHO)
2541 if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
2545 if (GET_MODE_NUNITS (mode) != 1)
2547 if (GET_MODE_BITSIZE (mode) > 64
2548 || (GET_MODE_BITSIZE (mode) > 32 && !TARGET_POWERPC64
2549 && !(TARGET_HARD_FLOAT && TARGET_FPRS && mode == DFmode)))
2552 return CONSTANT_P (x);
2559 /* Try machine-dependent ways of modifying an illegitimate address
2560 to be legitimate. If we find one, return the new, valid address.
2561 This is used from only one place: `memory_address' in explow.c.
2563 OLDX is the address as it was before break_out_memory_refs was
2564 called. In some cases it is useful to look at this to decide what
2567 MODE is passed so that this function can use GO_IF_LEGITIMATE_ADDRESS.
2569 It is always safe for this function to do nothing. It exists to
2570 recognize opportunities to optimize the output.
2572 On RS/6000, first check for the sum of a register with a constant
2573 integer that is out of range. If so, generate code to add the
2574 constant with the low-order 16 bits masked to the register and force
2575 this result into another register (this can be done with `cau').
2576 Then generate an address of REG+(CONST&0xffff), allowing for the
2577 possibility of bit 16 being a one.
2579 Then check for the sum of a register and something not constant, try to
2580 load the other things into a register and return the sum. */
2583 rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
2584 enum machine_mode mode)
2586 if (GET_CODE (x) == SYMBOL_REF)
2588 enum tls_model model = SYMBOL_REF_TLS_MODEL (x);
2590 return rs6000_legitimize_tls_address (x, model);
2593 if (GET_CODE (x) == PLUS
2594 && GET_CODE (XEXP (x, 0)) == REG
2595 && GET_CODE (XEXP (x, 1)) == CONST_INT
2596 && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) >= 0x10000)
2598 HOST_WIDE_INT high_int, low_int;
2600 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
2601 high_int = INTVAL (XEXP (x, 1)) - low_int;
2602 sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0),
2603 GEN_INT (high_int)), 0);
2604 return gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));
2606 else if (GET_CODE (x) == PLUS
2607 && GET_CODE (XEXP (x, 0)) == REG
2608 && GET_CODE (XEXP (x, 1)) != CONST_INT
2609 && GET_MODE_NUNITS (mode) == 1
2610 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
2612 || (((mode != DImode && mode != DFmode) || TARGET_E500_DOUBLE)
2614 && (TARGET_POWERPC64 || mode != DImode)
2617 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
2618 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
2620 else if (ALTIVEC_VECTOR_MODE (mode))
2624 /* Make sure both operands are registers. */
2625 if (GET_CODE (x) == PLUS)
2626 return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)),
2627 force_reg (Pmode, XEXP (x, 1)));
2629 reg = force_reg (Pmode, x);
2632 else if (SPE_VECTOR_MODE (mode)
2633 || (TARGET_E500_DOUBLE && (mode == DFmode
2634 || mode == DImode)))
2638 /* We accept [reg + reg] and [reg + OFFSET]. */
2640 if (GET_CODE (x) == PLUS)
2642 rtx op1 = XEXP (x, 0);
2643 rtx op2 = XEXP (x, 1);
2645 op1 = force_reg (Pmode, op1);
2647 if (GET_CODE (op2) != REG
2648 && (GET_CODE (op2) != CONST_INT
2649 || !SPE_CONST_OFFSET_OK (INTVAL (op2))))
2650 op2 = force_reg (Pmode, op2);
2652 return gen_rtx_PLUS (Pmode, op1, op2);
2655 return force_reg (Pmode, x);
2661 && GET_CODE (x) != CONST_INT
2662 && GET_CODE (x) != CONST_DOUBLE
2664 && GET_MODE_NUNITS (mode) == 1
2665 && (GET_MODE_BITSIZE (mode) <= 32
2666 || ((TARGET_HARD_FLOAT && TARGET_FPRS) && mode == DFmode)))
2668 rtx reg = gen_reg_rtx (Pmode);
2669 emit_insn (gen_elf_high (reg, x));
2670 return gen_rtx_LO_SUM (Pmode, reg, x);
2672 else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
2675 && ! MACHO_DYNAMIC_NO_PIC_P
2677 && GET_CODE (x) != CONST_INT
2678 && GET_CODE (x) != CONST_DOUBLE
2680 && ((TARGET_HARD_FLOAT && TARGET_FPRS) || mode != DFmode)
2684 rtx reg = gen_reg_rtx (Pmode);
2685 emit_insn (gen_macho_high (reg, x));
2686 return gen_rtx_LO_SUM (Pmode, reg, x);
2689 && constant_pool_expr_p (x)
2690 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
2692 return create_TOC_reference (x);
2698 /* This is called from dwarf2out.c via ASM_OUTPUT_DWARF_DTPREL.
2699 We need to emit DTP-relative relocations. */
2702 rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
2707 fputs ("\t.long\t", file);
2710 fputs (DOUBLE_INT_ASM_OP, file);
2715 output_addr_const (file, x);
2716 fputs ("@dtprel+0x8000", file);
2719 /* Construct the SYMBOL_REF for the tls_get_addr function. */
2721 static GTY(()) rtx rs6000_tls_symbol;
2723 rs6000_tls_get_addr (void)
2725 if (!rs6000_tls_symbol)
2726 rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr");
2728 return rs6000_tls_symbol;
2731 /* Construct the SYMBOL_REF for TLS GOT references. */
2733 static GTY(()) rtx rs6000_got_symbol;
2735 rs6000_got_sym (void)
2737 if (!rs6000_got_symbol)
2739 rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
2740 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL;
2741 SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL;
2744 return rs6000_got_symbol;
2747 /* ADDR contains a thread-local SYMBOL_REF. Generate code to compute
2748 this (thread-local) address. */
2751 rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
2755 dest = gen_reg_rtx (Pmode);
2756 if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 16)
2762 tlsreg = gen_rtx_REG (Pmode, 13);
2763 insn = gen_tls_tprel_64 (dest, tlsreg, addr);
2767 tlsreg = gen_rtx_REG (Pmode, 2);
2768 insn = gen_tls_tprel_32 (dest, tlsreg, addr);
2772 else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32)
2776 tmp = gen_reg_rtx (Pmode);
2779 tlsreg = gen_rtx_REG (Pmode, 13);
2780 insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr);
2784 tlsreg = gen_rtx_REG (Pmode, 2);
2785 insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr);
2789 insn = gen_tls_tprel_lo_64 (dest, tmp, addr);
2791 insn = gen_tls_tprel_lo_32 (dest, tmp, addr);
2796 rtx r3, got, tga, tmp1, tmp2, eqv;
2799 got = gen_rtx_REG (Pmode, TOC_REGISTER);
2803 got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
2806 rtx gsym = rs6000_got_sym ();
2807 got = gen_reg_rtx (Pmode);
2809 rs6000_emit_move (got, gsym, Pmode);
2813 static int tls_got_labelno = 0;
2814 rtx tempLR, lab, tmp3, mem;
2817 ASM_GENERATE_INTERNAL_LABEL (buf, "LTLS", tls_got_labelno++);
2818 lab = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
2819 tempLR = gen_reg_rtx (Pmode);
2820 tmp1 = gen_reg_rtx (Pmode);
2821 tmp2 = gen_reg_rtx (Pmode);
2822 tmp3 = gen_reg_rtx (Pmode);
2823 mem = gen_const_mem (Pmode, tmp1);
2825 first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, lab,
2827 emit_move_insn (tmp1, tempLR);
2828 emit_move_insn (tmp2, mem);
2829 emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
2830 last = emit_move_insn (got, tmp3);
2831 REG_NOTES (last) = gen_rtx_EXPR_LIST (REG_EQUAL, gsym,
2833 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
2835 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
2841 if (model == TLS_MODEL_GLOBAL_DYNAMIC)
2843 r3 = gen_rtx_REG (Pmode, 3);
2845 insn = gen_tls_gd_64 (r3, got, addr);
2847 insn = gen_tls_gd_32 (r3, got, addr);
2850 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
2851 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
2852 insn = emit_call_insn (insn);
2853 CONST_OR_PURE_CALL_P (insn) = 1;
2854 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
2855 insn = get_insns ();
2857 emit_libcall_block (insn, dest, r3, addr);
2859 else if (model == TLS_MODEL_LOCAL_DYNAMIC)
2861 r3 = gen_rtx_REG (Pmode, 3);
2863 insn = gen_tls_ld_64 (r3, got);
2865 insn = gen_tls_ld_32 (r3, got);
2868 tga = gen_rtx_MEM (Pmode, rs6000_tls_get_addr ());
2869 insn = gen_call_value (r3, tga, const0_rtx, const0_rtx);
2870 insn = emit_call_insn (insn);
2871 CONST_OR_PURE_CALL_P (insn) = 1;
2872 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r3);
2873 insn = get_insns ();
2875 tmp1 = gen_reg_rtx (Pmode);
2876 eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
2878 emit_libcall_block (insn, tmp1, r3, eqv);
2879 if (rs6000_tls_size == 16)
2882 insn = gen_tls_dtprel_64 (dest, tmp1, addr);
2884 insn = gen_tls_dtprel_32 (dest, tmp1, addr);
2886 else if (rs6000_tls_size == 32)
2888 tmp2 = gen_reg_rtx (Pmode);
2890 insn = gen_tls_dtprel_ha_64 (tmp2, tmp1, addr);
2892 insn = gen_tls_dtprel_ha_32 (tmp2, tmp1, addr);
2895 insn = gen_tls_dtprel_lo_64 (dest, tmp2, addr);
2897 insn = gen_tls_dtprel_lo_32 (dest, tmp2, addr);
2901 tmp2 = gen_reg_rtx (Pmode);
2903 insn = gen_tls_got_dtprel_64 (tmp2, got, addr);
2905 insn = gen_tls_got_dtprel_32 (tmp2, got, addr);
2907 insn = gen_rtx_SET (Pmode, dest,
2908 gen_rtx_PLUS (Pmode, tmp2, tmp1));
2914 /* IE, or 64 bit offset LE. */
2915 tmp2 = gen_reg_rtx (Pmode);
2917 insn = gen_tls_got_tprel_64 (tmp2, got, addr);
2919 insn = gen_tls_got_tprel_32 (tmp2, got, addr);
2922 insn = gen_tls_tls_64 (dest, tmp2, addr);
2924 insn = gen_tls_tls_32 (dest, tmp2, addr);
2932 /* Return 1 if X contains a thread-local symbol. */
2935 rs6000_tls_referenced_p (rtx x)
2937 if (! TARGET_HAVE_TLS)
2940 return for_each_rtx (&x, &rs6000_tls_symbol_ref_1, 0);
2943 /* Return 1 if *X is a thread-local symbol. This is the same as
2944 rs6000_tls_symbol_ref except for the type of the unused argument. */
2947 rs6000_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
2949 return RS6000_SYMBOL_REF_TLS_P (*x);
2952 /* The convention appears to be to define this wherever it is used.
2953 With legitimize_reload_address now defined here, REG_MODE_OK_FOR_BASE_P
2954 is now used here. */
2955 #ifndef REG_MODE_OK_FOR_BASE_P
2956 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
2959 /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS. Returns a value to
2960 replace the input X, or the original X if no replacement is called for.
2961 The output parameter *WIN is 1 if the calling macro should goto WIN,
2964 For RS/6000, we wish to handle large displacements off a base
2965 register by splitting the addend across an addiu/addis and the mem insn.
2966 This cuts number of extra insns needed from 3 to 1.
2968 On Darwin, we use this to generate code for floating point constants.
2969 A movsf_low is generated so we wind up with 2 instructions rather than 3.
2970 The Darwin code is inside #if TARGET_MACHO because only then is
2971 machopic_function_base_name() defined. */
2973 rs6000_legitimize_reload_address (rtx x, enum machine_mode mode,
2974 int opnum, int type,
2975 int ind_levels ATTRIBUTE_UNUSED, int *win)
2977 /* We must recognize output that we have already generated ourselves. */
2978 if (GET_CODE (x) == PLUS
2979 && GET_CODE (XEXP (x, 0)) == PLUS
2980 && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
2981 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
2982 && GET_CODE (XEXP (x, 1)) == CONST_INT)
2984 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
2985 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
2986 opnum, (enum reload_type)type);
2992 if (DEFAULT_ABI == ABI_DARWIN && flag_pic
2993 && GET_CODE (x) == LO_SUM
2994 && GET_CODE (XEXP (x, 0)) == PLUS
2995 && XEXP (XEXP (x, 0), 0) == pic_offset_table_rtx
2996 && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH
2997 && GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 0)) == CONST
2998 && XEXP (XEXP (XEXP (x, 0), 1), 0) == XEXP (x, 1)
2999 && GET_CODE (XEXP (XEXP (x, 1), 0)) == MINUS
3000 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 0)) == SYMBOL_REF
3001 && GET_CODE (XEXP (XEXP (XEXP (x, 1), 0), 1)) == SYMBOL_REF)
3003 /* Result of previous invocation of this function on Darwin
3004 floating point constant. */
3005 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3006 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3007 opnum, (enum reload_type)type);
3013 /* Force ld/std non-word aligned offset into base register by wrapping
3015 if (GET_CODE (x) == PLUS
3016 && GET_CODE (XEXP (x, 0)) == REG
3017 && REGNO (XEXP (x, 0)) < 32
3018 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3019 && GET_CODE (XEXP (x, 1)) == CONST_INT
3020 && (INTVAL (XEXP (x, 1)) & 3) != 0
3021 && !ALTIVEC_VECTOR_MODE (mode)
3022 && GET_MODE_SIZE (mode) >= UNITS_PER_WORD
3023 && TARGET_POWERPC64)
3025 x = gen_rtx_PLUS (GET_MODE (x), x, GEN_INT (0));
3026 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3027 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3028 opnum, (enum reload_type) type);
3033 if (GET_CODE (x) == PLUS
3034 && GET_CODE (XEXP (x, 0)) == REG
3035 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
3036 && REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
3037 && GET_CODE (XEXP (x, 1)) == CONST_INT
3038 && !SPE_VECTOR_MODE (mode)
3039 && !(TARGET_E500_DOUBLE && (mode == DFmode
3041 && !ALTIVEC_VECTOR_MODE (mode))
3043 HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
3044 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
3046 = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;
3048 /* Check for 32-bit overflow. */
3049 if (high + low != val)
3055 /* Reload the high part into a base reg; leave the low part
3056 in the mem directly. */
3058 x = gen_rtx_PLUS (GET_MODE (x),
3059 gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
3063 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3064 BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
3065 opnum, (enum reload_type)type);
3071 if (GET_CODE (x) == SYMBOL_REF
3072 && DEFAULT_ABI == ABI_DARWIN
3073 && !ALTIVEC_VECTOR_MODE (mode)
3074 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
3075 /* Don't do this for TFmode, since the result isn't offsettable.
3076 The same goes for DImode without 64-bit gprs. */
3078 && (mode != DImode || TARGET_POWERPC64))
3082 rtx offset = gen_rtx_CONST (Pmode,
3083 gen_rtx_MINUS (Pmode, x,
3084 machopic_function_base_sym ()));
3085 x = gen_rtx_LO_SUM (GET_MODE (x),
3086 gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
3087 gen_rtx_HIGH (Pmode, offset)), offset);
3090 x = gen_rtx_LO_SUM (GET_MODE (x),
3091 gen_rtx_HIGH (Pmode, x), x);
3093 push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
3094 BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3095 opnum, (enum reload_type)type);
3102 && constant_pool_expr_p (x)
3103 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
3105 (x) = create_TOC_reference (x);
3113 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
3114 that is a valid memory address for an instruction.
3115 The MODE argument is the machine mode for the MEM expression
3116 that wants to use this address.
3118 On the RS/6000, there are four valid address: a SYMBOL_REF that
3119 refers to a constant pool entry of an address (or the sum of it
3120 plus a constant), a short (16-bit signed) constant plus a register,
3121 the sum of two registers, or a register indirect, possibly with an
3122 auto-increment. For DFmode and DImode with a constant plus register,
3123 we must ensure that both words are addressable or PowerPC64 with offset
3126 For modes spanning multiple registers (DFmode in 32-bit GPRs,
3127 32-bit DImode, TImode, TFmode), indexed addressing cannot be used because
3128 adjacent memory cells are accessed by adding word-sized offsets
3129 during assembly output. */
3131 rs6000_legitimate_address (enum machine_mode mode, rtx x, int reg_ok_strict)
3133 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */
3135 && ALTIVEC_VECTOR_MODE (mode)
3136 && GET_CODE (x) == AND
3137 && GET_CODE (XEXP (x, 1)) == CONST_INT
3138 && INTVAL (XEXP (x, 1)) == -16)
3141 if (RS6000_SYMBOL_REF_TLS_P (x))
3143 if (legitimate_indirect_address_p (x, reg_ok_strict))
3145 if ((GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
3146 && !ALTIVEC_VECTOR_MODE (mode)
3147 && !SPE_VECTOR_MODE (mode)
3148 /* Restrict addressing for DI because of our SUBREG hackery. */
3149 && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == DImode))
3151 && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict))
3153 if (legitimate_small_data_p (mode, x))
3155 if (legitimate_constant_pool_address_p (x))
3157 /* If not REG_OK_STRICT (before reload) let pass any stack offset. */
3159 && GET_CODE (x) == PLUS
3160 && GET_CODE (XEXP (x, 0)) == REG
3161 && (XEXP (x, 0) == virtual_stack_vars_rtx
3162 || XEXP (x, 0) == arg_pointer_rtx)
3163 && GET_CODE (XEXP (x, 1)) == CONST_INT)
3165 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict))
3169 && ((TARGET_HARD_FLOAT && TARGET_FPRS)
3171 || ((mode != DFmode || TARGET_E500_DOUBLE) && mode != TFmode))
3172 && (TARGET_POWERPC64 || mode != DImode)
3173 && legitimate_indexed_address_p (x, reg_ok_strict))
3175 if (legitimate_lo_sum_address_p (mode, x, reg_ok_strict))
3180 /* Go to LABEL if ADDR (a legitimate address expression)
3181 has an effect that depends on the machine mode it is used for.
3183 On the RS/6000 this is true of all integral offsets (since AltiVec
3184 modes don't allow them) or is a pre-increment or decrement.
3186 ??? Except that due to conceptual problems in offsettable_address_p
3187 we can't really report the problems of integral offsets. So leave
3188 this assuming that the adjustable offset must be valid for the
3189 sub-words of a TFmode operand, which is what we had before. */
3192 rs6000_mode_dependent_address (rtx addr)
3194 switch (GET_CODE (addr))
3197 if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
3199 unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
3200 return val + 12 + 0x8000 >= 0x10000;
3209 return TARGET_UPDATE;
3218 /* Return number of consecutive hard regs needed starting at reg REGNO
3219 to hold something of mode MODE.
3220 This is ordinarily the length in words of a value of mode MODE
3221 but can be less for certain modes in special long registers.
3223 For the SPE, GPRs are 64 bits but only 32 bits are visible in
3224 scalar instructions. The upper 32 bits are only available to the
3227 POWER and PowerPC GPRs hold 32 bits worth;
3228 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
3231 rs6000_hard_regno_nregs (int regno, enum machine_mode mode)
3233 if (FP_REGNO_P (regno))
3234 return (GET_MODE_SIZE (mode) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD;
3236 if (TARGET_E500_DOUBLE && mode == DFmode)
3239 if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
3240 return (GET_MODE_SIZE (mode) + UNITS_PER_SPE_WORD - 1) / UNITS_PER_SPE_WORD;
3242 if (ALTIVEC_REGNO_P (regno))
3244 (GET_MODE_SIZE (mode) + UNITS_PER_ALTIVEC_WORD - 1) / UNITS_PER_ALTIVEC_WORD;
3246 return (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
3249 /* Change register usage conditional on target flags. */
3251 rs6000_conditional_register_usage (void)
3255 /* Set MQ register fixed (already call_used) if not POWER
3256 architecture (RIOS1, RIOS2, RSC, and PPC601) so that it will not
3261 /* 64-bit AIX reserves GPR13 for thread-private data. */
3263 fixed_regs[13] = call_used_regs[13]
3264 = call_really_used_regs[13] = 1;
3266 /* Conditionally disable FPRs. */
3267 if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
3268 for (i = 32; i < 64; i++)
3269 fixed_regs[i] = call_used_regs[i]
3270 = call_really_used_regs[i] = 1;
3272 if (DEFAULT_ABI == ABI_V4
3273 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3275 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3277 if (DEFAULT_ABI == ABI_V4
3278 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
3280 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3281 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3282 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3284 if (DEFAULT_ABI == ABI_DARWIN
3285 && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
3286 global_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3287 = fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3288 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3289 = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3291 if (TARGET_TOC && TARGET_MINIMAL_TOC)
3292 fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
3293 = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
3296 global_regs[VSCR_REGNO] = 1;
3300 global_regs[SPEFSCR_REGNO] = 1;
3301 fixed_regs[FIXED_SCRATCH]
3302 = call_used_regs[FIXED_SCRATCH]
3303 = call_really_used_regs[FIXED_SCRATCH] = 1;
3306 if (! TARGET_ALTIVEC)
3308 for (i = FIRST_ALTIVEC_REGNO; i <= LAST_ALTIVEC_REGNO; ++i)
3309 fixed_regs[i] = call_used_regs[i] = call_really_used_regs[i] = 1;
3310 call_really_used_regs[VRSAVE_REGNO] = 1;
3313 if (TARGET_ALTIVEC_ABI)
3314 for (i = FIRST_ALTIVEC_REGNO; i < FIRST_ALTIVEC_REGNO + 20; ++i)
3315 call_used_regs[i] = call_really_used_regs[i] = 1;
3318 /* Try to output insns to set TARGET equal to the constant C if it can
3319 be done in less than N insns. Do all computations in MODE.
3320 Returns the place where the output has been placed if it can be
3321 done and the insns have been emitted. If it would take more than N
3322 insns, zero is returned and no insns and emitted. */
3325 rs6000_emit_set_const (rtx dest, enum machine_mode mode,
3326 rtx source, int n ATTRIBUTE_UNUSED)
3328 rtx result, insn, set;
3329 HOST_WIDE_INT c0, c1;
3331 if (mode == QImode || mode == HImode)
3334 dest = gen_reg_rtx (mode);
3335 emit_insn (gen_rtx_SET (VOIDmode, dest, source));
3338 else if (mode == SImode)
3340 result = no_new_pseudos ? dest : gen_reg_rtx (SImode);
3342 emit_insn (gen_rtx_SET (VOIDmode, result,
3343 GEN_INT (INTVAL (source)
3344 & (~ (HOST_WIDE_INT) 0xffff))));
3345 emit_insn (gen_rtx_SET (VOIDmode, dest,
3346 gen_rtx_IOR (SImode, result,
3347 GEN_INT (INTVAL (source) & 0xffff))));
3350 else if (mode == DImode)
3352 if (GET_CODE (source) == CONST_INT)
3354 c0 = INTVAL (source);
3357 else if (GET_CODE (source) == CONST_DOUBLE)
3359 #if HOST_BITS_PER_WIDE_INT >= 64
3360 c0 = CONST_DOUBLE_LOW (source);
3363 c0 = CONST_DOUBLE_LOW (source);
3364 c1 = CONST_DOUBLE_HIGH (source);
3370 result = rs6000_emit_set_long_const (dest, c0, c1);
3375 insn = get_last_insn ();
3376 set = single_set (insn);
3377 if (! CONSTANT_P (SET_SRC (set)))
3378 set_unique_reg_note (insn, REG_EQUAL, source);
3383 /* Having failed to find a 3 insn sequence in rs6000_emit_set_const,
3384 fall back to a straight forward decomposition. We do this to avoid
3385 exponential run times encountered when looking for longer sequences
3386 with rs6000_emit_set_const. */
3388 rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c1, HOST_WIDE_INT c2)
3390 if (!TARGET_POWERPC64)
3392 rtx operand1, operand2;
3394 operand1 = operand_subword_force (dest, WORDS_BIG_ENDIAN == 0,
3396 operand2 = operand_subword_force (dest, WORDS_BIG_ENDIAN != 0,
3398 emit_move_insn (operand1, GEN_INT (c1));
3399 emit_move_insn (operand2, GEN_INT (c2));
3403 HOST_WIDE_INT ud1, ud2, ud3, ud4;
3406 ud2 = (c1 & 0xffff0000) >> 16;
3407 #if HOST_BITS_PER_WIDE_INT >= 64
3411 ud4 = (c2 & 0xffff0000) >> 16;
3413 if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000))
3414 || (ud4 == 0 && ud3 == 0 && ud2 == 0 && ! (ud1 & 0x8000)))
3417 emit_move_insn (dest, GEN_INT (((ud1 ^ 0x8000) - 0x8000)));
3419 emit_move_insn (dest, GEN_INT (ud1));
3422 else if ((ud4 == 0xffff && ud3 == 0xffff && (ud2 & 0x8000))
3423 || (ud4 == 0 && ud3 == 0 && ! (ud2 & 0x8000)))
3426 emit_move_insn (dest, GEN_INT (((ud2 << 16) ^ 0x80000000)
3429 emit_move_insn (dest, GEN_INT (ud2 << 16));
3431 emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
3433 else if ((ud4 == 0xffff && (ud3 & 0x8000))
3434 || (ud4 == 0 && ! (ud3 & 0x8000)))
3437 emit_move_insn (dest, GEN_INT (((ud3 << 16) ^ 0x80000000)