1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991, 93-8, 1999 Free Software Foundation, Inc.
3 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "hard-reg-set.h"
28 #include "insn-config.h"
29 #include "conditions.h"
30 #include "insn-flags.h"
31 #include "insn-attr.h"
42 #ifndef TARGET_NO_PROTOTYPE
43 #define TARGET_NO_PROTOTYPE 0
46 extern char *language_string
;
47 extern int profile_block_flag
;
49 #define min(A,B) ((A) < (B) ? (A) : (B))
50 #define max(A,B) ((A) > (B) ? (A) : (B))
54 enum processor_type rs6000_cpu
;
55 struct rs6000_cpu_select rs6000_select
[3] =
57 /* switch name, tune arch */
58 { (const char *)0, "--with-cpu=", 1, 1 },
59 { (const char *)0, "-mcpu=", 1, 1 },
60 { (const char *)0, "-mtune=", 1, 0 },
63 /* Set to non-zero by "fix" operation to indicate that itrunc and
64 uitrunc must be defined. */
66 int rs6000_trunc_used
;
68 /* Set to non-zero once they have been defined. */
70 static int trunc_defined
;
72 /* Set to non-zero once AIX common-mode calls have been defined. */
73 static int common_mode_defined
;
75 /* Save information from a "cmpxx" operation until the branch or scc is
77 rtx rs6000_compare_op0
, rs6000_compare_op1
;
78 int rs6000_compare_fp_p
;
81 /* Label number of label created for -mrelocatable, to call to so we can
82 get the address of the GOT section */
83 int rs6000_pic_labelno
;
84 int rs6000_pic_func_labelno
;
86 /* Which abi to adhere to */
87 const char *rs6000_abi_name
= RS6000_ABI_NAME
;
89 /* Semantics of the small data area */
90 enum rs6000_sdata_type rs6000_sdata
= SDATA_DATA
;
92 /* Which small data model to use */
93 const char *rs6000_sdata_name
= (char *)0;
96 /* Whether a System V.4 varargs area was created. */
97 int rs6000_sysv_varargs_p
;
99 /* ABI enumeration available for subtarget to use. */
100 enum rs6000_abi rs6000_current_abi
;
102 /* Offset & size for fpmem stack locations used for converting between
103 float and integral types. */
104 int rs6000_fpmem_offset
;
105 int rs6000_fpmem_size
;
108 const char *rs6000_debug_name
;
109 int rs6000_debug_stack
; /* debug stack applications */
110 int rs6000_debug_arg
; /* debug argument handling */
112 /* Flag to say the TOC is initialized */
116 /* Default register names. */
117 char rs6000_reg_names
[][8] =
119 "0", "1", "2", "3", "4", "5", "6", "7",
120 "8", "9", "10", "11", "12", "13", "14", "15",
121 "16", "17", "18", "19", "20", "21", "22", "23",
122 "24", "25", "26", "27", "28", "29", "30", "31",
123 "0", "1", "2", "3", "4", "5", "6", "7",
124 "8", "9", "10", "11", "12", "13", "14", "15",
125 "16", "17", "18", "19", "20", "21", "22", "23",
126 "24", "25", "26", "27", "28", "29", "30", "31",
127 "mq", "lr", "ctr","ap",
128 "0", "1", "2", "3", "4", "5", "6", "7",
132 #ifdef TARGET_REGNAMES
133 static char alt_reg_names
[][8] =
135 "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
136 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
137 "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23",
138 "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31",
139 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
140 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
141 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
142 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
143 "mq", "lr", "ctr", "ap",
144 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7",
149 #ifndef MASK_STRICT_ALIGN
150 #define MASK_STRICT_ALIGN 0
153 /* Override command line options. Mostly we process the processor
154 type and sometimes adjust other TARGET_ options. */
157 rs6000_override_options (default_cpu
)
158 const char *default_cpu
;
161 struct rs6000_cpu_select
*ptr
;
163 /* Simplify the entries below by making a mask for any POWER
164 variant and any PowerPC variant. */
166 #define POWER_MASKS (MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING)
167 #define POWERPC_MASKS (MASK_POWERPC | MASK_PPC_GPOPT \
168 | MASK_PPC_GFXOPT | MASK_POWERPC64)
169 #define POWERPC_OPT_MASKS (MASK_PPC_GPOPT | MASK_PPC_GFXOPT)
173 const char *name
; /* Canonical processor name. */
174 enum processor_type processor
; /* Processor type enum value. */
175 int target_enable
; /* Target flags to enable. */
176 int target_disable
; /* Target flags to disable. */
177 } processor_target_table
[]
178 = {{"common", PROCESSOR_COMMON
, MASK_NEW_MNEMONICS
,
179 POWER_MASKS
| POWERPC_MASKS
},
180 {"power", PROCESSOR_POWER
,
181 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
,
182 MASK_POWER2
| POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
183 {"power2", PROCESSOR_POWER
,
184 MASK_POWER
| MASK_POWER2
| MASK_MULTIPLE
| MASK_STRING
,
185 POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
186 {"powerpc", PROCESSOR_POWERPC
,
187 MASK_POWERPC
| MASK_NEW_MNEMONICS
,
188 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
189 {"rios", PROCESSOR_RIOS1
,
190 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
,
191 MASK_POWER2
| POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
192 {"rios1", PROCESSOR_RIOS1
,
193 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
,
194 MASK_POWER2
| POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
195 {"rsc", PROCESSOR_PPC601
,
196 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
,
197 MASK_POWER2
| POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
198 {"rsc1", PROCESSOR_PPC601
,
199 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
,
200 MASK_POWER2
| POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
201 {"rios2", PROCESSOR_RIOS2
,
202 MASK_POWER
| MASK_MULTIPLE
| MASK_STRING
| MASK_POWER2
,
203 POWERPC_MASKS
| MASK_NEW_MNEMONICS
},
204 {"401", PROCESSOR_PPC403
,
205 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
206 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
207 {"403", PROCESSOR_PPC403
,
208 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
| MASK_STRICT_ALIGN
,
209 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
210 {"505", PROCESSOR_MPCCORE
,
211 MASK_POWERPC
| MASK_NEW_MNEMONICS
,
212 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
213 {"601", PROCESSOR_PPC601
,
214 MASK_POWER
| MASK_POWERPC
| MASK_NEW_MNEMONICS
| MASK_MULTIPLE
| MASK_STRING
,
215 MASK_POWER2
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
216 {"602", PROCESSOR_PPC603
,
217 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
218 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
219 {"603", PROCESSOR_PPC603
,
220 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
221 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
222 {"603e", PROCESSOR_PPC603
,
223 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
224 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
225 {"ec603e", PROCESSOR_PPC603
,
226 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
227 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
228 {"604", PROCESSOR_PPC604
,
229 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
230 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
231 {"604e", PROCESSOR_PPC604e
,
232 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
233 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
234 {"620", PROCESSOR_PPC620
,
235 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
236 POWER_MASKS
| MASK_PPC_GPOPT
},
237 {"740", PROCESSOR_PPC750
,
238 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
239 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
240 {"750", PROCESSOR_PPC750
,
241 MASK_POWERPC
| MASK_PPC_GFXOPT
| MASK_NEW_MNEMONICS
,
242 POWER_MASKS
| MASK_PPC_GPOPT
| MASK_POWERPC64
},
243 {"801", PROCESSOR_MPCCORE
,
244 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
245 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
246 {"821", PROCESSOR_MPCCORE
,
247 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
248 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
249 {"823", PROCESSOR_MPCCORE
,
250 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
251 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
},
252 {"860", PROCESSOR_MPCCORE
,
253 MASK_POWERPC
| MASK_SOFT_FLOAT
| MASK_NEW_MNEMONICS
,
254 POWER_MASKS
| POWERPC_OPT_MASKS
| MASK_POWERPC64
}};
256 size_t ptt_size
= sizeof (processor_target_table
) / sizeof (struct ptt
);
258 int multiple
= TARGET_MULTIPLE
; /* save current -mmultiple/-mno-multiple status */
259 int string
= TARGET_STRING
; /* save current -mstring/-mno-string status */
261 profile_block_flag
= 0;
263 /* Identify the processor type */
264 rs6000_select
[0].string
= default_cpu
;
265 rs6000_cpu
= PROCESSOR_DEFAULT
;
267 for (i
= 0; i
< sizeof (rs6000_select
) / sizeof (rs6000_select
[0]); i
++)
269 ptr
= &rs6000_select
[i
];
270 if (ptr
->string
!= (char *)0 && ptr
->string
[0] != '\0')
272 for (j
= 0; j
< ptt_size
; j
++)
273 if (! strcmp (ptr
->string
, processor_target_table
[j
].name
))
276 rs6000_cpu
= processor_target_table
[j
].processor
;
280 target_flags
|= processor_target_table
[j
].target_enable
;
281 target_flags
&= ~processor_target_table
[j
].target_disable
;
287 error ("bad value (%s) for %s switch", ptr
->string
, ptr
->name
);
291 /* If we are optimizing big endian systems for space, use the
292 store multiple instructions. */
293 if (BYTES_BIG_ENDIAN
&& optimize_size
)
294 target_flags
|= MASK_MULTIPLE
;
296 /* If -mmultiple or -mno-multiple was explicitly used, don't
297 override with the processor default */
298 if (TARGET_MULTIPLE_SET
)
299 target_flags
= (target_flags
& ~MASK_MULTIPLE
) | multiple
;
301 /* If -mstring or -mno-string was explicitly used, don't
302 override with the processor default */
303 if (TARGET_STRING_SET
)
304 target_flags
= (target_flags
& ~MASK_STRING
) | string
;
306 /* Don't allow -mmultiple or -mstring on little endian systems unless the cpu
307 is a 750, because the hardware doesn't support the instructions used in
308 little endian mode, and causes an alignment trap. The 750 does not cause
309 an alignment trap (except when the target is unaligned). */
311 if (! BYTES_BIG_ENDIAN
&& rs6000_cpu
!= PROCESSOR_PPC750
)
315 target_flags
&= ~MASK_MULTIPLE
;
316 if (TARGET_MULTIPLE_SET
)
317 warning ("-mmultiple is not supported on little endian systems");
322 target_flags
&= ~MASK_STRING
;
323 if (TARGET_STRING_SET
)
324 warning ("-mstring is not supported on little endian systems");
328 if (flag_pic
&& (DEFAULT_ABI
== ABI_AIX
))
330 warning ("-f%s ignored for AIX (all code is position independent)",
331 (flag_pic
> 1) ? "PIC" : "pic");
335 /* Set debug flags */
336 if (rs6000_debug_name
)
338 if (! strcmp (rs6000_debug_name
, "all"))
339 rs6000_debug_stack
= rs6000_debug_arg
= 1;
340 else if (! strcmp (rs6000_debug_name
, "stack"))
341 rs6000_debug_stack
= 1;
342 else if (! strcmp (rs6000_debug_name
, "arg"))
343 rs6000_debug_arg
= 1;
345 error ("Unknown -mdebug-%s switch", rs6000_debug_name
);
348 #ifdef TARGET_REGNAMES
349 /* If the user desires alternate register names, copy in the alternate names
352 bcopy ((char *)alt_reg_names
, (char *)rs6000_reg_names
,
353 sizeof (rs6000_reg_names
));
356 #ifdef SUBTARGET_OVERRIDE_OPTIONS
357 SUBTARGET_OVERRIDE_OPTIONS
;
362 optimization_options (level
, size
)
364 int size ATTRIBUTE_UNUSED
;
366 #ifdef HAVE_decrement_and_branch_on_count
367 /* When optimizing, enable use of BCT instruction. */
369 flag_branch_on_count_reg
= 1;
373 /* Do anything needed at the start of the asm file. */
376 rs6000_file_start (file
, default_cpu
)
378 const char *default_cpu
;
382 const char *start
= buffer
;
383 struct rs6000_cpu_select
*ptr
;
385 if (flag_verbose_asm
)
387 sprintf (buffer
, "\n%s rs6000/powerpc options:", ASM_COMMENT_START
);
388 rs6000_select
[0].string
= default_cpu
;
390 for (i
= 0; i
< sizeof (rs6000_select
) / sizeof (rs6000_select
[0]); i
++)
392 ptr
= &rs6000_select
[i
];
393 if (ptr
->string
!= (char *)0 && ptr
->string
[0] != '\0')
395 fprintf (file
, "%s %s%s", start
, ptr
->name
, ptr
->string
);
401 switch (rs6000_sdata
)
403 case SDATA_NONE
: fprintf (file
, "%s -msdata=none", start
); start
= ""; break;
404 case SDATA_DATA
: fprintf (file
, "%s -msdata=data", start
); start
= ""; break;
405 case SDATA_SYSV
: fprintf (file
, "%s -msdata=sysv", start
); start
= ""; break;
406 case SDATA_EABI
: fprintf (file
, "%s -msdata=eabi", start
); start
= ""; break;
409 if (rs6000_sdata
&& g_switch_value
)
411 fprintf (file
, "%s -G %d", start
, g_switch_value
);
422 /* Create a CONST_DOUBLE from a string. */
425 rs6000_float_const (string
, mode
)
427 enum machine_mode mode
;
429 REAL_VALUE_TYPE value
= REAL_VALUE_ATOF (string
, mode
);
430 return immed_real_const_1 (value
, mode
);
433 /* Return non-zero if this function is known to have a null epilogue. */
438 if (reload_completed
)
440 rs6000_stack_t
*info
= rs6000_stack_info ();
442 if (info
->first_gp_reg_save
== 32
443 && info
->first_fp_reg_save
== 64
453 /* Returns 1 always. */
456 any_operand (op
, mode
)
457 register rtx op ATTRIBUTE_UNUSED
;
458 enum machine_mode mode ATTRIBUTE_UNUSED
;
463 /* Returns 1 if op is the count register */
465 count_register_operand(op
, mode
)
467 enum machine_mode mode ATTRIBUTE_UNUSED
;
469 if (GET_CODE (op
) != REG
)
472 if (REGNO (op
) == COUNT_REGISTER_REGNUM
)
475 if (REGNO (op
) > FIRST_PSEUDO_REGISTER
)
481 /* Returns 1 if op is memory location for float/int conversions that masquerades
484 fpmem_operand(op
, mode
)
486 enum machine_mode mode ATTRIBUTE_UNUSED
;
488 if (GET_CODE (op
) != REG
)
491 if (FPMEM_REGNO_P (REGNO (op
)))
495 if (REGNO (op
) > FIRST_PSEUDO_REGISTER
)
502 /* Return 1 if OP is a constant that can fit in a D field. */
505 short_cint_operand (op
, mode
)
507 enum machine_mode mode ATTRIBUTE_UNUSED
;
509 return ((GET_CODE (op
) == CONST_INT
510 && (unsigned HOST_WIDE_INT
) (INTVAL (op
) + 0x8000) < 0x10000));
513 /* Similar for a unsigned D field. */
516 u_short_cint_operand (op
, mode
)
518 enum machine_mode mode ATTRIBUTE_UNUSED
;
520 return (GET_CODE (op
) == CONST_INT
521 && (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff)) == 0);
524 /* Return 1 if OP is a CONST_INT that cannot fit in a signed D field. */
527 non_short_cint_operand (op
, mode
)
529 enum machine_mode mode ATTRIBUTE_UNUSED
;
531 return (GET_CODE (op
) == CONST_INT
532 && (unsigned HOST_WIDE_INT
) (INTVAL (op
) + 0x8000) >= 0x10000);
535 /* Returns 1 if OP is a register that is not special (i.e., not MQ,
539 gpc_reg_operand (op
, mode
)
541 enum machine_mode mode
;
543 return (register_operand (op
, mode
)
544 && (GET_CODE (op
) != REG
545 || (REGNO (op
) >= 67 && !FPMEM_REGNO_P (REGNO (op
)))
546 || REGNO (op
) < 64));
549 /* Returns 1 if OP is either a pseudo-register or a register denoting a
553 cc_reg_operand (op
, mode
)
555 enum machine_mode mode
;
557 return (register_operand (op
, mode
)
558 && (GET_CODE (op
) != REG
559 || REGNO (op
) >= FIRST_PSEUDO_REGISTER
560 || CR_REGNO_P (REGNO (op
))));
563 /* Returns 1 if OP is either a pseudo-register or a register denoting a
564 CR field that isn't CR0. */
567 cc_reg_not_cr0_operand (op
, mode
)
569 enum machine_mode mode
;
571 return (register_operand (op
, mode
)
572 && (GET_CODE (op
) != REG
573 || REGNO (op
) >= FIRST_PSEUDO_REGISTER
574 || CR_REGNO_NOT_CR0_P (REGNO (op
))));
577 /* Returns 1 if OP is either a constant integer valid for a D-field or a
578 non-special register. If a register, it must be in the proper mode unless
582 reg_or_short_operand (op
, mode
)
584 enum machine_mode mode
;
586 return short_cint_operand (op
, mode
) || gpc_reg_operand (op
, mode
);
589 /* Similar, except check if the negation of the constant would be valid for
593 reg_or_neg_short_operand (op
, mode
)
595 enum machine_mode mode
;
597 if (GET_CODE (op
) == CONST_INT
)
598 return CONST_OK_FOR_LETTER_P (INTVAL (op
), 'P');
600 return gpc_reg_operand (op
, mode
);
603 /* Return 1 if the operand is either a register or an integer whose high-order
607 reg_or_u_short_operand (op
, mode
)
609 enum machine_mode mode
;
611 return u_short_cint_operand (op
, mode
) || gpc_reg_operand (op
, mode
);
614 /* Return 1 is the operand is either a non-special register or ANY
618 reg_or_cint_operand (op
, mode
)
620 enum machine_mode mode
;
622 return (GET_CODE (op
) == CONST_INT
623 || gpc_reg_operand (op
, mode
));
626 /* Return 1 if the operand is an operand that can be loaded via the GOT */
629 got_operand (op
, mode
)
631 enum machine_mode mode ATTRIBUTE_UNUSED
;
633 return (GET_CODE (op
) == SYMBOL_REF
634 || GET_CODE (op
) == CONST
635 || GET_CODE (op
) == LABEL_REF
);
638 /* Return 1 if the operand is a simple references that can be loaded via
639 the GOT (labels involving addition aren't allowed). */
642 got_no_const_operand (op
, mode
)
644 enum machine_mode mode ATTRIBUTE_UNUSED
;
646 return (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == LABEL_REF
);
649 /* Return the number of instructions it takes to form a constant in an
653 num_insns_constant_wide (value
)
656 /* signed constant loadable with {cal|addi} */
657 if (((unsigned HOST_WIDE_INT
)value
+ 0x8000) < 0x10000)
660 #if HOST_BITS_PER_WIDE_INT == 32
661 /* constant loadable with {cau|addis} */
662 else if ((value
& 0xffff) == 0)
666 /* constant loadable with {cau|addis} */
667 else if ((value
& 0xffff) == 0 && (value
& ~0xffffffff) == 0)
670 else if (TARGET_64BIT
)
672 HOST_WIDE_INT low
= value
& 0xffffffff;
673 HOST_WIDE_INT high
= value
>> 32;
675 if (high
== 0 && (low
& 0x80000000) == 0)
678 else if (high
== 0xffffffff && (low
& 0x80000000) != 0)
682 return num_insns_constant_wide (high
) + 1;
685 return (num_insns_constant_wide (high
)
686 + num_insns_constant_wide (low
) + 1);
695 num_insns_constant (op
, mode
)
697 enum machine_mode mode
;
699 if (GET_CODE (op
) == CONST_INT
)
700 return num_insns_constant_wide (INTVAL (op
));
702 else if (GET_CODE (op
) == CONST_DOUBLE
&& mode
== SFmode
)
707 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
708 REAL_VALUE_TO_TARGET_SINGLE (rv
, l
);
709 return num_insns_constant_wide ((HOST_WIDE_INT
)l
);
712 else if (GET_CODE (op
) == CONST_DOUBLE
)
718 int endian
= (WORDS_BIG_ENDIAN
== 0);
720 if (mode
== VOIDmode
|| mode
== DImode
)
722 high
= CONST_DOUBLE_HIGH (op
);
723 low
= CONST_DOUBLE_LOW (op
);
727 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
728 REAL_VALUE_TO_TARGET_DOUBLE (rv
, l
);
734 return (num_insns_constant_wide (low
)
735 + num_insns_constant_wide (high
));
739 if (high
== 0 && (low
& 0x80000000) == 0)
740 return num_insns_constant_wide (low
);
742 else if (((high
& 0xffffffff) == 0xffffffff)
743 && ((low
& 0x80000000) != 0))
744 return num_insns_constant_wide (low
);
746 else if (mask64_operand (op
, mode
))
750 return num_insns_constant_wide (high
) + 1;
753 return (num_insns_constant_wide (high
)
754 + num_insns_constant_wide (low
) + 1);
762 /* Return 1 if the operand is a CONST_DOUBLE and it can be put into a register
763 with one instruction per word. We only do this if we can safely read
764 CONST_DOUBLE_{LOW,HIGH}. */
767 easy_fp_constant (op
, mode
)
769 register enum machine_mode mode
;
771 if (GET_CODE (op
) != CONST_DOUBLE
772 || GET_MODE (op
) != mode
773 || (GET_MODE_CLASS (mode
) != MODE_FLOAT
&& mode
!= DImode
))
776 /* Consider all constants with -msoft-float to be easy */
777 if (TARGET_SOFT_FLOAT
&& mode
!= DImode
)
780 /* If we are using V.4 style PIC, consider all constants to be hard */
781 if (flag_pic
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
784 #ifdef TARGET_RELOCATABLE
785 /* Similarly if we are using -mrelocatable, consider all constants to be hard */
786 if (TARGET_RELOCATABLE
)
795 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
796 REAL_VALUE_TO_TARGET_DOUBLE (rv
, k
);
798 return (num_insns_constant_wide ((HOST_WIDE_INT
)k
[0]) == 1
799 && num_insns_constant_wide ((HOST_WIDE_INT
)k
[1]) == 1);
802 else if (mode
== SFmode
)
807 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
808 REAL_VALUE_TO_TARGET_SINGLE (rv
, l
);
810 return num_insns_constant_wide (l
) == 1;
813 else if (mode
== DImode
)
814 return ((TARGET_64BIT
815 && GET_CODE (op
) == CONST_DOUBLE
&& CONST_DOUBLE_LOW (op
) == 0)
816 || (num_insns_constant (op
, DImode
) <= 2));
822 /* Return 1 if the operand is in volatile memory. Note that during the
823 RTL generation phase, memory_operand does not return TRUE for
824 volatile memory references. So this function allows us to
825 recognize volatile references where its safe. */
828 volatile_mem_operand (op
, mode
)
830 enum machine_mode mode
;
832 if (GET_CODE (op
) != MEM
)
835 if (!MEM_VOLATILE_P (op
))
838 if (mode
!= GET_MODE (op
))
841 if (reload_completed
)
842 return memory_operand (op
, mode
);
844 if (reload_in_progress
)
845 return strict_memory_address_p (mode
, XEXP (op
, 0));
847 return memory_address_p (mode
, XEXP (op
, 0));
850 /* Return 1 if the operand is an offsettable memory operand. */
853 offsettable_mem_operand (op
, mode
)
855 enum machine_mode mode
;
857 return ((GET_CODE (op
) == MEM
)
858 && offsettable_address_p (reload_completed
|| reload_in_progress
,
859 mode
, XEXP (op
, 0)));
862 /* Return 1 if the operand is either an easy FP constant (see above) or
866 mem_or_easy_const_operand (op
, mode
)
868 enum machine_mode mode
;
870 return memory_operand (op
, mode
) || easy_fp_constant (op
, mode
);
873 /* Return 1 if the operand is either a non-special register or an item
874 that can be used as the operand of an SI add insn. */
877 add_operand (op
, mode
)
879 enum machine_mode mode
;
881 return (reg_or_short_operand (op
, mode
)
882 || (GET_CODE (op
) == CONST_INT
883 && (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff0000)) == 0));
886 /* Return 1 if OP is a constant but not a valid add_operand. */
889 non_add_cint_operand (op
, mode
)
891 enum machine_mode mode ATTRIBUTE_UNUSED
;
893 return (GET_CODE (op
) == CONST_INT
894 && (unsigned HOST_WIDE_INT
) (INTVAL (op
) + 0x8000) >= 0x10000
895 && (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff0000)) != 0);
898 /* Return 1 if the operand is a non-special register or a constant that
899 can be used as the operand of an OR or XOR insn on the RS/6000. */
902 logical_operand (op
, mode
)
904 enum machine_mode mode
;
906 return (gpc_reg_operand (op
, mode
)
907 || (GET_CODE (op
) == CONST_INT
908 && ((INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff)) == 0
909 || (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff0000)) == 0)));
912 /* Return 1 if C is a constant that is not a logical operand (as
916 non_logical_cint_operand (op
, mode
)
918 enum machine_mode mode ATTRIBUTE_UNUSED
;
920 return (GET_CODE (op
) == CONST_INT
921 && (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff)) != 0
922 && (INTVAL (op
) & (~ (HOST_WIDE_INT
) 0xffff0000)) != 0);
925 /* Return 1 if C is a constant that can be encoded in a 32-bit mask on the
926 RS/6000. It is if there are no more than two 1->0 or 0->1 transitions.
927 Reject all ones and all zeros, since these should have been optimized
928 away and confuse the making of MB and ME. */
931 mask_operand (op
, mode
)
933 enum machine_mode mode ATTRIBUTE_UNUSED
;
940 if (GET_CODE (op
) != CONST_INT
)
945 if (c
== 0 || c
== ~0)
948 last_bit_value
= c
& 1;
950 for (i
= 1; i
< 32; i
++)
951 if (((c
>>= 1) & 1) != last_bit_value
)
952 last_bit_value
^= 1, transitions
++;
954 return transitions
<= 2;
957 /* Return 1 if the operand is a constant that is a PowerPC64 mask.
958 It is if there are no more than one 1->0 or 0->1 transitions.
959 Reject all ones and all zeros, since these should have been optimized
960 away and confuse the making of MB and ME. */
963 mask64_operand (op
, mode
)
965 enum machine_mode mode
;
967 if (GET_CODE (op
) == CONST_INT
)
969 HOST_WIDE_INT c
= INTVAL (op
);
974 if (c
== 0 || c
== ~0)
977 last_bit_value
= c
& 1;
979 for (i
= 1; i
< HOST_BITS_PER_WIDE_INT
; i
++)
980 if (((c
>>= 1) & 1) != last_bit_value
)
981 last_bit_value
^= 1, transitions
++;
983 #if HOST_BITS_PER_WIDE_INT == 32
984 /* Consider CONST_INT sign-extended. */
985 transitions
+= (last_bit_value
!= 1);
988 return transitions
<= 1;
990 else if (GET_CODE (op
) == CONST_DOUBLE
991 && (mode
== VOIDmode
|| mode
== DImode
))
993 HOST_WIDE_INT low
= CONST_DOUBLE_LOW (op
);
994 #if HOST_BITS_PER_WIDE_INT == 32
995 HOST_WIDE_INT high
= CONST_DOUBLE_HIGH (op
);
1002 #if HOST_BITS_PER_WIDE_INT == 32
1007 #if HOST_BITS_PER_WIDE_INT == 32
1013 last_bit_value
= low
& 1;
1015 for (i
= 1; i
< HOST_BITS_PER_WIDE_INT
; i
++)
1016 if (((low
>>= 1) & 1) != last_bit_value
)
1017 last_bit_value
^= 1, transitions
++;
1019 #if HOST_BITS_PER_WIDE_INT == 32
1020 if ((high
& 1) != last_bit_value
)
1021 last_bit_value
^= 1, transitions
++;
1023 for (i
= 1; i
< HOST_BITS_PER_WIDE_INT
; i
++)
1024 if (((high
>>= 1) & 1) != last_bit_value
)
1025 last_bit_value
^= 1, transitions
++;
1028 return transitions
<= 1;
1034 /* Return 1 if the operand is either a non-special register or a constant
1035 that can be used as the operand of a PowerPC64 logical AND insn. */
1038 and64_operand (op
, mode
)
1040 enum machine_mode mode
;
1042 if (fixed_regs
[68]) /* CR0 not available, don't do andi./andis. */
1043 return (gpc_reg_operand (op
, mode
) || mask64_operand (op
, mode
));
1045 return (logical_operand (op
, mode
) || mask64_operand (op
, mode
));
1048 /* Return 1 if the operand is either a non-special register or a
1049 constant that can be used as the operand of an RS/6000 logical AND insn. */
1052 and_operand (op
, mode
)
1054 enum machine_mode mode
;
1056 if (fixed_regs
[68]) /* CR0 not available, don't do andi./andis. */
1057 return (gpc_reg_operand (op
, mode
) || mask_operand (op
, mode
));
1059 return (logical_operand (op
, mode
) || mask_operand (op
, mode
));
1062 /* Return 1 if the operand is a general register or memory operand. */
1065 reg_or_mem_operand (op
, mode
)
1067 register enum machine_mode mode
;
1069 return (gpc_reg_operand (op
, mode
)
1070 || memory_operand (op
, mode
)
1071 || volatile_mem_operand (op
, mode
));
1074 /* Return 1 if the operand is a general register or memory operand without
1075 pre-inc or pre_dec which produces invalid form of PowerPC lwa
1079 lwa_operand (op
, mode
)
1081 register enum machine_mode mode
;
1085 if (reload_completed
&& GET_CODE (inner
) == SUBREG
)
1086 inner
= SUBREG_REG (inner
);
1088 return gpc_reg_operand (inner
, mode
)
1089 || (memory_operand (inner
, mode
)
1090 && GET_CODE (XEXP (inner
, 0)) != PRE_INC
1091 && GET_CODE (XEXP (inner
, 0)) != PRE_DEC
);
1094 /* Return 1 if the operand, used inside a MEM, is a valid first argument
1095 to CALL. This is a SYMBOL_REF or a pseudo-register, which will be
1099 call_operand (op
, mode
)
1101 enum machine_mode mode
;
1103 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
1106 return (GET_CODE (op
) == SYMBOL_REF
1107 || (GET_CODE (op
) == REG
&& REGNO (op
) >= FIRST_PSEUDO_REGISTER
));
1111 /* Return 1 if the operand is a SYMBOL_REF for a function known to be in
1115 current_file_function_operand (op
, mode
)
1117 enum machine_mode mode ATTRIBUTE_UNUSED
;
1119 return (GET_CODE (op
) == SYMBOL_REF
1120 && (SYMBOL_REF_FLAG (op
)
1121 || op
== XEXP (DECL_RTL (current_function_decl
), 0)));
1125 /* Return 1 if this operand is a valid input for a move insn. */
1128 input_operand (op
, mode
)
1130 enum machine_mode mode
;
1132 /* Memory is always valid. */
1133 if (memory_operand (op
, mode
))
1136 /* Only a tiny bit of handling for CONSTANT_P_RTX is necessary. */
1137 if (GET_CODE (op
) == CONSTANT_P_RTX
)
1140 /* For floating-point, easy constants are valid. */
1141 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
1143 && easy_fp_constant (op
, mode
))
1146 /* Allow any integer constant. */
1147 if (GET_MODE_CLASS (mode
) == MODE_INT
1148 && (GET_CODE (op
) == CONST_INT
1149 || GET_CODE (op
) == CONST_DOUBLE
))
1152 /* For floating-point or multi-word mode, the only remaining valid type
1154 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
1155 || GET_MODE_SIZE (mode
) > UNITS_PER_WORD
)
1156 return register_operand (op
, mode
);
1158 /* The only cases left are integral modes one word or smaller (we
1159 do not get called for MODE_CC values). These can be in any
1161 if (register_operand (op
, mode
))
1164 /* A SYMBOL_REF referring to the TOC is valid. */
1165 if (LEGITIMATE_CONSTANT_POOL_ADDRESS_P (op
))
1168 /* Windows NT allows SYMBOL_REFs and LABEL_REFs against the TOC
1169 directly in the instruction stream */
1170 if (DEFAULT_ABI
== ABI_NT
1171 && (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == LABEL_REF
))
1174 /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
1176 if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
1177 && (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == CONST
)
1178 && small_data_operand (op
, Pmode
))
1184 /* Return 1 for an operand in small memory on V.4/eabi */
1187 small_data_operand (op
, mode
)
1188 rtx op ATTRIBUTE_UNUSED
;
1189 enum machine_mode mode ATTRIBUTE_UNUSED
;
1192 rtx sym_ref
, const_part
;
1194 if (rs6000_sdata
== SDATA_NONE
|| rs6000_sdata
== SDATA_DATA
)
1197 if (DEFAULT_ABI
!= ABI_V4
&& DEFAULT_ABI
!= ABI_SOLARIS
)
1200 if (GET_CODE (op
) == SYMBOL_REF
)
1203 else if (GET_CODE (op
) != CONST
1204 || GET_CODE (XEXP (op
, 0)) != PLUS
1205 || GET_CODE (XEXP (XEXP (op
, 0), 0)) != SYMBOL_REF
1206 || GET_CODE (XEXP (XEXP (op
, 0), 1)) != CONST_INT
)
1211 rtx sum
= XEXP (op
, 0);
1212 HOST_WIDE_INT summand
;
1214 /* We have to be careful here, because it is the referenced address
1215 that must be 32k from _SDA_BASE_, not just the symbol. */
1216 summand
= INTVAL (XEXP (sum
, 1));
1217 if (summand
< 0 || summand
> g_switch_value
)
1220 sym_ref
= XEXP (sum
, 0);
1223 if (*XSTR (sym_ref
, 0) != '@')
1234 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1235 for a call to a function whose data type is FNTYPE.
1236 For a library call, FNTYPE is 0.
1238 For incoming args we set the number of arguments in the prototype large
1239 so we never return a PARALLEL. */
1242 init_cumulative_args (cum
, fntype
, libname
, incoming
)
1243 CUMULATIVE_ARGS
*cum
;
1245 rtx libname ATTRIBUTE_UNUSED
;
1248 static CUMULATIVE_ARGS zero_cumulative
;
1249 enum rs6000_abi abi
= DEFAULT_ABI
;
1251 *cum
= zero_cumulative
;
1253 cum
->fregno
= FP_ARG_MIN_REG
;
1254 cum
->prototype
= (fntype
&& TYPE_ARG_TYPES (fntype
));
1255 cum
->call_cookie
= CALL_NORMAL
;
1258 cum
->nargs_prototype
= 1000; /* don't return a PARALLEL */
1260 else if (cum
->prototype
)
1261 cum
->nargs_prototype
= (list_length (TYPE_ARG_TYPES (fntype
)) - 1
1262 + (TYPE_MODE (TREE_TYPE (fntype
)) == BLKmode
1263 || RETURN_IN_MEMORY (TREE_TYPE (fntype
))));
1266 cum
->nargs_prototype
= 0;
1268 cum
->orig_nargs
= cum
->nargs_prototype
;
1270 /* Check for DLL import functions */
1273 && lookup_attribute ("dllimport", TYPE_ATTRIBUTES (fntype
)))
1274 cum
->call_cookie
= CALL_NT_DLLIMPORT
;
1276 /* Also check for longcall's */
1277 else if (fntype
&& lookup_attribute ("longcall", TYPE_ATTRIBUTES (fntype
)))
1278 cum
->call_cookie
= CALL_LONG
;
1280 if (TARGET_DEBUG_ARG
)
1282 fprintf (stderr
, "\ninit_cumulative_args:");
1285 tree ret_type
= TREE_TYPE (fntype
);
1286 fprintf (stderr
, " ret code = %s,",
1287 tree_code_name
[ (int)TREE_CODE (ret_type
) ]);
1290 if (cum
->call_cookie
& CALL_NT_DLLIMPORT
)
1291 fprintf (stderr
, " dllimport,");
1293 if (cum
->call_cookie
& CALL_LONG
)
1294 fprintf (stderr
, " longcall,");
1296 fprintf (stderr
, " proto = %d, nargs = %d\n",
1297 cum
->prototype
, cum
->nargs_prototype
);
1301 /* If defined, a C expression which determines whether, and in which
1302 direction, to pad out an argument with extra space. The value
1303 should be of type `enum direction': either `upward' to pad above
1304 the argument, `downward' to pad below, or `none' to inhibit
1307 For the AIX ABI structs are always stored left shifted in their
1311 function_arg_padding (mode
, type
)
1312 enum machine_mode mode
;
1315 if (type
!= 0 && AGGREGATE_TYPE_P (type
))
1318 /* This is the default definition. */
1319 return (! BYTES_BIG_ENDIAN
1322 ? (type
&& TREE_CODE (TYPE_SIZE (type
)) == INTEGER_CST
1323 && int_size_in_bytes (type
) < (PARM_BOUNDARY
/ BITS_PER_UNIT
))
1324 : GET_MODE_BITSIZE (mode
) < PARM_BOUNDARY
)
1325 ? (int)downward
: (int)upward
));
1328 /* If defined, a C expression that gives the alignment boundary, in bits,
1329 of an argument with the specified mode and type. If it is not defined,
1330 PARM_BOUNDARY is used for all arguments.
1332 Windows NT wants anything >= 8 bytes to be double word aligned.
1334 V.4 wants long longs to be double word aligned. */
1337 function_arg_boundary (mode
, type
)
1338 enum machine_mode mode
;
1341 if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
) && mode
== DImode
)
1344 if (DEFAULT_ABI
!= ABI_NT
|| TARGET_64BIT
)
1345 return PARM_BOUNDARY
;
1347 if (mode
!= BLKmode
)
1348 return (GET_MODE_SIZE (mode
)) >= 8 ? 64 : 32;
1350 return (int_size_in_bytes (type
) >= 8) ? 64 : 32;
1353 /* Update the data in CUM to advance over an argument
1354 of mode MODE and data type TYPE.
1355 (TYPE is null for libcalls where that information may not be available.) */
1358 function_arg_advance (cum
, mode
, type
, named
)
1359 CUMULATIVE_ARGS
*cum
;
1360 enum machine_mode mode
;
1364 int align
= (TARGET_32BIT
&& (cum
->words
& 1) != 0
1365 && function_arg_boundary (mode
, type
) == 64) ? 1 : 0;
1366 cum
->words
+= align
;
1367 cum
->nargs_prototype
--;
1369 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
1371 /* Long longs must not be split between registers and stack */
1372 if ((GET_MODE_CLASS (mode
) != MODE_FLOAT
|| TARGET_SOFT_FLOAT
)
1373 && type
&& !AGGREGATE_TYPE_P (type
)
1374 && cum
->words
< GP_ARG_NUM_REG
1375 && cum
->words
+ RS6000_ARG_SIZE (mode
, type
, named
) > GP_ARG_NUM_REG
)
1377 cum
->words
= GP_ARG_NUM_REG
;
1380 /* Aggregates get passed as pointers */
1381 if (type
&& AGGREGATE_TYPE_P (type
))
1384 /* Floats go in registers, & don't occupy space in the GP registers
1385 like they do for AIX unless software floating point. */
1386 else if (GET_MODE_CLASS (mode
) == MODE_FLOAT
1387 && TARGET_HARD_FLOAT
1388 && cum
->fregno
<= FP_ARG_V4_MAX_REG
)
1392 cum
->words
+= RS6000_ARG_SIZE (mode
, type
, 1);
1397 cum
->words
+= RS6000_ARG_SIZE (mode
, type
, named
);
1398 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
&& TARGET_HARD_FLOAT
)
1402 if (TARGET_DEBUG_ARG
)
1404 "function_adv: words = %2d, fregno = %2d, nargs = %4d, proto = %d, mode = %4s, named = %d, align = %d\n",
1405 cum
->words
, cum
->fregno
, cum
->nargs_prototype
, cum
->prototype
, GET_MODE_NAME (mode
), named
, align
);
1408 /* Determine where to put an argument to a function.
1409 Value is zero to push the argument on the stack,
1410 or a hard register in which to store the argument.
1412 MODE is the argument's machine mode.
1413 TYPE is the data type of the argument (as a tree).
1414 This is null for libcalls where that information may
1416 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1417 the preceding args and about the function being called.
1418 NAMED is nonzero if this argument is a named parameter
1419 (otherwise it is an extra parameter matching an ellipsis).
1421 On RS/6000 the first eight words of non-FP are normally in registers
1422 and the rest are pushed. Under AIX, the first 13 FP args are in registers.
1423 Under V.4, the first 8 FP args are in registers.
1425 If this is floating-point and no prototype is specified, we use
1426 both an FP and integer register (or possibly FP reg and stack). Library
1427 functions (when TYPE is zero) always have the proper types for args,
1428 so we can pass the FP value just in one register. emit_library_function
1429 doesn't support PARALLEL anyway. */
1432 function_arg (cum
, mode
, type
, named
)
1433 CUMULATIVE_ARGS
*cum
;
1434 enum machine_mode mode
;
1438 int align
= (TARGET_32BIT
&& (cum
->words
& 1) != 0
1439 && function_arg_boundary (mode
, type
) == 64) ? 1 : 0;
1440 int align_words
= cum
->words
+ align
;
1442 if (TARGET_DEBUG_ARG
)
1444 "function_arg: words = %2d, fregno = %2d, nargs = %4d, proto = %d, mode = %4s, named = %d, align = %d\n",
1445 cum
->words
, cum
->fregno
, cum
->nargs_prototype
, cum
->prototype
, GET_MODE_NAME (mode
), named
, align
);
1447 /* Return a marker to indicate whether CR1 needs to set or clear the bit that V.4
1448 uses to say fp args were passed in registers. Assume that we don't need the
1449 marker for software floating point, or compiler generated library calls. */
1450 if (mode
== VOIDmode
)
1452 enum rs6000_abi abi
= DEFAULT_ABI
;
1454 if ((abi
== ABI_V4
|| abi
== ABI_SOLARIS
)
1455 && TARGET_HARD_FLOAT
1456 && cum
->nargs_prototype
< 0
1457 && type
&& (cum
->prototype
|| TARGET_NO_PROTOTYPE
))
1459 return GEN_INT (cum
->call_cookie
1460 | ((cum
->fregno
== FP_ARG_MIN_REG
)
1461 ? CALL_V4_SET_FP_ARGS
1462 : CALL_V4_CLEAR_FP_ARGS
));
1465 return GEN_INT (cum
->call_cookie
);
1470 if (DEFAULT_ABI
!= ABI_V4
&& DEFAULT_ABI
!= ABI_SOLARIS
)
1474 if (type
&& TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1477 if (USE_FP_FOR_ARG_P (*cum
, mode
, type
))
1479 if (DEFAULT_ABI
== ABI_V4
/* V.4 never passes FP values in GP registers */
1480 || DEFAULT_ABI
== ABI_SOLARIS
1482 || ((cum
->nargs_prototype
> 0)
1483 /* IBM AIX extended its linkage convention definition always to
1484 require FP args after register save area hole on the stack. */
1485 && (DEFAULT_ABI
!= ABI_AIX
1487 || (align_words
< GP_ARG_NUM_REG
))))
1488 return gen_rtx_REG (mode
, cum
->fregno
);
1490 return gen_rtx_PARALLEL (mode
,
1493 gen_rtx_EXPR_LIST (VOIDmode
,
1494 ((align_words
>= GP_ARG_NUM_REG
)
1497 + RS6000_ARG_SIZE (mode
, type
, named
)
1499 /* If this is partially on the stack, then
1500 we only include the portion actually
1501 in registers here. */
1502 ? gen_rtx_REG (SImode
,
1503 GP_ARG_MIN_REG
+ align_words
)
1504 : gen_rtx_REG (mode
,
1505 GP_ARG_MIN_REG
+ align_words
))),
1507 gen_rtx_EXPR_LIST (VOIDmode
,
1508 gen_rtx_REG (mode
, cum
->fregno
),
1512 /* Long longs won't be split between register and stack;
1513 FP arguments get passed on the stack if they didn't get a register. */
1514 else if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
) &&
1515 (align_words
+ RS6000_ARG_SIZE (mode
, type
, named
) > GP_ARG_NUM_REG
1516 || (GET_MODE_CLASS (mode
) == MODE_FLOAT
&& TARGET_HARD_FLOAT
)))
1521 else if (align_words
< GP_ARG_NUM_REG
)
1522 return gen_rtx_REG (mode
, GP_ARG_MIN_REG
+ align_words
);
1527 /* For an arg passed partly in registers and partly in memory,
1528 this is the number of registers used.
1529 For args passed entirely in registers or entirely in memory, zero. */
1532 function_arg_partial_nregs (cum
, mode
, type
, named
)
1533 CUMULATIVE_ARGS
*cum
;
1534 enum machine_mode mode
;
1541 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
1544 if (USE_FP_FOR_ARG_P (*cum
, mode
, type
))
1546 if (cum
->nargs_prototype
>= 0)
1550 if (cum
->words
< GP_ARG_NUM_REG
1551 && GP_ARG_NUM_REG
< (cum
->words
+ RS6000_ARG_SIZE (mode
, type
, named
)))
1553 int ret
= GP_ARG_NUM_REG
- cum
->words
;
1554 if (ret
&& TARGET_DEBUG_ARG
)
1555 fprintf (stderr
, "function_arg_partial_nregs: %d\n", ret
);
1563 /* A C expression that indicates when an argument must be passed by
1564 reference. If nonzero for an argument, a copy of that argument is
1565 made in memory and a pointer to the argument is passed instead of
1566 the argument itself. The pointer is passed in whatever way is
1567 appropriate for passing a pointer to that type.
1569 Under V.4, structures and unions are passed by reference. */
1572 function_arg_pass_by_reference (cum
, mode
, type
, named
)
1573 CUMULATIVE_ARGS
*cum ATTRIBUTE_UNUSED
;
1574 enum machine_mode mode ATTRIBUTE_UNUSED
;
1576 int named ATTRIBUTE_UNUSED
;
1578 if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
1579 && type
&& AGGREGATE_TYPE_P (type
))
1581 if (TARGET_DEBUG_ARG
)
1582 fprintf (stderr
, "function_arg_pass_by_reference: aggregate\n");
1591 /* Perform any needed actions needed for a function that is receiving a
1592 variable number of arguments.
1596 MODE and TYPE are the mode and type of the current parameter.
1598 PRETEND_SIZE is a variable that should be set to the amount of stack
1599 that must be pushed by the prolog to pretend that our caller pushed
1602 Normally, this macro will push all remaining incoming registers on the
1603 stack and set PRETEND_SIZE to the length of the registers pushed. */
1606 setup_incoming_varargs (cum
, mode
, type
, pretend_size
, no_rtl
)
1607 CUMULATIVE_ARGS
*cum
;
1608 enum machine_mode mode
;
1614 rtx save_area
= virtual_incoming_args_rtx
;
1615 int reg_size
= TARGET_32BIT
? 4 : 8;
1617 if (TARGET_DEBUG_ARG
)
1619 "setup_vararg: words = %2d, fregno = %2d, nargs = %4d, proto = %d, mode = %4s, no_rtl= %d\n",
1620 cum
->words
, cum
->fregno
, cum
->nargs_prototype
, cum
->prototype
, GET_MODE_NAME (mode
), no_rtl
);
1622 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
1624 rs6000_sysv_varargs_p
= 1;
1626 save_area
= plus_constant (virtual_stack_vars_rtx
,
1627 - RS6000_VARARGS_SIZE
);
1630 rs6000_sysv_varargs_p
= 0;
1634 int first_reg_offset
= cum
->words
;
1636 if (MUST_PASS_IN_STACK (mode
, type
))
1637 first_reg_offset
+= RS6000_ARG_SIZE (TYPE_MODE (type
), type
, 1);
1639 if (first_reg_offset
> GP_ARG_NUM_REG
)
1640 first_reg_offset
= GP_ARG_NUM_REG
;
1642 if (!no_rtl
&& first_reg_offset
!= GP_ARG_NUM_REG
)
1644 (GP_ARG_MIN_REG
+ first_reg_offset
,
1645 gen_rtx_MEM (BLKmode
,
1646 plus_constant (save_area
, first_reg_offset
* reg_size
)),
1647 GP_ARG_NUM_REG
- first_reg_offset
,
1648 (GP_ARG_NUM_REG
- first_reg_offset
) * UNITS_PER_WORD
);
1650 *pretend_size
= (GP_ARG_NUM_REG
- first_reg_offset
) * UNITS_PER_WORD
;
1653 /* Save FP registers if needed. */
1654 if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
) && TARGET_HARD_FLOAT
&& !no_rtl
)
1656 int fregno
= cum
->fregno
;
1657 int num_fp_reg
= FP_ARG_V4_MAX_REG
+ 1 - fregno
;
1659 if (num_fp_reg
>= 0)
1661 rtx cr1
= gen_rtx_REG (CCmode
, 69);
1662 rtx lab
= gen_label_rtx ();
1663 int off
= (GP_ARG_NUM_REG
* reg_size
) + ((fregno
- FP_ARG_MIN_REG
) * 8);
1665 emit_jump_insn (gen_rtx_SET (VOIDmode
,
1667 gen_rtx_IF_THEN_ELSE (VOIDmode
,
1668 gen_rtx_NE (VOIDmode
, cr1
, const0_rtx
),
1669 gen_rtx_LABEL_REF (VOIDmode
, lab
),
1672 while ( num_fp_reg
-- >= 0)
1674 emit_move_insn (gen_rtx_MEM (DFmode
, plus_constant (save_area
, off
)),
1675 gen_rtx_REG (DFmode
, fregno
++));
1684 /* If defined, is a C expression that produces the machine-specific
1685 code for a call to `__builtin_saveregs'. This code will be moved
1686 to the very beginning of the function, before any parameter access
1687 are made. The return value of this function should be an RTX that
1688 contains the value to use as the return of `__builtin_saveregs'.
1690 The argument ARGS is a `tree_list' containing the arguments that
1691 were passed to `__builtin_saveregs'.
1693 If this macro is not defined, the compiler will output an ordinary
1694 call to the library function `__builtin_saveregs'.
1696 On the Power/PowerPC return the address of the area on the stack
1697 used to hold arguments. Under AIX, this includes the 8 word register
1700 Under V.4, things are more complicated. We do not have access to
1701 all of the virtual registers required for va_start to do its job,
1702 so we construct the va_list in its entirity here, and reduce va_start
1703 to a block copy. This is similar to the way we do things on Alpha. */
1706 expand_builtin_saveregs (args
)
1707 tree args ATTRIBUTE_UNUSED
;
1709 rtx block
, mem_gpr_fpr
, mem_reg_save_area
, mem_overflow
, tmp
;
1712 HOST_WIDE_INT words
, gpr
, fpr
;
1714 if (DEFAULT_ABI
!= ABI_V4
&& DEFAULT_ABI
!= ABI_SOLARIS
)
1715 return virtual_incoming_args_rtx
;
1717 fntype
= TREE_TYPE (current_function_decl
);
1718 stdarg_p
= (TYPE_ARG_TYPES (fntype
) != 0
1719 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype
)))
1720 != void_type_node
));
1722 /* Allocate the va_list constructor. */
1723 block
= assign_stack_local (BLKmode
, 3 * UNITS_PER_WORD
, BITS_PER_WORD
);
1724 RTX_UNCHANGING_P (block
) = 1;
1725 RTX_UNCHANGING_P (XEXP (block
, 0)) = 1;
1727 mem_gpr_fpr
= change_address (block
, word_mode
, XEXP (block
, 0));
1728 mem_overflow
= change_address (block
, ptr_mode
,
1729 plus_constant (XEXP (block
, 0),
1731 mem_reg_save_area
= change_address (block
, ptr_mode
,
1732 plus_constant (XEXP (block
, 0),
1733 2 * UNITS_PER_WORD
));
1735 /* Construct the two characters of `gpr' and `fpr' as a unit. */
1736 words
= current_function_args_info
.words
- !stdarg_p
;
1737 gpr
= (words
> 8 ? 8 : words
);
1738 fpr
= current_function_args_info
.fregno
- 33;
1740 if (BYTES_BIG_ENDIAN
)
1742 HOST_WIDE_INT bits
= gpr
<< 8 | fpr
;
1743 if (HOST_BITS_PER_WIDE_INT
>= BITS_PER_WORD
)
1744 tmp
= GEN_INT (bits
<< (BITS_PER_WORD
- 16));
1747 bits
<<= BITS_PER_WORD
- HOST_BITS_PER_WIDE_INT
- 16;
1748 tmp
= immed_double_const (0, bits
, word_mode
);
1752 tmp
= GEN_INT (fpr
<< 8 | gpr
);
1754 emit_move_insn (mem_gpr_fpr
, tmp
);
1756 /* Find the overflow area. */
1758 tmp
= virtual_incoming_args_rtx
;
1760 tmp
= expand_binop (Pmode
, add_optab
, virtual_incoming_args_rtx
,
1761 GEN_INT ((words
- 8) * UNITS_PER_WORD
),
1762 mem_overflow
, 0, OPTAB_WIDEN
);
1763 if (tmp
!= mem_overflow
)
1764 emit_move_insn (mem_overflow
, tmp
);
1766 /* Find the register save area. */
1767 tmp
= expand_binop (Pmode
, add_optab
, virtual_stack_vars_rtx
,
1768 GEN_INT (-RS6000_VARARGS_SIZE
),
1769 mem_reg_save_area
, 0, OPTAB_WIDEN
);
1770 if (tmp
!= mem_reg_save_area
)
1771 emit_move_insn (mem_reg_save_area
, tmp
);
1773 /* Return the address of the va_list constructor. */
1774 return XEXP (block
, 0);
1778 /* Generate a memory reference for expand_block_move, copying volatile,
1779 and other bits from an original memory reference. */
1782 expand_block_move_mem (mode
, addr
, orig_mem
)
1783 enum machine_mode mode
;
1787 rtx mem
= gen_rtx_MEM (mode
, addr
);
1789 RTX_UNCHANGING_P (mem
) = RTX_UNCHANGING_P (orig_mem
);
1790 MEM_COPY_ATTRIBUTES (mem
, orig_mem
);
1791 #ifdef MEM_UNALIGNED_P
1792 MEM_UNALIGNED_P (mem
) = MEM_UNALIGNED_P (orig_mem
);
1797 /* Expand a block move operation, and return 1 if successful. Return 0
1798 if we should let the compiler generate normal code.
1800 operands[0] is the destination
1801 operands[1] is the source
1802 operands[2] is the length
1803 operands[3] is the alignment */
1805 #define MAX_MOVE_REG 4
1808 expand_block_move (operands
)
1811 rtx orig_dest
= operands
[0];
1812 rtx orig_src
= operands
[1];
1813 rtx bytes_rtx
= operands
[2];
1814 rtx align_rtx
= operands
[3];
1815 int constp
= (GET_CODE (bytes_rtx
) == CONST_INT
);
1816 int align
= XINT (align_rtx
, 0);
1826 rtx stores
[MAX_MOVE_REG
];
1829 /* If this is not a fixed size move, just call memcpy */
1833 /* Anything to move? */
1834 bytes
= INTVAL (bytes_rtx
);
1838 /* Don't support real large moves. If string instructions are not used,
1839 then don't generate more than 8 loads. */
1845 else if (!STRICT_ALIGNMENT
)
1850 else if (bytes
> 8*align
)
1853 /* Move the address into scratch registers. */
1854 dest_reg
= copy_addr_to_reg (XEXP (orig_dest
, 0));
1855 src_reg
= copy_addr_to_reg (XEXP (orig_src
, 0));
1857 if (TARGET_STRING
) /* string instructions are available */
1859 for ( ; bytes
> 0; bytes
-= move_bytes
)
1861 if (bytes
> 24 /* move up to 32 bytes at a time */
1871 move_bytes
= (bytes
> 32) ? 32 : bytes
;
1872 emit_insn (gen_movstrsi_8reg (expand_block_move_mem (BLKmode
, dest_reg
, orig_dest
),
1873 expand_block_move_mem (BLKmode
, src_reg
, orig_src
),
1874 GEN_INT ((move_bytes
== 32) ? 0 : move_bytes
),
1877 else if (bytes
> 16 /* move up to 24 bytes at a time */
1885 move_bytes
= (bytes
> 24) ? 24 : bytes
;
1886 emit_insn (gen_movstrsi_6reg (expand_block_move_mem (BLKmode
, dest_reg
, orig_dest
),
1887 expand_block_move_mem (BLKmode
, src_reg
, orig_src
),
1888 GEN_INT (move_bytes
),
1891 else if (bytes
> 8 /* move up to 16 bytes at a time */
1897 move_bytes
= (bytes
> 16) ? 16 : bytes
;
1898 emit_insn (gen_movstrsi_4reg (expand_block_move_mem (BLKmode
, dest_reg
, orig_dest
),
1899 expand_block_move_mem (BLKmode
, src_reg
, orig_src
),
1900 GEN_INT (move_bytes
),
1903 else if (bytes
> 4 && !TARGET_64BIT
)
1904 { /* move up to 8 bytes at a time */
1905 move_bytes
= (bytes
> 8) ? 8 : bytes
;
1906 emit_insn (gen_movstrsi_2reg (expand_block_move_mem (BLKmode
, dest_reg
, orig_dest
),
1907 expand_block_move_mem (BLKmode
, src_reg
, orig_src
),
1908 GEN_INT (move_bytes
),
1911 else if (bytes
>= 4 && (align
>= 4 || !STRICT_ALIGNMENT
))
1912 { /* move 4 bytes */
1914 tmp_reg
= gen_reg_rtx (SImode
);
1915 emit_move_insn (tmp_reg
, expand_block_move_mem (SImode
, src_reg
, orig_src
));
1916 emit_move_insn (expand_block_move_mem (SImode
, dest_reg
, orig_dest
), tmp_reg
);
1918 else if (bytes
== 2 && (align
>= 2 || !STRICT_ALIGNMENT
))
1919 { /* move 2 bytes */
1921 tmp_reg
= gen_reg_rtx (HImode
);
1922 emit_move_insn (tmp_reg
, expand_block_move_mem (HImode
, src_reg
, orig_src
));
1923 emit_move_insn (expand_block_move_mem (HImode
, dest_reg
, orig_dest
), tmp_reg
);
1925 else if (bytes
== 1) /* move 1 byte */
1928 tmp_reg
= gen_reg_rtx (QImode
);
1929 emit_move_insn (tmp_reg
, expand_block_move_mem (QImode
, src_reg
, orig_src
));
1930 emit_move_insn (expand_block_move_mem (QImode
, dest_reg
, orig_dest
), tmp_reg
);
1933 { /* move up to 4 bytes at a time */
1934 move_bytes
= (bytes
> 4) ? 4 : bytes
;
1935 emit_insn (gen_movstrsi_1reg (expand_block_move_mem (BLKmode
, dest_reg
, orig_dest
),
1936 expand_block_move_mem (BLKmode
, src_reg
, orig_src
),
1937 GEN_INT (move_bytes
),
1941 if (bytes
> move_bytes
)
1943 emit_insn (gen_addsi3 (src_reg
, src_reg
, GEN_INT (move_bytes
)));
1944 emit_insn (gen_addsi3 (dest_reg
, dest_reg
, GEN_INT (move_bytes
)));
1949 else /* string instructions not available */
1951 num_reg
= offset
= 0;
1952 for ( ; bytes
> 0; (bytes
-= move_bytes
), (offset
+= move_bytes
))
1954 /* Calculate the correct offset for src/dest */
1958 dest_addr
= dest_reg
;
1962 src_addr
= gen_rtx_PLUS (Pmode
, src_reg
, GEN_INT (offset
));
1963 dest_addr
= gen_rtx_PLUS (Pmode
, dest_reg
, GEN_INT (offset
));
1966 /* Generate the appropriate load and store, saving the stores for later */
1967 if (bytes
>= 8 && TARGET_64BIT
&& (align
>= 8 || !STRICT_ALIGNMENT
))
1970 tmp_reg
= gen_reg_rtx (DImode
);
1971 emit_insn (gen_movdi (tmp_reg
, expand_block_move_mem (DImode
, src_addr
, orig_src
)));
1972 stores
[ num_reg
++ ] = gen_movdi (expand_block_move_mem (DImode
, dest_addr
, orig_dest
), tmp_reg
);
1974 else if (bytes
>= 4 && (align
>= 4 || !STRICT_ALIGNMENT
))
1977 tmp_reg
= gen_reg_rtx (SImode
);
1978 emit_insn (gen_movsi (tmp_reg
, expand_block_move_mem (SImode
, src_addr
, orig_src
)));
1979 stores
[ num_reg
++ ] = gen_movsi (expand_block_move_mem (SImode
, dest_addr
, orig_dest
), tmp_reg
);
1981 else if (bytes
>= 2 && (align
>= 2 || !STRICT_ALIGNMENT
))
1984 tmp_reg
= gen_reg_rtx (HImode
);
1985 emit_insn (gen_movsi (tmp_reg
, expand_block_move_mem (HImode
, src_addr
, orig_src
)));
1986 stores
[ num_reg
++ ] = gen_movhi (expand_block_move_mem (HImode
, dest_addr
, orig_dest
), tmp_reg
);
1991 tmp_reg
= gen_reg_rtx (QImode
);
1992 emit_insn (gen_movsi (tmp_reg
, expand_block_move_mem (QImode
, src_addr
, orig_src
)));
1993 stores
[ num_reg
++ ] = gen_movqi (expand_block_move_mem (QImode
, dest_addr
, orig_dest
), tmp_reg
);
1996 if (num_reg
>= MAX_MOVE_REG
)
1998 for (i
= 0; i
< num_reg
; i
++)
1999 emit_insn (stores
[i
]);
2004 for (i
= 0; i
< num_reg
; i
++)
2005 emit_insn (stores
[i
]);
2012 /* Return 1 if OP is a load multiple operation. It is known to be a
2013 PARALLEL and the first section will be tested. */
2016 load_multiple_operation (op
, mode
)
2018 enum machine_mode mode ATTRIBUTE_UNUSED
;
2020 int count
= XVECLEN (op
, 0);
2025 /* Perform a quick check so we don't blow up below. */
2027 || GET_CODE (XVECEXP (op
, 0, 0)) != SET
2028 || GET_CODE (SET_DEST (XVECEXP (op
, 0, 0))) != REG
2029 || GET_CODE (SET_SRC (XVECEXP (op
, 0, 0))) != MEM
)
2032 dest_regno
= REGNO (SET_DEST (XVECEXP (op
, 0, 0)));
2033 src_addr
= XEXP (SET_SRC (XVECEXP (op
, 0, 0)), 0);
2035 for (i
= 1; i
< count
; i
++)
2037 rtx elt
= XVECEXP (op
, 0, i
);
2039 if (GET_CODE (elt
) != SET
2040 || GET_CODE (SET_DEST (elt
)) != REG
2041 || GET_MODE (SET_DEST (elt
)) != SImode
2042 || REGNO (SET_DEST (elt
)) != dest_regno
+ i
2043 || GET_CODE (SET_SRC (elt
)) != MEM
2044 || GET_MODE (SET_SRC (elt
)) != SImode
2045 || GET_CODE (XEXP (SET_SRC (elt
), 0)) != PLUS
2046 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt
), 0), 0), src_addr
)
2047 || GET_CODE (XEXP (XEXP (SET_SRC (elt
), 0), 1)) != CONST_INT
2048 || INTVAL (XEXP (XEXP (SET_SRC (elt
), 0), 1)) != i
* 4)
2055 /* Similar, but tests for store multiple. Here, the second vector element
2056 is a CLOBBER. It will be tested later. */
2059 store_multiple_operation (op
, mode
)
2061 enum machine_mode mode ATTRIBUTE_UNUSED
;
2063 int count
= XVECLEN (op
, 0) - 1;
2068 /* Perform a quick check so we don't blow up below. */
2070 || GET_CODE (XVECEXP (op
, 0, 0)) != SET
2071 || GET_CODE (SET_DEST (XVECEXP (op
, 0, 0))) != MEM
2072 || GET_CODE (SET_SRC (XVECEXP (op
, 0, 0))) != REG
)
2075 src_regno
= REGNO (SET_SRC (XVECEXP (op
, 0, 0)));
2076 dest_addr
= XEXP (SET_DEST (XVECEXP (op
, 0, 0)), 0);
2078 for (i
= 1; i
< count
; i
++)
2080 rtx elt
= XVECEXP (op
, 0, i
+ 1);
2082 if (GET_CODE (elt
) != SET
2083 || GET_CODE (SET_SRC (elt
)) != REG
2084 || GET_MODE (SET_SRC (elt
)) != SImode
2085 || REGNO (SET_SRC (elt
)) != src_regno
+ i
2086 || GET_CODE (SET_DEST (elt
)) != MEM
2087 || GET_MODE (SET_DEST (elt
)) != SImode
2088 || GET_CODE (XEXP (SET_DEST (elt
), 0)) != PLUS
2089 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt
), 0), 0), dest_addr
)
2090 || GET_CODE (XEXP (XEXP (SET_DEST (elt
), 0), 1)) != CONST_INT
2091 || INTVAL (XEXP (XEXP (SET_DEST (elt
), 0), 1)) != i
* 4)
2098 /* Return 1 if OP is a comparison operation that is valid for a branch insn.
2099 We only check the opcode against the mode of the CC value here. */
2102 branch_comparison_operator (op
, mode
)
2104 enum machine_mode mode ATTRIBUTE_UNUSED
;
2106 enum rtx_code code
= GET_CODE (op
);
2107 enum machine_mode cc_mode
;
2109 if (GET_RTX_CLASS (code
) != '<')
2112 cc_mode
= GET_MODE (XEXP (op
, 0));
2113 if (GET_MODE_CLASS (cc_mode
) != MODE_CC
)
2116 if ((code
== GT
|| code
== LT
|| code
== GE
|| code
== LE
)
2117 && cc_mode
== CCUNSmode
)
2120 if ((code
== GTU
|| code
== LTU
|| code
== GEU
|| code
== LEU
)
2121 && (cc_mode
!= CCUNSmode
))
2127 /* Return 1 if OP is a comparison operation that is valid for an scc insn.
2128 We check the opcode against the mode of the CC value and disallow EQ or
2129 NE comparisons for integers. */
2132 scc_comparison_operator (op
, mode
)
2134 enum machine_mode mode
;
2136 enum rtx_code code
= GET_CODE (op
);
2137 enum machine_mode cc_mode
;
2139 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
2142 if (GET_RTX_CLASS (code
) != '<')
2145 cc_mode
= GET_MODE (XEXP (op
, 0));
2146 if (GET_MODE_CLASS (cc_mode
) != MODE_CC
)
2149 if (code
== NE
&& cc_mode
!= CCFPmode
)
2152 if ((code
== GT
|| code
== LT
|| code
== GE
|| code
== LE
)
2153 && cc_mode
== CCUNSmode
)
2156 if ((code
== GTU
|| code
== LTU
|| code
== GEU
|| code
== LEU
)
2157 && (cc_mode
!= CCUNSmode
))
2160 if (cc_mode
== CCEQmode
&& code
!= EQ
&& code
!= NE
)
2167 trap_comparison_operator (op
, mode
)
2169 enum machine_mode mode
;
2171 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
2173 return (GET_RTX_CLASS (GET_CODE (op
)) == '<'
2174 || GET_CODE (op
) == EQ
|| GET_CODE (op
) == NE
);
2177 /* Return 1 if ANDOP is a mask that has no bits on that are not in the
2178 mask required to convert the result of a rotate insn into a shift
2179 left insn of SHIFTOP bits. Both are known to be CONST_INT. */
2182 includes_lshift_p (shiftop
, andop
)
2183 register rtx shiftop
;
2186 int shift_mask
= (~0 << INTVAL (shiftop
));
2188 return (INTVAL (andop
) & ~shift_mask
) == 0;
2191 /* Similar, but for right shift. */
2194 includes_rshift_p (shiftop
, andop
)
2195 register rtx shiftop
;
2198 unsigned HOST_WIDE_INT shift_mask
= ~(unsigned HOST_WIDE_INT
) 0;
2200 shift_mask
>>= INTVAL (shiftop
);
2202 return (INTVAL (andop
) & ~ shift_mask
) == 0;
2205 /* Return 1 if REGNO (reg1) == REGNO (reg2) - 1 making them candidates
2206 for lfq and stfq insns.
2208 Note reg1 and reg2 *must* be hard registers. To be sure we will
2209 abort if we are passed pseudo registers. */
2212 registers_ok_for_quad_peep (reg1
, reg2
)
2215 /* We might have been passed a SUBREG. */
2216 if (GET_CODE (reg1
) != REG
|| GET_CODE (reg2
) != REG
)
2219 return (REGNO (reg1
) == REGNO (reg2
) - 1);
2222 /* Return 1 if addr1 and addr2 are suitable for lfq or stfq insn. addr1 and
2223 addr2 must be in consecutive memory locations (addr2 == addr1 + 8). */
2226 addrs_ok_for_quad_peep (addr1
, addr2
)
2233 /* Extract an offset (if used) from the first addr. */
2234 if (GET_CODE (addr1
) == PLUS
)
2236 /* If not a REG, return zero. */
2237 if (GET_CODE (XEXP (addr1
, 0)) != REG
)
2241 reg1
= REGNO (XEXP (addr1
, 0));
2242 /* The offset must be constant! */
2243 if (GET_CODE (XEXP (addr1
, 1)) != CONST_INT
)
2245 offset1
= INTVAL (XEXP (addr1
, 1));
2248 else if (GET_CODE (addr1
) != REG
)
2252 reg1
= REGNO (addr1
);
2253 /* This was a simple (mem (reg)) expression. Offset is 0. */
2257 /* Make sure the second address is a (mem (plus (reg) (const_int). */
2258 if (GET_CODE (addr2
) != PLUS
)
2261 if (GET_CODE (XEXP (addr2
, 0)) != REG
2262 || GET_CODE (XEXP (addr2
, 1)) != CONST_INT
)
2265 if (reg1
!= REGNO (XEXP (addr2
, 0)))
2268 /* The offset for the second addr must be 8 more than the first addr. */
2269 if (INTVAL (XEXP (addr2
, 1)) != offset1
+ 8)
2272 /* All the tests passed. addr1 and addr2 are valid for lfq or stfq
2277 /* Return the register class of a scratch register needed to copy IN into
2278 or out of a register in CLASS in MODE. If it can be done directly,
2279 NO_REGS is returned. */
2282 secondary_reload_class (class, mode
, in
)
2283 enum reg_class
class;
2284 enum machine_mode mode ATTRIBUTE_UNUSED
;
2289 /* We can not copy a symbolic operand directly into anything other than
2290 BASE_REGS for TARGET_ELF. So indicate that a register from BASE_REGS
2291 is needed as an intermediate register. */
2293 && class != BASE_REGS
2294 && (GET_CODE (in
) == SYMBOL_REF
2295 || GET_CODE (in
) == LABEL_REF
2296 || GET_CODE (in
) == CONST
))
2299 if (GET_CODE (in
) == REG
)
2302 if (regno
>= FIRST_PSEUDO_REGISTER
)
2304 regno
= true_regnum (in
);
2305 if (regno
>= FIRST_PSEUDO_REGISTER
)
2309 else if (GET_CODE (in
) == SUBREG
)
2311 regno
= true_regnum (in
);
2312 if (regno
>= FIRST_PSEUDO_REGISTER
)
2318 /* We can place anything into GENERAL_REGS and can put GENERAL_REGS
2320 if (class == GENERAL_REGS
|| class == BASE_REGS
2321 || (regno
>= 0 && INT_REGNO_P (regno
)))
2324 /* Constants, memory, and FP registers can go into FP registers. */
2325 if ((regno
== -1 || FP_REGNO_P (regno
))
2326 && (class == FLOAT_REGS
|| class == NON_SPECIAL_REGS
))
2329 /* We can copy among the CR registers. */
2330 if ((class == CR_REGS
|| class == CR0_REGS
)
2331 && regno
>= 0 && CR_REGNO_P (regno
))
2334 /* Otherwise, we need GENERAL_REGS. */
2335 return GENERAL_REGS
;
2338 /* Given a comparison operation, return the bit number in CCR to test. We
2339 know this is a valid comparison.
2341 SCC_P is 1 if this is for an scc. That means that %D will have been
2342 used instead of %C, so the bits will be in different places.
2344 Return -1 if OP isn't a valid comparison for some reason. */
2351 enum rtx_code code
= GET_CODE (op
);
2352 enum machine_mode cc_mode
;
2356 if (GET_RTX_CLASS (code
) != '<')
2359 cc_mode
= GET_MODE (XEXP (op
, 0));
2360 cc_regnum
= REGNO (XEXP (op
, 0));
2361 base_bit
= 4 * (cc_regnum
- 68);
2363 /* In CCEQmode cases we have made sure that the result is always in the
2364 third bit of the CR field. */
2366 if (cc_mode
== CCEQmode
)
2367 return base_bit
+ 3;
2372 return scc_p
? base_bit
+ 3 : base_bit
+ 2;
2374 return base_bit
+ 2;
2376 return base_bit
+ 1;
2381 /* If floating-point, we will have done a cror to put the bit in the
2382 unordered position. So test that bit. For integer, this is ! LT
2383 unless this is an scc insn. */
2384 return cc_mode
== CCFPmode
|| scc_p
? base_bit
+ 3 : base_bit
;
2387 return cc_mode
== CCFPmode
|| scc_p
? base_bit
+ 3 : base_bit
+ 1;
2394 /* Return the GOT register, creating it if needed. */
2397 rs6000_got_register (value
)
2400 if (! current_function_uses_pic_offset_table
|| ! pic_offset_table_rtx
)
2403 fatal_insn ("internal error -- needed new GOT register during reload phase to load:",
2406 current_function_uses_pic_offset_table
= 1;
2407 pic_offset_table_rtx
= gen_rtx_REG (Pmode
, GOT_TOC_REGNUM
);
2410 return pic_offset_table_rtx
;
2414 /* Replace all occurrences of register FROM with an new pseudo register in an insn X.
2415 Store the pseudo register used in REG.
2416 This is only safe during FINALIZE_PIC, since the registers haven't been setup
2420 rs6000_replace_regno (x
, from
, reg
)
2426 register const char *fmt
;
2428 /* Allow this function to make replacements in EXPR_LISTs. */
2432 switch (GET_CODE (x
))
2445 if (REGNO (x
) == from
)
2448 *reg
= pic_offset_table_rtx
= gen_reg_rtx (Pmode
);
2459 fmt
= GET_RTX_FORMAT (GET_CODE (x
));
2460 for (i
= GET_RTX_LENGTH (GET_CODE (x
)) - 1; i
>= 0; i
--)
2463 XEXP (x
, i
) = rs6000_replace_regno (XEXP (x
, i
), from
, reg
);
2464 else if (fmt
[i
] == 'E')
2465 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
2466 XVECEXP (x
, i
, j
) = rs6000_replace_regno (XVECEXP (x
, i
, j
), from
, reg
);
2473 /* By generating position-independent code, when two different
2474 programs (A and B) share a common library (libC.a), the text of
2475 the library can be shared whether or not the library is linked at
2476 the same address for both programs. In some of these
2477 environments, position-independent code requires not only the use
2478 of different addressing modes, but also special code to enable the
2479 use of these addressing modes.
2481 The `FINALIZE_PIC' macro serves as a hook to emit these special
2482 codes once the function is being compiled into assembly code, but
2483 not before. (It is not done before, because in the case of
2484 compiling an inline function, it would lead to multiple PIC
2485 prologues being included in functions which used inline functions
2486 and were compiled to assembly language.) */
2489 rs6000_finalize_pic ()
2491 /* Loop through all of the insns, replacing the special GOT_TOC_REGNUM
2492 with an appropriate pseudo register. If we find we need GOT/TOC,
2493 add the appropriate init code. */
2494 if (flag_pic
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
2496 rtx insn
= get_insns ();
2499 rtx last_insn
= NULL_RTX
;
2501 if (GET_CODE (insn
) == NOTE
)
2502 insn
= next_nonnote_insn (insn
);
2505 for ( ; insn
!= NULL_RTX
; insn
= NEXT_INSN (insn
))
2507 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
2509 PATTERN (insn
) = rs6000_replace_regno (PATTERN (insn
),
2513 if (REG_NOTES (insn
))
2514 REG_NOTES (insn
) = rs6000_replace_regno (REG_NOTES (insn
),
2519 if (GET_CODE (insn
) != NOTE
)
2525 rtx init
= gen_init_v4_pic (reg
);
2526 emit_insn_before (init
, first_insn
);
2527 if (!optimize
&& last_insn
)
2528 emit_insn_after (gen_rtx_USE (VOIDmode
, reg
), last_insn
);
2534 /* Search for any occurrence of the GOT_TOC register marker that should
2535 have been eliminated, but may have crept back in. */
2541 if (flag_pic
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
2543 rtx got_reg
= gen_rtx_REG (Pmode
, GOT_TOC_REGNUM
);
2544 for ( ; insn
!= NULL_RTX
; insn
= NEXT_INSN (insn
))
2545 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i'
2546 && reg_mentioned_p (got_reg
, PATTERN (insn
)))
2547 fatal_insn ("GOT/TOC register marker not removed:", PATTERN (insn
));
2552 /* Define the structure for the machine field in struct function. */
2553 struct machine_function
2559 rtx pic_offset_table_rtx
;
2562 /* Functions to save and restore rs6000_fpmem_size.
2563 These will be called, via pointer variables,
2564 from push_function_context and pop_function_context. */
2567 rs6000_save_machine_status (p
)
2570 struct machine_function
*machine
=
2571 (struct machine_function
*) xmalloc (sizeof (struct machine_function
));
2573 p
->machine
= machine
;
2574 machine
->sysv_varargs_p
= rs6000_sysv_varargs_p
;
2575 machine
->fpmem_size
= rs6000_fpmem_size
;
2576 machine
->fpmem_offset
= rs6000_fpmem_offset
;
2577 machine
->pic_offset_table_rtx
= pic_offset_table_rtx
;
2581 rs6000_restore_machine_status (p
)
2584 struct machine_function
*machine
= p
->machine
;
2586 rs6000_sysv_varargs_p
= machine
->sysv_varargs_p
;
2587 rs6000_fpmem_size
= machine
->fpmem_size
;
2588 rs6000_fpmem_offset
= machine
->fpmem_offset
;
2589 pic_offset_table_rtx
= machine
->pic_offset_table_rtx
;
2592 p
->machine
= (struct machine_function
*)0;
2595 /* Do anything needed before RTL is emitted for each function. */
2598 rs6000_init_expanders ()
2600 /* Reset varargs and save TOC indicator */
2601 rs6000_sysv_varargs_p
= 0;
2602 rs6000_fpmem_size
= 0;
2603 rs6000_fpmem_offset
= 0;
2604 pic_offset_table_rtx
= (rtx
)0;
2606 /* Arrange to save and restore machine status around nested functions. */
2607 save_machine_status
= rs6000_save_machine_status
;
2608 restore_machine_status
= rs6000_restore_machine_status
;
2612 /* Print an operand. Recognize special options, documented below. */
2615 #define SMALL_DATA_RELOC ((rs6000_sdata == SDATA_EABI) ? "sda21" : "sdarel")
2616 #define SMALL_DATA_REG ((rs6000_sdata == SDATA_EABI) ? 0 : 13)
2618 #define SMALL_DATA_RELOC "sda21"
2619 #define SMALL_DATA_REG 0
2623 print_operand (file
, x
, code
)
2631 /* These macros test for integers and extract the low-order bits. */
2633 ((GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE) \
2634 && GET_MODE (X) == VOIDmode)
2636 #define INT_LOWPART(X) \
2637 (GET_CODE (X) == CONST_INT ? INTVAL (X) : CONST_DOUBLE_LOW (X))
2642 /* Write out an instruction after the call which may be replaced
2643 with glue code by the loader. This depends on the AIX version. */
2644 asm_fprintf (file
, RS6000_CALL_GLUE
);
2648 /* Write the register number of the TOC register. */
2649 fputs (TARGET_MINIMAL_TOC
? reg_names
[30] : reg_names
[2], file
);
2653 /* Write out either a '.' or '$' for the current location, depending
2654 on whether this is Solaris or not. */
2655 putc ((DEFAULT_ABI
== ABI_SOLARIS
) ? '.' : '$', file
);
2659 /* If X is a constant integer whose low-order 5 bits are zero,
2660 write 'l'. Otherwise, write 'r'. This is a kludge to fix a bug
2661 in the AIX assembler where "sri" with a zero shift count
2662 write a trash instruction. */
2663 if (GET_CODE (x
) == CONST_INT
&& (INTVAL (x
) & 31) == 0)
2670 /* Low-order 16 bits of constant, unsigned. */
2672 output_operand_lossage ("invalid %%b value");
2674 fprintf (file
, "%d", INT_LOWPART (x
) & 0xffff);
2678 /* If the low-order bit is zero, write 'r'; otherwise, write 'l'
2679 for 64-bit mask direction. */
2680 putc (((INT_LOWPART(x
) & 1) == 0 ? 'r' : 'l'), file
);
2684 /* This is an optional cror needed for LE or GE floating-point
2685 comparisons. Otherwise write nothing. */
2686 if ((GET_CODE (x
) == LE
|| GET_CODE (x
) == GE
)
2687 && GET_MODE (XEXP (x
, 0)) == CCFPmode
)
2689 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2691 fprintf (file
, "cror %d,%d,%d\n\t", base_bit
+ 3,
2692 base_bit
+ 2, base_bit
+ (GET_CODE (x
) == GE
));
2697 /* Similar, except that this is for an scc, so we must be able to
2698 encode the test in a single bit that is one. We do the above
2699 for any LE, GE, GEU, or LEU and invert the bit for NE. */
2700 if (GET_CODE (x
) == LE
|| GET_CODE (x
) == GE
2701 || GET_CODE (x
) == LEU
|| GET_CODE (x
) == GEU
)
2703 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2705 fprintf (file
, "cror %d,%d,%d\n\t", base_bit
+ 3,
2707 base_bit
+ (GET_CODE (x
) == GE
|| GET_CODE (x
) == GEU
));
2710 else if (GET_CODE (x
) == NE
)
2712 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2714 fprintf (file
, "crnor %d,%d,%d\n\t", base_bit
+ 3,
2715 base_bit
+ 2, base_bit
+ 2);
2720 /* X is a CR register. Print the number of the third bit of the CR */
2721 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2722 output_operand_lossage ("invalid %%E value");
2724 fprintf(file
, "%d", 4 * (REGNO (x
) - 68) + 3);
2728 /* X is a CR register. Print the shift count needed to move it
2729 to the high-order four bits. */
2730 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2731 output_operand_lossage ("invalid %%f value");
2733 fprintf (file
, "%d", 4 * (REGNO (x
) - 68));
2737 /* Similar, but print the count for the rotate in the opposite
2739 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2740 output_operand_lossage ("invalid %%F value");
2742 fprintf (file
, "%d", 32 - 4 * (REGNO (x
) - 68));
2746 /* X is a constant integer. If it is negative, print "m",
2747 otherwise print "z". This is to make a aze or ame insn. */
2748 if (GET_CODE (x
) != CONST_INT
)
2749 output_operand_lossage ("invalid %%G value");
2750 else if (INTVAL (x
) >= 0)
2757 /* If constant, output low-order five bits. Otherwise,
2760 fprintf (file
, "%d", INT_LOWPART (x
) & 31);
2762 print_operand (file
, x
, 0);
2766 /* If constant, output low-order six bits. Otherwise,
2769 fprintf (file
, "%d", INT_LOWPART (x
) & 63);
2771 print_operand (file
, x
, 0);
2775 /* Print `i' if this is a constant, else nothing. */
2781 /* Write the bit number in CCR for jump. */
2784 output_operand_lossage ("invalid %%j code");
2786 fprintf (file
, "%d", i
);
2790 /* Similar, but add one for shift count in rlinm for scc and pass
2791 scc flag to `ccr_bit'. */
2794 output_operand_lossage ("invalid %%J code");
2796 /* If we want bit 31, write a shift count of zero, not 32. */
2797 fprintf (file
, "%d", i
== 31 ? 0 : i
+ 1);
2801 /* X must be a constant. Write the 1's complement of the
2804 output_operand_lossage ("invalid %%k value");
2806 fprintf (file
, "%d", ~ INT_LOWPART (x
));
2810 /* Write second word of DImode or DFmode reference. Works on register
2811 or non-indexed memory only. */
2812 if (GET_CODE (x
) == REG
)
2813 fprintf (file
, "%s", reg_names
[REGNO (x
) + 1]);
2814 else if (GET_CODE (x
) == MEM
)
2816 /* Handle possible auto-increment. Since it is pre-increment and
2817 we have already done it, we can just use an offset of word. */
2818 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
2819 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
2820 output_address (plus_constant (XEXP (XEXP (x
, 0), 0),
2823 output_address (plus_constant (XEXP (x
, 0), UNITS_PER_WORD
));
2824 if (small_data_operand (x
, GET_MODE (x
)))
2825 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
2826 reg_names
[SMALL_DATA_REG
]);
2831 /* MB value for a mask operand. */
2832 if (! mask_operand (x
, VOIDmode
))
2833 output_operand_lossage ("invalid %%m value");
2835 val
= INT_LOWPART (x
);
2837 /* If the high bit is set and the low bit is not, the value is zero.
2838 If the high bit is zero, the value is the first 1 bit we find from
2840 if ((val
& 0x80000000) && ((val
& 1) == 0))
2845 else if ((val
& 0x80000000) == 0)
2847 for (i
= 1; i
< 32; i
++)
2848 if ((val
<<= 1) & 0x80000000)
2850 fprintf (file
, "%d", i
);
2854 /* Otherwise, look for the first 0 bit from the right. The result is its
2855 number plus 1. We know the low-order bit is one. */
2856 for (i
= 0; i
< 32; i
++)
2857 if (((val
>>= 1) & 1) == 0)
2860 /* If we ended in ...01, i would be 0. The correct value is 31, so
2862 fprintf (file
, "%d", 31 - i
);
2866 /* ME value for a mask operand. */
2867 if (! mask_operand (x
, VOIDmode
))
2868 output_operand_lossage ("invalid %%M value");
2870 val
= INT_LOWPART (x
);
2872 /* If the low bit is set and the high bit is not, the value is 31.
2873 If the low bit is zero, the value is the first 1 bit we find from
2875 if ((val
& 1) && ((val
& 0x80000000) == 0))
2880 else if ((val
& 1) == 0)
2882 for (i
= 0; i
< 32; i
++)
2883 if ((val
>>= 1) & 1)
2886 /* If we had ....10, i would be 0. The result should be
2887 30, so we need 30 - i. */
2888 fprintf (file
, "%d", 30 - i
);
2892 /* Otherwise, look for the first 0 bit from the left. The result is its
2893 number minus 1. We know the high-order bit is one. */
2894 for (i
= 0; i
< 32; i
++)
2895 if (((val
<<= 1) & 0x80000000) == 0)
2898 fprintf (file
, "%d", i
);
2902 /* Write the number of elements in the vector times 4. */
2903 if (GET_CODE (x
) != PARALLEL
)
2904 output_operand_lossage ("invalid %%N value");
2906 fprintf (file
, "%d", XVECLEN (x
, 0) * 4);
2910 /* Similar, but subtract 1 first. */
2911 if (GET_CODE (x
) != PARALLEL
)
2912 output_operand_lossage ("invalid %%O value");
2914 fprintf (file
, "%d", (XVECLEN (x
, 0) - 1) * 4);
2918 /* X is a CONST_INT that is a power of two. Output the logarithm. */
2920 || (i
= exact_log2 (INT_LOWPART (x
))) < 0)
2921 output_operand_lossage ("invalid %%p value");
2923 fprintf (file
, "%d", i
);
2927 /* The operand must be an indirect memory reference. The result
2928 is the register number. */
2929 if (GET_CODE (x
) != MEM
|| GET_CODE (XEXP (x
, 0)) != REG
2930 || REGNO (XEXP (x
, 0)) >= 32)
2931 output_operand_lossage ("invalid %%P value");
2933 fprintf (file
, "%d", REGNO (XEXP (x
, 0)));
2937 /* X is a CR register. Print the mask for `mtcrf'. */
2938 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2939 output_operand_lossage ("invalid %%R value");
2941 fprintf (file
, "%d", 128 >> (REGNO (x
) - 68));
2945 /* Low 5 bits of 32 - value */
2947 output_operand_lossage ("invalid %%s value");
2949 fprintf (file
, "%d", (32 - INT_LOWPART (x
)) & 31);
2953 /* PowerPC64 mask position. All 0's and all 1's are excluded.
2954 CONST_INT 32-bit mask is considered sign-extended so any
2955 transition must occur within the CONST_INT, not on the boundary. */
2956 if (! mask64_operand (x
, VOIDmode
))
2957 output_operand_lossage ("invalid %%S value");
2959 val
= INT_LOWPART (x
);
2961 if (val
& 1) /* Clear Left */
2963 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
; i
++)
2964 if (!((val
>>= 1) & 1))
2967 #if HOST_BITS_PER_WIDE_INT == 32
2968 if (GET_CODE (x
) == CONST_DOUBLE
&& i
== 32)
2970 val
= CONST_DOUBLE_HIGH (x
);
2975 for (i
= 32; i
< 64; i
++)
2976 if (!((val
>>= 1) & 1))
2980 /* i = index of last set bit from right
2981 mask begins at 63 - i from left */
2983 output_operand_lossage ("%%S computed all 1's mask");
2984 fprintf (file
, "%d", 63 - i
);
2987 else /* Clear Right */
2989 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
; i
++)
2990 if ((val
>>= 1) & 1)
2993 #if HOST_BITS_PER_WIDE_INT == 32
2994 if (GET_CODE (x
) == CONST_DOUBLE
&& i
== 32)
2996 val
= CONST_DOUBLE_HIGH (x
);
2998 if (val
== (HOST_WIDE_INT
) -1)
3001 for (i
= 32; i
< 64; i
++)
3002 if ((val
>>= 1) & 1)
3006 /* i = index of last clear bit from right
3007 mask ends at 62 - i from left */
3009 output_operand_lossage ("%%S computed all 0's mask");
3010 fprintf (file
, "%d", 62 - i
);
3015 /* Write 12 if this jump operation will branch if true, 4 otherwise.
3016 All floating-point operations except NE branch true and integer
3017 EQ, LT, GT, LTU and GTU also branch true. */
3018 if (GET_RTX_CLASS (GET_CODE (x
)) != '<')
3019 output_operand_lossage ("invalid %%t value");
3021 else if ((GET_MODE (XEXP (x
, 0)) == CCFPmode
3022 && GET_CODE (x
) != NE
)
3023 || GET_CODE (x
) == EQ
3024 || GET_CODE (x
) == LT
|| GET_CODE (x
) == GT
3025 || GET_CODE (x
) == LTU
|| GET_CODE (x
) == GTU
)
3032 /* Opposite of 't': write 4 if this jump operation will branch if true,
3034 if (GET_RTX_CLASS (GET_CODE (x
)) != '<')
3035 output_operand_lossage ("invalid %%T value");
3037 else if ((GET_MODE (XEXP (x
, 0)) == CCFPmode
3038 && GET_CODE (x
) != NE
)
3039 || GET_CODE (x
) == EQ
3040 || GET_CODE (x
) == LT
|| GET_CODE (x
) == GT
3041 || GET_CODE (x
) == LTU
|| GET_CODE (x
) == GTU
)
3048 /* High-order 16 bits of constant for use in unsigned operand. */
3050 output_operand_lossage ("invalid %%u value");
3052 fprintf (file
, "0x%x", (INT_LOWPART (x
) >> 16) & 0xffff);
3056 /* High-order 16 bits of constant for use in signed operand. */
3058 output_operand_lossage ("invalid %%v value");
3061 int value
= (INT_LOWPART (x
) >> 16) & 0xffff;
3063 /* Solaris assembler doesn't like lis 0,0x8000 */
3064 if (DEFAULT_ABI
== ABI_SOLARIS
&& (value
& 0x8000) != 0)
3065 fprintf (file
, "%d", value
| (~0 << 16));
3067 fprintf (file
, "0x%x", value
);
3072 /* Print `u' if this has an auto-increment or auto-decrement. */
3073 if (GET_CODE (x
) == MEM
3074 && (GET_CODE (XEXP (x
, 0)) == PRE_INC
3075 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
))
3080 /* Print the trap code for this operand. */
3081 switch (GET_CODE (x
))
3084 fputs ("eq", file
); /* 4 */
3087 fputs ("ne", file
); /* 24 */
3090 fputs ("lt", file
); /* 16 */
3093 fputs ("le", file
); /* 20 */
3096 fputs ("gt", file
); /* 8 */
3099 fputs ("ge", file
); /* 12 */
3102 fputs ("llt", file
); /* 2 */
3105 fputs ("lle", file
); /* 6 */
3108 fputs ("lgt", file
); /* 1 */
3111 fputs ("lge", file
); /* 5 */
3119 /* If constant, low-order 16 bits of constant, signed. Otherwise, write
3122 fprintf (file
, "%d", ((INT_LOWPART (x
) & 0xffff) ^ 0x8000) - 0x8000);
3124 print_operand (file
, x
, 0);
3128 /* If constant, low-order 16 bits of constant, unsigned.
3129 Otherwise, write normally. */
3131 fprintf (file
, "%d", INT_LOWPART (x
) & 0xffff);
3133 print_operand (file
, x
, 0);
3137 if (GET_CODE (x
) == MEM
3138 && LEGITIMATE_INDEXED_ADDRESS_P (XEXP (x
, 0)))
3143 /* Like 'L', for third word of TImode */
3144 if (GET_CODE (x
) == REG
)
3145 fprintf (file
, "%s", reg_names
[REGNO (x
) + 2]);
3146 else if (GET_CODE (x
) == MEM
)
3148 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
3149 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3150 output_address (plus_constant (XEXP (XEXP (x
, 0), 0), 8));
3152 output_address (plus_constant (XEXP (x
, 0), 8));
3153 if (small_data_operand (x
, GET_MODE (x
)))
3154 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3155 reg_names
[SMALL_DATA_REG
]);
3160 /* X is a SYMBOL_REF. Write out the name preceded by a
3161 period and without any trailing data in brackets. Used for function
3162 names. If we are configured for System V (or the embedded ABI) on
3163 the PowerPC, do not emit the period, since those systems do not use
3164 TOCs and the like. */
3165 if (GET_CODE (x
) != SYMBOL_REF
)
3168 if (XSTR (x
, 0)[0] != '.')
3170 switch (DEFAULT_ABI
)
3180 case ABI_AIX_NODESC
:
3189 RS6000_OUTPUT_BASENAME (file
, XSTR (x
, 0));
3193 /* Like 'L', for last word of TImode. */
3194 if (GET_CODE (x
) == REG
)
3195 fprintf (file
, "%s", reg_names
[REGNO (x
) + 3]);
3196 else if (GET_CODE (x
) == MEM
)
3198 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
3199 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3200 output_address (plus_constant (XEXP (XEXP (x
, 0), 0), 12));
3202 output_address (plus_constant (XEXP (x
, 0), 12));
3203 if (small_data_operand (x
, GET_MODE (x
)))
3204 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3205 reg_names
[SMALL_DATA_REG
]);
3210 if (GET_CODE (x
) == REG
)
3211 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
3212 else if (GET_CODE (x
) == MEM
)
3214 /* We need to handle PRE_INC and PRE_DEC here, since we need to
3215 know the width from the mode. */
3216 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
)
3217 fprintf (file
, "%d(%d)", GET_MODE_SIZE (GET_MODE (x
)),
3218 REGNO (XEXP (XEXP (x
, 0), 0)));
3219 else if (GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3220 fprintf (file
, "%d(%d)", - GET_MODE_SIZE (GET_MODE (x
)),
3221 REGNO (XEXP (XEXP (x
, 0), 0)));
3223 output_address (XEXP (x
, 0));
3226 output_addr_const (file
, x
);
3230 output_operand_lossage ("invalid %%xn code");
3234 /* Print the address of an operand. */
3237 print_operand_address (file
, x
)
3241 if (GET_CODE (x
) == REG
)
3242 fprintf (file
, "0(%s)", reg_names
[ REGNO (x
) ]);
3243 else if (GET_CODE (x
) == SYMBOL_REF
|| GET_CODE (x
) == CONST
|| GET_CODE (x
) == LABEL_REF
)
3245 output_addr_const (file
, x
);
3246 if (small_data_operand (x
, GET_MODE (x
)))
3247 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3248 reg_names
[SMALL_DATA_REG
]);
3250 #ifdef TARGET_NO_TOC
3251 else if (TARGET_NO_TOC
)
3255 fprintf (file
, "(%s)", reg_names
[ TARGET_MINIMAL_TOC
? 30 : 2 ]);
3257 else if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 1)) == REG
)
3259 if (REGNO (XEXP (x
, 0)) == 0)
3260 fprintf (file
, "%s,%s", reg_names
[ REGNO (XEXP (x
, 1)) ],
3261 reg_names
[ REGNO (XEXP (x
, 0)) ]);
3263 fprintf (file
, "%s,%s", reg_names
[ REGNO (XEXP (x
, 0)) ],
3264 reg_names
[ REGNO (XEXP (x
, 1)) ]);
3266 else if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 1)) == CONST_INT
)
3267 fprintf (file
, "%d(%s)", INTVAL (XEXP (x
, 1)), reg_names
[ REGNO (XEXP (x
, 0)) ]);
3268 else if (TARGET_ELF
&& !TARGET_64BIT
&& GET_CODE (x
) == LO_SUM
3269 && GET_CODE (XEXP (x
, 0)) == REG
&& CONSTANT_P (XEXP (x
, 1)))
3271 output_addr_const (file
, XEXP (x
, 1));
3272 fprintf (file
, "@l(%s)", reg_names
[ REGNO (XEXP (x
, 0)) ]);
3278 /* This page contains routines that are used to determine what the function
3279 prologue and epilogue code will do and write them out. */
3281 /* Return the first fixed-point register that is required to be saved. 32 if
3285 first_reg_to_save ()
3289 /* Find lowest numbered live register. */
3290 for (first_reg
= 13; first_reg
<= 31; first_reg
++)
3291 if (regs_ever_live
[first_reg
])
3296 /* AIX must save/restore every register that contains a parameter
3297 before/after the .__mcount call plus an additional register
3298 for the static chain, if needed; use registers from 30 down to 22
3300 if (DEFAULT_ABI
== ABI_AIX
)
3302 int last_parm_reg
, profile_first_reg
;
3304 /* Figure out last used parameter register. The proper thing
3305 to do is to walk incoming args of the function. A function
3306 might have live parameter registers even if it has no
3308 for (last_parm_reg
= 10;
3309 last_parm_reg
> 2 && ! regs_ever_live
[last_parm_reg
];
3313 /* Calculate first reg for saving parameter registers
3315 Skip reg 31 which may contain the frame pointer. */
3316 profile_first_reg
= (33 - last_parm_reg
3317 - (current_function_needs_context
? 1 : 0));
3318 /* Do not save frame pointer if no parameters needs to be saved. */
3319 if (profile_first_reg
== 31)
3320 profile_first_reg
= 32;
3322 if (first_reg
> profile_first_reg
)
3323 first_reg
= profile_first_reg
;
3326 /* SVR4 may need one register to preserve the static chain. */
3327 else if (current_function_needs_context
)
3329 /* Skip reg 31 which may contain the frame pointer. */
3338 /* Similar, for FP regs. */
3341 first_fp_reg_to_save ()
3345 /* Find lowest numbered live register. */
3346 for (first_reg
= 14 + 32; first_reg
<= 63; first_reg
++)
3347 if (regs_ever_live
[first_reg
])
3353 /* Return non-zero if this function makes calls. */
3356 rs6000_makes_calls ()
3360 /* If we are profiling, we will be making a call to __mcount.
3361 Under the System V ABI's, we store the LR directly, so
3362 we don't need to do it here. */
3363 if (DEFAULT_ABI
== ABI_AIX
&& profile_flag
)
3366 for (insn
= get_insns (); insn
; insn
= next_insn (insn
))
3367 if (GET_CODE (insn
) == CALL_INSN
)
3374 /* Calculate the stack information for the current function. This is
3375 complicated by having two separate calling sequences, the AIX calling
3376 sequence and the V.4 calling sequence.
3378 AIX stack frames look like:
3380 SP----> +---------------------------------------+
3381 | back chain to caller | 0 0
3382 +---------------------------------------+
3383 | saved CR | 4 8 (8-11)
3384 +---------------------------------------+
3386 +---------------------------------------+
3387 | reserved for compilers | 12 24
3388 +---------------------------------------+
3389 | reserved for binders | 16 32
3390 +---------------------------------------+
3391 | saved TOC pointer | 20 40
3392 +---------------------------------------+
3393 | Parameter save area (P) | 24 48
3394 +---------------------------------------+
3395 | Alloca space (A) | 24+P etc.
3396 +---------------------------------------+
3397 | Local variable space (L) | 24+P+A
3398 +---------------------------------------+
3399 | Float/int conversion temporary (X) | 24+P+A+L
3400 +---------------------------------------+
3401 | Save area for GP registers (G) | 24+P+A+X+L
3402 +---------------------------------------+
3403 | Save area for FP registers (F) | 24+P+A+X+L+G
3404 +---------------------------------------+
3405 old SP->| back chain to caller's caller |
3406 +---------------------------------------+
3408 The required alignment for AIX configurations is two words (i.e., 8
3412 V.4 stack frames look like:
3414 SP----> +---------------------------------------+
3415 | back chain to caller | 0
3416 +---------------------------------------+
3417 | caller's saved LR | 4
3418 +---------------------------------------+
3419 | Parameter save area (P) | 8
3420 +---------------------------------------+
3421 | Alloca space (A) | 8+P
3422 +---------------------------------------+
3423 | Varargs save area (V) | 8+P+A
3424 +---------------------------------------+
3425 | Local variable space (L) | 8+P+A+V
3426 +---------------------------------------+
3427 | Float/int conversion temporary (X) | 8+P+A+V+L
3428 +---------------------------------------+
3429 | saved CR (C) | 8+P+A+V+L+X
3430 +---------------------------------------+
3431 | Save area for GP registers (G) | 8+P+A+V+L+X+C
3432 +---------------------------------------+
3433 | Save area for FP registers (F) | 8+P+A+V+L+X+C+G
3434 +---------------------------------------+
3435 old SP->| back chain to caller's caller |
3436 +---------------------------------------+
3438 The required alignment for V.4 is 16 bytes, or 8 bytes if -meabi is
3439 given. (But note below and in sysv4.h that we require only 8 and
3440 may round up the size of our stack frame anyways. The historical
3441 reason is early versions of powerpc-linux which didn't properly
3442 align the stack at program startup. A happy side-effect is that
3443 -mno-eabi libraries can be used with -meabi programs.)
3446 A PowerPC Windows/NT frame looks like:
3448 SP----> +---------------------------------------+
3449 | back chain to caller | 0
3450 +---------------------------------------+
3452 +---------------------------------------+
3454 +---------------------------------------+
3456 +---------------------------------------+
3458 +---------------------------------------+
3460 +---------------------------------------+
3461 | Parameter save area (P) | 24
3462 +---------------------------------------+
3463 | Alloca space (A) | 24+P
3464 +---------------------------------------+
3465 | Local variable space (L) | 24+P+A
3466 +---------------------------------------+
3467 | Float/int conversion temporary (X) | 24+P+A+L
3468 +---------------------------------------+
3469 | Save area for FP registers (F) | 24+P+A+L+X
3470 +---------------------------------------+
3471 | Possible alignment area (Y) | 24+P+A+L+X+F
3472 +---------------------------------------+
3473 | Save area for GP registers (G) | 24+P+A+L+X+F+Y
3474 +---------------------------------------+
3475 | Save area for CR (C) | 24+P+A+L+X+F+Y+G
3476 +---------------------------------------+
3477 | Save area for TOC (T) | 24+P+A+L+X+F+Y+G+C
3478 +---------------------------------------+
3479 | Save area for LR (R) | 24+P+A+L+X+F+Y+G+C+T
3480 +---------------------------------------+
3481 old SP->| back chain to caller's caller |
3482 +---------------------------------------+
3484 For NT, there is no specific order to save the registers, but in
3485 order to support __builtin_return_address, the save area for the
3486 link register needs to be in a known place, so we use -4 off of the
3487 old SP. To support calls through pointers, we also allocate a
3488 fixed slot to store the TOC, -8 off the old SP.
3490 The required alignment for NT is 16 bytes.
3493 The EABI configuration defaults to the V.4 layout, unless
3494 -mcall-aix is used, in which case the AIX layout is used. However,
3495 the stack alignment requirements may differ. If -mno-eabi is not
3496 given, the required stack alignment is 8 bytes; if -mno-eabi is
3497 given, the required alignment is 16 bytes. (But see V.4 comment
3500 #ifndef ABI_STACK_BOUNDARY
3501 #define ABI_STACK_BOUNDARY STACK_BOUNDARY
3505 rs6000_stack_info ()
3507 static rs6000_stack_t info
, zero_info
;
3508 rs6000_stack_t
*info_ptr
= &info
;
3509 int reg_size
= TARGET_32BIT
? 4 : 8;
3510 enum rs6000_abi abi
;
3513 /* Zero all fields portably */
3516 /* Select which calling sequence */
3517 info_ptr
->abi
= abi
= DEFAULT_ABI
;
3519 /* Calculate which registers need to be saved & save area size */
3520 info_ptr
->first_gp_reg_save
= first_reg_to_save ();
3521 info_ptr
->gp_size
= reg_size
* (32 - info_ptr
->first_gp_reg_save
);
3523 info_ptr
->first_fp_reg_save
= first_fp_reg_to_save ();
3524 info_ptr
->fp_size
= 8 * (64 - info_ptr
->first_fp_reg_save
);
3526 /* Does this function call anything? */
3527 info_ptr
->calls_p
= rs6000_makes_calls ();
3529 /* Allocate space to save the toc. */
3530 if (abi
== ABI_NT
&& info_ptr
->calls_p
)
3532 info_ptr
->toc_save_p
= 1;
3533 info_ptr
->toc_size
= reg_size
;
3536 /* Does this machine need the float/int conversion area? */
3537 info_ptr
->fpmem_p
= regs_ever_live
[FPMEM_REGNUM
];
3539 /* If this is main and we need to call a function to set things up,
3540 save main's arguments around the call. */
3545 if (strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl
)), "main") == 0
3546 && DECL_CONTEXT (current_function_decl
) == NULL_TREE
)
3548 info_ptr
->main_p
= 1;
3551 info_ptr
->calls_p
= 1;
3553 if (DECL_ARGUMENTS (current_function_decl
))
3558 info_ptr
->main_save_p
= 1;
3559 info_ptr
->main_size
= 0;
3561 for ((i
= 0), (arg
= DECL_ARGUMENTS (current_function_decl
));
3562 arg
!= NULL_TREE
&& i
< 8;
3563 (arg
= TREE_CHAIN (arg
)), i
++)
3565 info_ptr
->main_size
+= reg_size
;
3572 /* Determine if we need to save the link register */
3573 if (regs_ever_live
[65]
3574 || (DEFAULT_ABI
== ABI_AIX
&& profile_flag
)
3575 #ifdef TARGET_RELOCATABLE
3576 || (TARGET_RELOCATABLE
&& (get_pool_size () != 0))
3578 || (info_ptr
->first_fp_reg_save
!= 64
3579 && !FP_SAVE_INLINE (info_ptr
->first_fp_reg_save
))
3580 || (abi
== ABI_V4
&& current_function_calls_alloca
)
3581 || (abi
== ABI_SOLARIS
&& current_function_calls_alloca
)
3582 || info_ptr
->calls_p
)
3584 info_ptr
->lr_save_p
= 1;
3585 regs_ever_live
[65] = 1;
3587 info_ptr
->lr_size
= reg_size
;
3590 /* Determine if we need to save the condition code registers */
3591 if (regs_ever_live
[70] || regs_ever_live
[71] || regs_ever_live
[72])
3593 info_ptr
->cr_save_p
= 1;
3594 if (abi
== ABI_V4
|| abi
== ABI_NT
|| abi
== ABI_SOLARIS
)
3595 info_ptr
->cr_size
= reg_size
;
3598 /* Determine various sizes */
3599 info_ptr
->reg_size
= reg_size
;
3600 info_ptr
->fixed_size
= RS6000_SAVE_AREA
;
3601 info_ptr
->varargs_size
= RS6000_VARARGS_AREA
;
3602 info_ptr
->vars_size
= RS6000_ALIGN (get_frame_size (), 8);
3603 info_ptr
->parm_size
= RS6000_ALIGN (current_function_outgoing_args_size
, 8);
3604 info_ptr
->fpmem_size
= (info_ptr
->fpmem_p
) ? 8 : 0;
3605 info_ptr
->save_size
= RS6000_ALIGN (info_ptr
->fp_size
3609 + info_ptr
->toc_size
3610 + info_ptr
->main_size
, 8);
3612 /* Calculate the offsets */
3620 case ABI_AIX_NODESC
:
3621 info_ptr
->fp_save_offset
= - info_ptr
->fp_size
;
3622 info_ptr
->gp_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->gp_size
;
3623 info_ptr
->main_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->main_size
;
3624 info_ptr
->cr_save_offset
= reg_size
; /* first word when 64-bit. */
3625 info_ptr
->lr_save_offset
= 2*reg_size
;
3630 info_ptr
->fp_save_offset
= - info_ptr
->fp_size
;
3631 info_ptr
->gp_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->gp_size
;
3632 info_ptr
->cr_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->cr_size
;
3633 info_ptr
->toc_save_offset
= info_ptr
->cr_save_offset
- info_ptr
->toc_size
;
3634 info_ptr
->main_save_offset
= info_ptr
->toc_save_offset
- info_ptr
->main_size
;
3635 info_ptr
->lr_save_offset
= reg_size
;
3639 info_ptr
->lr_save_offset
= -reg_size
;
3640 info_ptr
->toc_save_offset
= info_ptr
->lr_save_offset
- info_ptr
->lr_size
;
3641 info_ptr
->cr_save_offset
= info_ptr
->toc_save_offset
- info_ptr
->toc_size
;
3642 info_ptr
->gp_save_offset
= info_ptr
->cr_save_offset
- info_ptr
->cr_size
- info_ptr
->gp_size
+ reg_size
;
3643 info_ptr
->fp_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->fp_size
;
3644 if (info_ptr
->fp_size
&& ((- info_ptr
->fp_save_offset
) % 8) != 0)
3645 info_ptr
->fp_save_offset
-= reg_size
;
3647 info_ptr
->main_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->main_size
;
3651 /* Ensure that fpmem_offset will be aligned to an 8-byte boundary. */
3652 if (info_ptr
->fpmem_p
3653 && (info_ptr
->main_save_offset
- info_ptr
->fpmem_size
) % 8)
3654 info_ptr
->fpmem_size
+= reg_size
;
3656 total_raw_size
= (info_ptr
->vars_size
3657 + info_ptr
->parm_size
3658 + info_ptr
->fpmem_size
3659 + info_ptr
->save_size
3660 + info_ptr
->varargs_size
3661 + info_ptr
->fixed_size
);
3663 info_ptr
->total_size
= RS6000_ALIGN (total_raw_size
, ABI_STACK_BOUNDARY
/ BITS_PER_UNIT
);
3665 /* Determine if we need to allocate any stack frame:
3667 For AIX we need to push the stack if a frame pointer is needed (because
3668 the stack might be dynamically adjusted), if we are debugging, if we
3669 make calls, or if the sum of fp_save, gp_save, fpmem, and local variables
3670 are more than the space needed to save all non-volatile registers:
3671 32-bit: 18*8 + 19*4 = 220 or 64-bit: 18*8 + 18*8 = 288 (GPR13 reserved).
3673 For V.4 we don't have the stack cushion that AIX uses, but assume that
3674 the debugger can handle stackless frames. */
3676 if (info_ptr
->calls_p
)
3677 info_ptr
->push_p
= 1;
3679 else if (abi
== ABI_V4
|| abi
== ABI_NT
|| abi
== ABI_SOLARIS
)
3680 info_ptr
->push_p
= (total_raw_size
> info_ptr
->fixed_size
3681 || (abi
== ABI_NT
? info_ptr
->lr_save_p
3682 : info_ptr
->calls_p
));
3685 info_ptr
->push_p
= (frame_pointer_needed
3686 || write_symbols
!= NO_DEBUG
3687 || ((total_raw_size
- info_ptr
->fixed_size
)
3688 > (TARGET_32BIT
? 220 : 288)));
3690 if (info_ptr
->fpmem_p
)
3692 info_ptr
->fpmem_offset
= info_ptr
->main_save_offset
- info_ptr
->fpmem_size
;
3693 rs6000_fpmem_size
= info_ptr
->fpmem_size
;
3694 rs6000_fpmem_offset
= (info_ptr
->push_p
3695 ? info_ptr
->total_size
+ info_ptr
->fpmem_offset
3696 : info_ptr
->fpmem_offset
);
3699 info_ptr
->fpmem_offset
= 0;
3701 /* Zero offsets if we're not saving those registers */
3702 if (info_ptr
->fp_size
== 0)
3703 info_ptr
->fp_save_offset
= 0;
3705 if (info_ptr
->gp_size
== 0)
3706 info_ptr
->gp_save_offset
= 0;
3708 if (!info_ptr
->lr_save_p
)
3709 info_ptr
->lr_save_offset
= 0;
3711 if (!info_ptr
->cr_save_p
)
3712 info_ptr
->cr_save_offset
= 0;
3714 if (!info_ptr
->toc_save_p
)
3715 info_ptr
->toc_save_offset
= 0;
3717 if (!info_ptr
->main_save_p
)
3718 info_ptr
->main_save_offset
= 0;
3724 debug_stack_info (info
)
3725 rs6000_stack_t
*info
;
3727 const char *abi_string
;
3730 info
= rs6000_stack_info ();
3732 fprintf (stderr
, "\nStack information for function %s:\n",
3733 ((current_function_decl
&& DECL_NAME (current_function_decl
))
3734 ? IDENTIFIER_POINTER (DECL_NAME (current_function_decl
))
3739 default: abi_string
= "Unknown"; break;
3740 case ABI_NONE
: abi_string
= "NONE"; break;
3741 case ABI_AIX
: abi_string
= "AIX"; break;
3742 case ABI_AIX_NODESC
: abi_string
= "AIX"; break;
3743 case ABI_V4
: abi_string
= "V.4"; break;
3744 case ABI_SOLARIS
: abi_string
= "Solaris"; break;
3745 case ABI_NT
: abi_string
= "NT"; break;
3748 fprintf (stderr
, "\tABI = %5s\n", abi_string
);
3750 if (info
->first_gp_reg_save
!= 32)
3751 fprintf (stderr
, "\tfirst_gp_reg_save = %5d\n", info
->first_gp_reg_save
);
3753 if (info
->first_fp_reg_save
!= 64)
3754 fprintf (stderr
, "\tfirst_fp_reg_save = %5d\n", info
->first_fp_reg_save
);
3756 if (info
->lr_save_p
)
3757 fprintf (stderr
, "\tlr_save_p = %5d\n", info
->lr_save_p
);
3759 if (info
->cr_save_p
)
3760 fprintf (stderr
, "\tcr_save_p = %5d\n", info
->cr_save_p
);
3762 if (info
->toc_save_p
)
3763 fprintf (stderr
, "\ttoc_save_p = %5d\n", info
->toc_save_p
);
3766 fprintf (stderr
, "\tpush_p = %5d\n", info
->push_p
);
3769 fprintf (stderr
, "\tcalls_p = %5d\n", info
->calls_p
);
3772 fprintf (stderr
, "\tmain_p = %5d\n", info
->main_p
);
3774 if (info
->main_save_p
)
3775 fprintf (stderr
, "\tmain_save_p = %5d\n", info
->main_save_p
);
3778 fprintf (stderr
, "\tfpmem_p = %5d\n", info
->fpmem_p
);
3780 if (info
->gp_save_offset
)
3781 fprintf (stderr
, "\tgp_save_offset = %5d\n", info
->gp_save_offset
);
3783 if (info
->fp_save_offset
)
3784 fprintf (stderr
, "\tfp_save_offset = %5d\n", info
->fp_save_offset
);
3786 if (info
->lr_save_offset
)
3787 fprintf (stderr
, "\tlr_save_offset = %5d\n", info
->lr_save_offset
);
3789 if (info
->cr_save_offset
)
3790 fprintf (stderr
, "\tcr_save_offset = %5d\n", info
->cr_save_offset
);
3792 if (info
->toc_save_offset
)
3793 fprintf (stderr
, "\ttoc_save_offset = %5d\n", info
->toc_save_offset
);
3795 if (info
->varargs_save_offset
)
3796 fprintf (stderr
, "\tvarargs_save_offset = %5d\n", info
->varargs_save_offset
);
3798 if (info
->main_save_offset
)
3799 fprintf (stderr
, "\tmain_save_offset = %5d\n", info
->main_save_offset
);
3801 if (info
->fpmem_offset
)
3802 fprintf (stderr
, "\tfpmem_offset = %5d\n", info
->fpmem_offset
);
3804 if (info
->total_size
)
3805 fprintf (stderr
, "\ttotal_size = %5d\n", info
->total_size
);
3807 if (info
->varargs_size
)
3808 fprintf (stderr
, "\tvarargs_size = %5d\n", info
->varargs_size
);
3810 if (info
->vars_size
)
3811 fprintf (stderr
, "\tvars_size = %5d\n", info
->vars_size
);
3813 if (info
->parm_size
)
3814 fprintf (stderr
, "\tparm_size = %5d\n", info
->parm_size
);
3816 if (info
->fpmem_size
)
3817 fprintf (stderr
, "\tfpmem_size = %5d\n", info
->fpmem_size
);
3819 if (info
->fixed_size
)
3820 fprintf (stderr
, "\tfixed_size = %5d\n", info
->fixed_size
);
3823 fprintf (stderr
, "\tgp_size = %5d\n", info
->gp_size
);
3826 fprintf (stderr
, "\tfp_size = %5d\n", info
->fp_size
);
3829 fprintf (stderr
, "\tlr_size = %5d\n", info
->cr_size
);
3832 fprintf (stderr
, "\tcr_size = %5d\n", info
->cr_size
);
3835 fprintf (stderr
, "\ttoc_size = %5d\n", info
->toc_size
);
3837 if (info
->main_size
)
3838 fprintf (stderr
, "\tmain_size = %5d\n", info
->main_size
);
3840 if (info
->save_size
)
3841 fprintf (stderr
, "\tsave_size = %5d\n", info
->save_size
);
3843 if (info
->reg_size
!= 4)
3844 fprintf (stderr
, "\treg_size = %5d\n", info
->reg_size
);
3846 fprintf (stderr
, "\n");
3849 /* Write out an instruction to load the TOC_TABLE address into register 30.
3850 This is only needed when TARGET_TOC, TARGET_MINIMAL_TOC, and there is
3854 rs6000_output_load_toc_table (file
, reg
)
3861 if (TARGET_RELOCATABLE
)
3863 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3864 fprintf (file
, "\tbl ");
3865 assemble_name (file
, buf
);
3866 fprintf (file
, "\n");
3868 /* possibly create the toc section */
3869 if (!toc_initialized
)
3872 function_section (current_function_decl
);
3875 /* If not first call in this function, we need to put the
3876 different between .LCTOC1 and the address we get to right
3877 after the bl. It will mess up disassembling the instructions
3878 but that can't be helped. We will later need to bias the
3879 address before loading. */
3880 if (rs6000_pic_func_labelno
!= rs6000_pic_labelno
)
3882 const char *init_ptr
= TARGET_32BIT
? ".long" : ".quad";
3885 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCL", rs6000_pic_labelno
);
3887 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 1);
3888 STRIP_NAME_ENCODING (buf_ptr
, buf
);
3889 fprintf (file
, "\t%s %s-", init_ptr
, buf_ptr
);
3891 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3892 fprintf (file
, "%s\n", buf_ptr
);
3895 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCF", rs6000_pic_labelno
);
3896 fprintf (file
, "\tmflr %s\n", reg_names
[reg
]);
3898 if (rs6000_pic_func_labelno
!= rs6000_pic_labelno
)
3899 asm_fprintf(file
, "\t{cal|la} %s,%d(%s)\n", reg_names
[reg
],
3900 (TARGET_32BIT
? 4 : 8), reg_names
[reg
]);
3902 asm_fprintf (file
, (TARGET_32BIT
) ? "\t{l|lwz} %s,(" : "\tld %s,(",
3904 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCL", rs6000_pic_labelno
);
3905 assemble_name (file
, buf
);
3907 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3908 assemble_name (file
, buf
);
3909 fprintf (file
, ")(%s)\n", reg_names
[reg
]);
3910 asm_fprintf (file
, "\t{cax|add} %s,%s,%s\n",
3911 reg_names
[reg
], reg_names
[0], reg_names
[reg
]);
3912 rs6000_pic_labelno
++;
3914 else if (! TARGET_64BIT
)
3916 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 1);
3917 asm_fprintf (file
, "\t{liu|lis} %s,", reg_names
[reg
]);
3918 assemble_name (file
, buf
);
3919 fputs ("@ha\n", file
);
3920 asm_fprintf (file
, "\t{cal|la} %s,", reg_names
[reg
]);
3921 assemble_name (file
, buf
);
3922 asm_fprintf (file
, "@l(%s)\n", reg_names
[reg
]);
3927 #else /* !USING_SVR4_H */
3928 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 0);
3929 asm_fprintf (file
, TARGET_32BIT
? "\t{l|lwz} %s," : "\tld %s,",
3931 assemble_name (file
, buf
);
3932 asm_fprintf (file
, "(%s)\n", reg_names
[2]);
3933 #endif /* USING_SVR4_H */
3937 /* Emit the correct code for allocating stack space. If COPY_R12, make sure a copy
3938 of the old frame is left in r12. */
3941 rs6000_allocate_stack_space (file
, size
, copy_r12
)
3946 int neg_size
= -size
;
3951 (TARGET_32BIT
) ? "\t{stu|stwu} %s,%d(%s)\n" : "\tstdu %s,%d(%s)\n",
3952 reg_names
[1], neg_size
, reg_names
[1]);
3956 fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
3958 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
3959 reg_names
[0], (neg_size
>> 16) & 0xffff,
3960 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
3962 (TARGET_32BIT
) ? "\t{stux|stwux} %s,%s,%s\n" : "\tstdux %s,%s,%s\n",
3963 reg_names
[1], reg_names
[1], reg_names
[0]);
3968 fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
3970 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
3971 reg_names
[1], neg_size
, reg_names
[1]);
3974 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
3975 reg_names
[0], (neg_size
>> 16) & 0xffff,
3976 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
3977 asm_fprintf (file
, "\t{cax|add} %s,%s,%s\n", reg_names
[1],
3978 reg_names
[0], reg_names
[1]);
3982 (TARGET_32BIT
) ? "\t{st|stw} %s,0(%s)\n" : "\tstd %s,0(%s)\n",
3983 reg_names
[12], reg_names
[1]);
3988 /* Write function prologue. */
3990 output_prolog (file
, size
)
3992 int size ATTRIBUTE_UNUSED
;
3994 rs6000_stack_t
*info
= rs6000_stack_info ();
3995 int reg_size
= info
->reg_size
;
3996 const char *store_reg
;
3997 const char *load_reg
;
4003 store_reg
= "\t{st|stw} %s,%d(%s)\n";
4004 load_reg
= "\t{l|lwz} %s,%d(%s)\n";
4008 store_reg
= "\tstd %s,%d(%s)\n";
4009 load_reg
= "\tlld %s,%d(%s)\n";
4012 if (TARGET_DEBUG_STACK
)
4013 debug_stack_info (info
);
4015 /* Write .extern for any function we will call to save and restore fp
4017 if (info
->first_fp_reg_save
< 64 && !FP_SAVE_INLINE (info
->first_fp_reg_save
))
4018 fprintf (file
, "\t.extern %s%d%s\n\t.extern %s%d%s\n",
4019 SAVE_FP_PREFIX
, info
->first_fp_reg_save
- 32, SAVE_FP_SUFFIX
,
4020 RESTORE_FP_PREFIX
, info
->first_fp_reg_save
- 32, RESTORE_FP_SUFFIX
);
4022 /* Write .extern for truncation routines, if needed. */
4023 if (rs6000_trunc_used
&& ! trunc_defined
)
4025 fprintf (file
, "\t.extern .%s\n\t.extern .%s\n",
4026 RS6000_ITRUNC
, RS6000_UITRUNC
);
4030 /* Write .extern for AIX common mode routines, if needed. */
4031 if (! TARGET_POWER
&& ! TARGET_POWERPC
&& ! common_mode_defined
)
4033 fputs ("\t.extern __mulh\n", file
);
4034 fputs ("\t.extern __mull\n", file
);
4035 fputs ("\t.extern __divss\n", file
);
4036 fputs ("\t.extern __divus\n", file
);
4037 fputs ("\t.extern __quoss\n", file
);
4038 fputs ("\t.extern __quous\n", file
);
4039 common_mode_defined
= 1;
4042 /* For V.4, update stack before we do any saving and set back pointer. */
4043 if (info
->push_p
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
4045 if (info
->total_size
< 32767)
4046 sp_offset
= info
->total_size
;
4049 rs6000_allocate_stack_space (file
, info
->total_size
, sp_reg
== 12);
4052 /* If we use the link register, get it into r0. */
4053 if (info
->lr_save_p
)
4054 asm_fprintf (file
, "\tmflr %s\n", reg_names
[0]);
4056 /* If we need to save CR, put it into r12. */
4057 if (info
->cr_save_p
&& sp_reg
!= 12)
4058 asm_fprintf (file
, "\tmfcr %s\n", reg_names
[12]);
4060 /* Do any required saving of fpr's. If only one or two to save, do it
4061 ourself. Otherwise, call function. Note that since they are statically
4062 linked, we do not need a nop following them. */
4063 if (FP_SAVE_INLINE (info
->first_fp_reg_save
))
4065 int regno
= info
->first_fp_reg_save
;
4066 int loc
= info
->fp_save_offset
+ sp_offset
;
4068 for ( ; regno
< 64; regno
++, loc
+= 8)
4069 asm_fprintf (file
, "\tstfd %s,%d(%s)\n", reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4071 else if (info
->first_fp_reg_save
!= 64)
4072 asm_fprintf (file
, "\tbl %s%d%s\n", SAVE_FP_PREFIX
,
4073 info
->first_fp_reg_save
- 32, SAVE_FP_SUFFIX
);
4075 /* Now save gpr's. */
4076 if (! TARGET_MULTIPLE
|| info
->first_gp_reg_save
== 31 || TARGET_64BIT
)
4078 int regno
= info
->first_gp_reg_save
;
4079 int loc
= info
->gp_save_offset
+ sp_offset
;
4081 for ( ; regno
< 32; regno
++, loc
+= reg_size
)
4082 asm_fprintf (file
, store_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4085 else if (info
->first_gp_reg_save
!= 32)
4086 asm_fprintf (file
, "\t{stm|stmw} %s,%d(%s)\n",
4087 reg_names
[info
->first_gp_reg_save
],
4088 info
->gp_save_offset
+ sp_offset
,
4091 /* Save main's arguments if we need to call a function */
4093 if (info
->main_save_p
)
4096 int loc
= info
->main_save_offset
+ sp_offset
;
4097 int size
= info
->main_size
;
4099 for (regno
= 3; size
> 0; regno
++, loc
+= reg_size
, size
-= reg_size
)
4100 asm_fprintf (file
, store_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4104 /* Save lr if we used it. */
4105 if (info
->lr_save_p
)
4106 asm_fprintf (file
, store_reg
, reg_names
[0], info
->lr_save_offset
+ sp_offset
,
4109 /* Save CR if we use any that must be preserved. */
4110 if (info
->cr_save_p
)
4112 if (sp_reg
== 12) /* If r12 is used to hold the original sp, copy cr now */
4114 asm_fprintf (file
, "\tmfcr %s\n", reg_names
[0]);
4115 asm_fprintf (file
, store_reg
, reg_names
[0],
4116 info
->cr_save_offset
+ sp_offset
,
4120 asm_fprintf (file
, store_reg
, reg_names
[12], info
->cr_save_offset
+ sp_offset
,
4124 /* NT needs us to probe the stack frame every 4k pages for large frames, so
4126 if (DEFAULT_ABI
== ABI_NT
&& info
->total_size
> 4096)
4128 if (info
->total_size
< 32768)
4130 int probe_offset
= 4096;
4131 while (probe_offset
< info
->total_size
)
4133 asm_fprintf (file
, "\t{l|lwz} %s,%d(%s)\n", reg_names
[0], -probe_offset
, reg_names
[1]);
4134 probe_offset
+= 4096;
4139 int probe_iterations
= info
->total_size
/ 4096;
4140 static int probe_labelno
= 0;
4143 if (probe_iterations
< 32768)
4144 asm_fprintf (file
, "\tli %s,%d\n", reg_names
[12], probe_iterations
);
4147 asm_fprintf (file
, "\tlis %s,%d\n", reg_names
[12], probe_iterations
>> 16);
4148 if (probe_iterations
& 0xffff)
4149 asm_fprintf (file
, "\tori %s,%s,%d\n", reg_names
[12], reg_names
[12],
4150 probe_iterations
& 0xffff);
4152 asm_fprintf (file
, "\tmtctr %s\n", reg_names
[12]);
4153 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
4154 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCprobe", probe_labelno
);
4155 asm_fprintf (file
, "\t{lu|lwzu} %s,-4096(%s)\n", reg_names
[0], reg_names
[12]);
4156 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCprobe", probe_labelno
++);
4157 fputs ("\tbdnz ", file
);
4158 assemble_name (file
, buf
);
4163 /* Update stack and set back pointer unless this is V.4, which was done previously */
4164 if (info
->push_p
&& DEFAULT_ABI
!= ABI_V4
&& DEFAULT_ABI
!= ABI_SOLARIS
)
4165 rs6000_allocate_stack_space (file
, info
->total_size
, FALSE
);
4167 /* Set frame pointer, if needed. */
4168 if (frame_pointer_needed
)
4169 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[31], reg_names
[1]);
4172 /* If we need to call a function to set things up for main, do so now
4173 before dealing with the TOC. */
4176 const char *prefix
= "";
4178 switch (DEFAULT_ABI
)
4180 case ABI_AIX
: prefix
= "."; break;
4181 case ABI_NT
: prefix
= ".."; break;
4184 fprintf (file
, "\tbl %s%s\n", prefix
, NAME__MAIN
);
4185 #ifdef RS6000_CALL_GLUE2
4186 fprintf (file
, "\t%s%s%s\n", RS6000_CALL_GLUE2
, prefix
, NAME_MAIN
);
4188 #ifdef RS6000_CALL_GLUE
4189 if (DEFAULT_ABI
== ABI_AIX
|| DEFAULT_ABI
== ABI_NT
)
4190 fprintf (file
, "\t%s\n", RS6000_CALL_GLUE
);
4194 if (info
->main_save_p
)
4198 int size
= info
->main_size
;
4200 if (info
->total_size
< 32767)
4202 loc
= info
->total_size
+ info
->main_save_offset
;
4203 for (regno
= 3; size
> 0; regno
++, size
-= reg_size
, loc
+= reg_size
)
4204 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[1]);
4208 int neg_size
= info
->main_save_offset
- info
->total_size
;
4210 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
4211 reg_names
[0], (neg_size
>> 16) & 0xffff,
4212 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
4214 asm_fprintf (file
, "\t{sf|subf} %s,%s,%s\n", reg_names
[0], reg_names
[0],
4217 for (regno
= 3; size
> 0; regno
++, size
-= reg_size
, loc
+= reg_size
)
4218 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[0]);
4225 /* If TARGET_MINIMAL_TOC, and the constant pool is needed, then load the
4226 TOC_TABLE address into register 30. */
4227 if (TARGET_TOC
&& TARGET_MINIMAL_TOC
&& get_pool_size () != 0)
4231 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
4233 rs6000_output_load_toc_table (file
, 30);
4236 if (DEFAULT_ABI
== ABI_NT
)
4238 assemble_name (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4239 fputs (".b:\n", file
);
4243 /* Write function epilogue. */
4246 output_epilog (file
, size
)
4248 int size ATTRIBUTE_UNUSED
;
4250 rs6000_stack_t
*info
= rs6000_stack_info ();
4251 const char *load_reg
= (TARGET_32BIT
) ? "\t{l|lwz} %s,%d(%s)\n" : "\tld %s,%d(%s)\n";
4252 rtx insn
= get_last_insn ();
4256 /* If the last insn was a BARRIER, we don't have to write anything except
4258 if (GET_CODE (insn
) == NOTE
)
4259 insn
= prev_nonnote_insn (insn
);
4260 if (insn
== 0 || GET_CODE (insn
) != BARRIER
)
4262 /* If we have a frame pointer, a call to alloca, or a large stack
4263 frame, restore the old stack pointer using the backchain. Otherwise,
4264 we know what size to update it with. */
4265 if (frame_pointer_needed
|| current_function_calls_alloca
4266 || info
->total_size
> 32767)
4268 /* Under V.4, don't reset the stack pointer until after we're done
4269 loading the saved registers. */
4270 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
4273 asm_fprintf (file
, load_reg
, reg_names
[sp_reg
], 0, reg_names
[1]);
4275 else if (info
->push_p
)
4277 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
4278 sp_offset
= info
->total_size
;
4280 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
4281 reg_names
[1], info
->total_size
, reg_names
[1]);
4284 /* Get the old lr if we saved it. */
4285 if (info
->lr_save_p
)
4286 asm_fprintf (file
, load_reg
, reg_names
[0], info
->lr_save_offset
+ sp_offset
, reg_names
[sp_reg
]);
4288 /* Get the old cr if we saved it. */
4289 if (info
->cr_save_p
)
4290 asm_fprintf (file
, load_reg
, reg_names
[12], info
->cr_save_offset
+ sp_offset
, reg_names
[sp_reg
]);
4292 /* Set LR here to try to overlap restores below. */
4293 if (info
->lr_save_p
)
4294 asm_fprintf (file
, "\tmtlr %s\n", reg_names
[0]);
4296 /* Restore gpr's. */
4297 if (! TARGET_MULTIPLE
|| info
->first_gp_reg_save
== 31 || TARGET_64BIT
)
4299 int regno
= info
->first_gp_reg_save
;
4300 int loc
= info
->gp_save_offset
+ sp_offset
;
4301 int reg_size
= (TARGET_32BIT
) ? 4 : 8;
4303 for ( ; regno
< 32; regno
++, loc
+= reg_size
)
4304 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4307 else if (info
->first_gp_reg_save
!= 32)
4308 asm_fprintf (file
, "\t{lm|lmw} %s,%d(%s)\n",
4309 reg_names
[info
->first_gp_reg_save
],
4310 info
->gp_save_offset
+ sp_offset
,
4313 /* Restore fpr's if we can do it without calling a function. */
4314 if (FP_SAVE_INLINE (info
->first_fp_reg_save
))
4316 int regno
= info
->first_fp_reg_save
;
4317 int loc
= info
->fp_save_offset
+ sp_offset
;
4319 for ( ; regno
< 64; regno
++, loc
+= 8)
4320 asm_fprintf (file
, "\tlfd %s,%d(%s)\n", reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4323 /* If we saved cr, restore it here. Just those of cr2, cr3, and cr4
4325 if (info
->cr_save_p
)
4326 asm_fprintf (file
, "\tmtcrf %d,%s\n",
4327 (regs_ever_live
[70] != 0) * 0x20
4328 + (regs_ever_live
[71] != 0) * 0x10
4329 + (regs_ever_live
[72] != 0) * 0x8, reg_names
[12]);
4331 /* If this is V.4, unwind the stack pointer after all of the loads
4334 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
4335 reg_names
[1], sp_offset
, reg_names
[1]);
4336 else if (sp_reg
!= 1)
4337 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[1], reg_names
[sp_reg
]);
4339 /* If we have to restore more than two FP registers, branch to the
4340 restore function. It will return to our caller. */
4341 if (info
->first_fp_reg_save
!= 64 && !FP_SAVE_INLINE (info
->first_fp_reg_save
))
4342 asm_fprintf (file
, "\tb %s%d%s\n", RESTORE_FP_PREFIX
,
4343 info
->first_fp_reg_save
- 32, RESTORE_FP_SUFFIX
);
4345 asm_fprintf (file
, "\t{br|blr}\n");
4348 /* Output a traceback table here. See /usr/include/sys/debug.h for info
4351 We don't output a traceback table if -finhibit-size-directive was
4352 used. The documentation for -finhibit-size-directive reads
4353 ``don't output a @code{.size} assembler directive, or anything
4354 else that would cause trouble if the function is split in the
4355 middle, and the two halves are placed at locations far apart in
4356 memory.'' The traceback table has this property, since it
4357 includes the offset from the start of the function to the
4358 traceback table itself.
4360 System V.4 Powerpc's (and the embedded ABI derived from it) use a
4361 different traceback table. */
4362 if (DEFAULT_ABI
== ABI_AIX
&& ! flag_inhibit_size_directive
)
4364 char *fname
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
4365 int fixed_parms
, float_parms
, parm_info
;
4368 while (*fname
== '.') /* V.4 encodes . in the name */
4371 /* Need label immediately before tbtab, so we can compute its offset
4372 from the function start. */
4375 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LT");
4376 ASM_OUTPUT_LABEL (file
, fname
);
4378 /* The .tbtab pseudo-op can only be used for the first eight
4379 expressions, since it can't handle the possibly variable
4380 length fields that follow. However, if you omit the optional
4381 fields, the assembler outputs zeros for all optional fields
4382 anyways, giving each variable length field is minimum length
4383 (as defined in sys/debug.h). Thus we can not use the .tbtab
4384 pseudo-op at all. */
4386 /* An all-zero word flags the start of the tbtab, for debuggers
4387 that have to find it by searching forward from the entry
4388 point or from the current pc. */
4389 fputs ("\t.long 0\n", file
);
4391 /* Tbtab format type. Use format type 0. */
4392 fputs ("\t.byte 0,", file
);
4394 /* Language type. Unfortunately, there doesn't seem to be any
4395 official way to get this info, so we use language_string. C
4396 is 0. C++ is 9. No number defined for Obj-C, so use the
4397 value for C for now. There is no official value for Java,
4398 although IBM appears to be using 13. There is no official value
4399 for Chill, so we've choosen 44 pseudo-randomly. */
4400 if (! strcmp (language_string
, "GNU C")
4401 || ! strcmp (language_string
, "GNU Obj-C"))
4403 else if (! strcmp (language_string
, "GNU F77"))
4405 else if (! strcmp (language_string
, "GNU Ada"))
4407 else if (! strcmp (language_string
, "GNU Pascal"))
4409 else if (! strcmp (language_string
, "GNU C++"))
4411 else if (! strcmp (language_string
, "GNU Java"))
4413 else if (! strcmp (language_string
, "GNU CHILL"))
4417 fprintf (file
, "%d,", i
);
4419 /* 8 single bit fields: global linkage (not set for C extern linkage,
4420 apparently a PL/I convention?), out-of-line epilogue/prologue, offset
4421 from start of procedure stored in tbtab, internal function, function
4422 has controlled storage, function has no toc, function uses fp,
4423 function logs/aborts fp operations. */
4424 /* Assume that fp operations are used if any fp reg must be saved. */
4425 fprintf (file
, "%d,", (1 << 5) | ((info
->first_fp_reg_save
!= 64) << 1));
4427 /* 6 bitfields: function is interrupt handler, name present in
4428 proc table, function calls alloca, on condition directives
4429 (controls stack walks, 3 bits), saves condition reg, saves
4431 /* The `function calls alloca' bit seems to be set whenever reg 31 is
4432 set up as a frame pointer, even when there is no alloca call. */
4433 fprintf (file
, "%d,",
4434 ((1 << 6) | (frame_pointer_needed
<< 5)
4435 | (info
->cr_save_p
<< 1) | (info
->lr_save_p
)));
4437 /* 3 bitfields: saves backchain, spare bit, number of fpr saved
4439 fprintf (file
, "%d,",
4440 (info
->push_p
<< 7) | (64 - info
->first_fp_reg_save
));
4442 /* 2 bitfields: spare bits (2 bits), number of gpr saved (6 bits). */
4443 fprintf (file
, "%d,", (32 - first_reg_to_save ()));
4446 /* Compute the parameter info from the function decl argument
4449 int next_parm_info_bit
;
4451 next_parm_info_bit
= 31;
4456 for (decl
= DECL_ARGUMENTS (current_function_decl
);
4457 decl
; decl
= TREE_CHAIN (decl
))
4459 rtx parameter
= DECL_INCOMING_RTL (decl
);
4460 enum machine_mode mode
= GET_MODE (parameter
);
4462 if (GET_CODE (parameter
) == REG
)
4464 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
4472 else if (mode
== DFmode
)
4477 /* If only one bit will fit, don't or in this entry. */
4478 if (next_parm_info_bit
> 0)
4479 parm_info
|= (bits
<< (next_parm_info_bit
- 1));
4480 next_parm_info_bit
-= 2;
4484 fixed_parms
+= ((GET_MODE_SIZE (mode
)
4485 + (UNITS_PER_WORD
- 1))
4487 next_parm_info_bit
-= 1;
4493 /* Number of fixed point parameters. */
4494 /* This is actually the number of words of fixed point parameters; thus
4495 an 8 byte struct counts as 2; and thus the maximum value is 8. */
4496 fprintf (file
, "%d,", fixed_parms
);
4498 /* 2 bitfields: number of floating point parameters (7 bits), parameters
4500 /* This is actually the number of fp registers that hold parameters;
4501 and thus the maximum value is 13. */
4502 /* Set parameters on stack bit if parameters are not in their original
4503 registers, regardless of whether they are on the stack? Xlc
4504 seems to set the bit when not optimizing. */
4505 fprintf (file
, "%d\n", ((float_parms
<< 1) | (! optimize
)));
4507 /* Optional fields follow. Some are variable length. */
4509 /* Parameter types, left adjusted bit fields: 0 fixed, 10 single float,
4511 /* There is an entry for each parameter in a register, in the order that
4512 they occur in the parameter list. Any intervening arguments on the
4513 stack are ignored. If the list overflows a long (max possible length
4514 34 bits) then completely leave off all elements that don't fit. */
4515 /* Only emit this long if there was at least one parameter. */
4516 if (fixed_parms
|| float_parms
)
4517 fprintf (file
, "\t.long %d\n", parm_info
);
4519 /* Offset from start of code to tb table. */
4520 fputs ("\t.long ", file
);
4521 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LT");
4522 RS6000_OUTPUT_BASENAME (file
, fname
);
4524 RS6000_OUTPUT_BASENAME (file
, fname
);
4527 /* Interrupt handler mask. */
4528 /* Omit this long, since we never set the interrupt handler bit
4531 /* Number of CTL (controlled storage) anchors. */
4532 /* Omit this long, since the has_ctl bit is never set above. */
4534 /* Displacement into stack of each CTL anchor. */
4535 /* Omit this list of longs, because there are no CTL anchors. */
4537 /* Length of function name. */
4538 fprintf (file
, "\t.short %d\n", (int) strlen (fname
));
4540 /* Function name. */
4541 assemble_string (fname
, strlen (fname
));
4543 /* Register for alloca automatic storage; this is always reg 31.
4544 Only emit this if the alloca bit was set above. */
4545 if (frame_pointer_needed
)
4546 fputs ("\t.byte 31\n", file
);
4549 if (DEFAULT_ABI
== ABI_NT
)
4551 RS6000_OUTPUT_BASENAME (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4552 fputs (".e:\nFE_MOT_RESVD..", file
);
4553 RS6000_OUTPUT_BASENAME (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4554 fputs (":\n", file
);
4558 /* A C compound statement that outputs the assembler code for a thunk function,
4559 used to implement C++ virtual function calls with multiple inheritance. The
4560 thunk acts as a wrapper around a virtual function, adjusting the implicit
4561 object parameter before handing control off to the real function.
4563 First, emit code to add the integer DELTA to the location that contains the
4564 incoming first argument. Assume that this argument contains a pointer, and
4565 is the one used to pass the `this' pointer in C++. This is the incoming
4566 argument *before* the function prologue, e.g. `%o0' on a sparc. The
4567 addition must preserve the values of all other incoming arguments.
4569 After the addition, emit code to jump to FUNCTION, which is a
4570 `FUNCTION_DECL'. This is a direct pure jump, not a call, and does not touch
4571 the return address. Hence returning from FUNCTION will return to whoever
4572 called the current `thunk'.
4574 The effect must be as if FUNCTION had been called directly with the adjusted
4575 first argument. This macro is responsible for emitting all of the code for
4576 a thunk function; `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE' are not
4579 The THUNK_FNDECL is redundant. (DELTA and FUNCTION have already been
4580 extracted from it.) It might possibly be useful on some targets, but
4583 If you do not define this macro, the target-independent code in the C++
4584 frontend will generate a less efficient heavyweight thunk that calls
4585 FUNCTION instead of jumping to it. The generic approach does not support
4589 output_mi_thunk (file
, thunk_fndecl
, delta
, function
)
4591 tree thunk_fndecl ATTRIBUTE_UNUSED
;
4595 const char *this_reg
= reg_names
[ aggregate_value_p (TREE_TYPE (TREE_TYPE (function
))) ? 4 : 3 ];
4598 const char *r0
= reg_names
[0];
4599 const char *sp
= reg_names
[1];
4600 const char *toc
= reg_names
[2];
4601 const char *schain
= reg_names
[11];
4602 const char *r12
= reg_names
[12];
4604 static int labelno
= 0;
4606 /* Small constants that can be done by one add instruction */
4607 if (delta
>= -32768 && delta
<= 32767)
4609 if (! TARGET_NEW_MNEMONICS
)
4610 fprintf (file
, "\tcal %s,%d(%s)\n", this_reg
, delta
, this_reg
);
4612 fprintf (file
, "\taddi %s,%s,%d\n", this_reg
, this_reg
, delta
);
4615 /* Large constants that can be done by one addis instruction */
4616 else if ((delta
& 0xffff) == 0 && num_insns_constant_wide (delta
) == 1)
4617 asm_fprintf (file
, "\t{cau|addis} %s,%s,%d\n", this_reg
, this_reg
,
4620 /* 32-bit constants that can be done by an add and addis instruction. */
4621 else if (TARGET_32BIT
|| num_insns_constant_wide (delta
) == 1)
4623 /* Break into two pieces, propagating the sign bit from the low word to
4625 int delta_high
= delta
>> 16;
4626 int delta_low
= delta
& 0xffff;
4627 if ((delta_low
& 0x8000) != 0)
4630 delta_low
= (delta_low
^ 0x8000) - 0x8000; /* sign extend */
4633 asm_fprintf (file
, "\t{cau|addis} %s,%s,%d\n", this_reg
, this_reg
,
4636 if (! TARGET_NEW_MNEMONICS
)
4637 fprintf (file
, "\tcal %s,%d(%s)\n", this_reg
, delta_low
, this_reg
);
4639 fprintf (file
, "\taddi %s,%s,%d\n", this_reg
, this_reg
, delta_low
);
4642 /* 64-bit constants, fixme */
4646 /* Get the prefix in front of the names. */
4647 switch (DEFAULT_ABI
)
4657 case ABI_AIX_NODESC
:
4667 /* If the function is compiled in this module, jump to it directly.
4668 Otherwise, load up its address and jump to it. */
4670 fname
= XSTR (XEXP (DECL_RTL (function
), 0), 0);
4672 if (current_file_function_operand (XEXP (DECL_RTL (function
), 0))
4673 && ! lookup_attribute ("longcall",
4674 TYPE_ATTRIBUTES (TREE_TYPE (function
))))
4676 fprintf (file
, "\tb %s", prefix
);
4677 assemble_name (file
, fname
);
4678 if (DEFAULT_ABI
== ABI_V4
&& flag_pic
) fputs ("@local", file
);
4684 switch (DEFAULT_ABI
)
4691 /* Set up a TOC entry for the function. */
4692 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lthunk", labelno
);
4694 ASM_OUTPUT_INTERNAL_LABEL (file
, "Lthunk", labelno
);
4697 /* Note, MINIMAL_TOC doesn't make sense in the case of a thunk, since
4698 there will be only one TOC entry for this function. */
4699 fputs ("\t.tc\t", file
);
4700 assemble_name (file
, buf
);
4701 fputs ("[TC],", file
);
4702 assemble_name (file
, buf
);
4705 asm_fprintf (file
, (TARGET_32BIT
) ? "\t{l|lwz} %s," : "\tld %s", r12
);
4706 assemble_name (file
, buf
);
4707 asm_fprintf (file
, "(%s)\n", reg_names
[2]);
4709 (TARGET_32BIT
) ? "\t{l|lwz} %s,0(%s)\n" : "\tld %s,0(%s)\n",
4713 (TARGET_32BIT
) ? "\t{l|lwz} %s,4(%s)\n" : "\tld %s,8(%s)\n",
4716 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4718 (TARGET_32BIT
) ? "\t{l|lwz} %s,8(%s)\n" : "\tld %s,16(%s)\n",
4721 asm_fprintf (file
, "\tbctr\n");
4725 fprintf (file
, "\tb %s", prefix
);
4726 assemble_name (file
, fname
);
4727 if (flag_pic
) fputs ("@plt", file
);
4731 /* Don't use r11, that contains the static chain, just use r0/r12. */
4732 case ABI_AIX_NODESC
:
4736 fprintf (file
, "\tmflr %s\n", r0
);
4737 fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file
);
4738 asm_fprintf (file
, "\tmflr %s\n", r12
);
4739 asm_fprintf (file
, "\tmtlr %s\n", r0
);
4740 asm_fprintf (file
, "\t{l|lwz} %s,", r0
);
4741 assemble_name (file
, fname
);
4742 asm_fprintf (file
, "@got(%s)\n", r12
);
4743 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4744 asm_fprintf (file
, "\tbctr\n");
4747 else if (flag_pic
> 1 || TARGET_RELOCATABLE
)
4749 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lthunk", labelno
);
4751 fprintf (file
, "\tmflr %s\n", r0
);
4752 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n", r0
, sp
);
4753 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
4754 rs6000_output_load_toc_table (file
, 12);
4755 asm_fprintf (file
, "\t{l|lwz} %s,", r0
);
4756 assemble_name (file
, buf
);
4757 asm_fprintf (file
, "(%s)\n", r12
);
4758 asm_fprintf (file
, "\t{l|lwz} %s,4(%s)\n", r12
, sp
);
4759 asm_fprintf (file
, "\tmtlr %s\n", r12
);
4760 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4761 asm_fprintf (file
, "\tbctr\n");
4762 asm_fprintf (file
, "%s\n", MINIMAL_TOC_SECTION_ASM_OP
);
4763 assemble_name (file
, buf
);
4764 fputs (" = .-.LCTOC1\n", file
);
4765 fputs ("\t.long ", file
);
4766 assemble_name (file
, fname
);
4767 fputs ("\n\t.previous\n", file
);
4769 #endif /* TARGET_ELF */
4773 asm_fprintf (file
, "\t{liu|lis} %s,", r12
);
4774 assemble_name (file
, fname
);
4775 asm_fprintf (file
, "@ha\n");
4776 asm_fprintf (file
, "\t{cal|la} %s,", r12
);
4777 assemble_name (file
, fname
);
4778 asm_fprintf (file
, "@l(%s)\n", r12
);
4779 asm_fprintf (file
, "\tmtctr %s\n", r12
);
4780 asm_fprintf (file
, "\tbctr\n");
4789 /* Output a TOC entry. We derive the entry name from what is
4793 output_toc (file
, x
, labelno
)
4807 /* if we're going to put a double constant in the TOC, make sure it's
4808 aligned properly when strict alignment is on. */
4809 if (GET_CODE (x
) == CONST_DOUBLE
4811 && GET_MODE (x
) == DFmode
4812 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
)) {
4813 ASM_OUTPUT_ALIGN (file
, 3);
4817 if (TARGET_ELF
&& TARGET_MINIMAL_TOC
)
4819 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LC");
4820 fprintf (file
, "%d = .-", labelno
);
4821 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LCTOC");
4822 fputs ("1\n", file
);
4825 ASM_OUTPUT_INTERNAL_LABEL (file
, "LC", labelno
);
4827 /* Handle FP constants specially. Note that if we have a minimal
4828 TOC, things we put here aren't actually in the TOC, so we can allow
4830 if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == DFmode
4831 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4836 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
4837 REAL_VALUE_TO_TARGET_DOUBLE (rv
, k
);
4840 if (TARGET_MINIMAL_TOC
)
4841 fprintf (file
, "\t.llong 0x%lx%08lx\n", k
[0], k
[1]);
4843 fprintf (file
, "\t.tc FD_%lx_%lx[TC],0x%lx%08lx\n",
4844 k
[0], k
[1], k
[0] & 0xffffffff, k
[1] & 0xffffffff);
4849 if (TARGET_MINIMAL_TOC
)
4850 fprintf (file
, "\t.long %ld\n\t.long %ld\n", k
[0], k
[1]);
4852 fprintf (file
, "\t.tc FD_%lx_%lx[TC],%ld,%ld\n",
4853 k
[0], k
[1], k
[0], k
[1]);
4857 else if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == SFmode
4858 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4863 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
4864 REAL_VALUE_TO_TARGET_SINGLE (rv
, l
);
4866 if (TARGET_MINIMAL_TOC
)
4867 fprintf (file
, TARGET_32BIT
? "\t.long %ld\n" : "\t.llong %ld\n", l
);
4869 fprintf (file
, "\t.tc FS_%lx[TC],%ld\n", l
, l
);
4872 else if (GET_MODE (x
) == DImode
4873 && (GET_CODE (x
) == CONST_INT
|| GET_CODE (x
) == CONST_DOUBLE
)
4874 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4879 if (GET_CODE (x
) == CONST_DOUBLE
)
4881 low
= CONST_DOUBLE_LOW (x
);
4882 high
= CONST_DOUBLE_HIGH (x
);
4885 #if HOST_BITS_PER_WIDE_INT == 32
4888 high
= (low
< 0) ? ~0 : 0;
4892 low
= INTVAL (x
) & 0xffffffff;
4893 high
= (HOST_WIDE_INT
) INTVAL (x
) >> 32;
4899 if (TARGET_MINIMAL_TOC
)
4900 fprintf (file
, "\t.llong 0x%lx%08lx\n", (long)high
, (long)low
);
4902 fprintf (file
, "\t.tc ID_%lx_%lx[TC],0x%lx%08lx\n",
4903 (long)high
, (long)low
, (long)high
, (long)low
);
4908 if (TARGET_MINIMAL_TOC
)
4909 fprintf (file
, "\t.long %ld\n\t.long %ld\n",
4910 (long)high
, (long)low
);
4912 fprintf (file
, "\t.tc ID_%lx_%lx[TC],%ld,%ld\n",
4913 (long)high
, (long)low
, (long)high
, (long)low
);
4918 if (GET_CODE (x
) == CONST
)
4920 base
= XEXP (XEXP (x
, 0), 0);
4921 offset
= INTVAL (XEXP (XEXP (x
, 0), 1));
4924 if (GET_CODE (base
) == SYMBOL_REF
)
4925 name
= XSTR (base
, 0);
4926 else if (GET_CODE (base
) == LABEL_REF
)
4927 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (XEXP (base
, 0)));
4928 else if (GET_CODE (base
) == CODE_LABEL
)
4929 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (base
));
4933 STRIP_NAME_ENCODING (real_name
, name
);
4934 if (TARGET_MINIMAL_TOC
)
4935 fputs (TARGET_32BIT
? "\t.long " : "\t.llong ", file
);
4938 fprintf (file
, "\t.tc %s", real_name
);
4941 fprintf (file
, ".N%d", - offset
);
4943 fprintf (file
, ".P%d", offset
);
4945 fputs ("[TC],", file
);
4948 /* Currently C++ toc references to vtables can be emitted before it
4949 is decided whether the vtable is public or private. If this is
4950 the case, then the linker will eventually complain that there is
4951 a TOC reference to an unknown section. Thus, for vtables only,
4952 we emit the TOC reference to reference the symbol and not the
4954 if (!strncmp ("_vt.", name
, 4))
4956 RS6000_OUTPUT_BASENAME (file
, name
);
4958 fprintf (file
, "%d", offset
);
4959 else if (offset
> 0)
4960 fprintf (file
, "+%d", offset
);
4963 output_addr_const (file
, x
);
4967 /* Output an assembler pseudo-op to write an ASCII string of N characters
4968 starting at P to FILE.
4970 On the RS/6000, we have to do this using the .byte operation and
4971 write out special characters outside the quoted string.
4972 Also, the assembler is broken; very long strings are truncated,
4973 so we must artificially break them up early. */
4976 output_ascii (file
, p
, n
)
4982 int i
, count_string
;
4983 const char *for_string
= "\t.byte \"";
4984 const char *for_decimal
= "\t.byte ";
4985 const char *to_close
= NULL
;
4988 for (i
= 0; i
< n
; i
++)
4991 if (c
>= ' ' && c
< 0177)
4994 fputs (for_string
, file
);
4997 /* Write two quotes to get one. */
5005 for_decimal
= "\"\n\t.byte ";
5009 if (count_string
>= 512)
5011 fputs (to_close
, file
);
5013 for_string
= "\t.byte \"";
5014 for_decimal
= "\t.byte ";
5022 fputs (for_decimal
, file
);
5023 fprintf (file
, "%d", c
);
5025 for_string
= "\n\t.byte \"";
5032 /* Now close the string if we have written one. Then end the line. */
5034 fprintf (file
, to_close
);
5037 /* Generate a unique section name for FILENAME for a section type
5038 represented by SECTION_DESC. Output goes into BUF.
5040 SECTION_DESC can be any string, as long as it is different for each
5041 possible section type.
5043 We name the section in the same manner as xlc. The name begins with an
5044 underscore followed by the filename (after stripping any leading directory
5045 names) with the last period replaced by the string SECTION_DESC. If
5046 FILENAME does not contain a period, SECTION_DESC is appended to the end of
5050 rs6000_gen_section_name (buf
, filename
, section_desc
)
5055 char *q
, *after_last_slash
, *last_period
= 0;
5059 after_last_slash
= filename
;
5060 for (q
= filename
; *q
; q
++)
5063 after_last_slash
= q
+ 1;
5068 len
= strlen (after_last_slash
) + strlen (section_desc
) + 2;
5069 *buf
= (char *) permalloc (len
);
5074 for (q
= after_last_slash
; *q
; q
++)
5076 if (q
== last_period
)
5078 strcpy (p
, section_desc
);
5079 p
+= strlen (section_desc
);
5082 else if (ISALNUM (*q
))
5086 if (last_period
== 0)
5087 strcpy (p
, section_desc
);
5092 /* Write function profiler code. */
5095 output_function_profiler (file
, labelno
)
5099 /* The last used parameter register. */
5104 ASM_GENERATE_INTERNAL_LABEL (buf
, "LP", labelno
);
5105 switch (DEFAULT_ABI
)
5112 case ABI_AIX_NODESC
:
5113 fprintf (file
, "\tmflr %s\n", reg_names
[0]);
5116 fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file
);
5117 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5118 reg_names
[0], reg_names
[1]);
5119 asm_fprintf (file
, "\tmflr %s\n", reg_names
[12]);
5120 asm_fprintf (file
, "\t{l|lwz} %s,", reg_names
[0]);
5121 assemble_name (file
, buf
);
5122 asm_fprintf (file
, "@got(%s)\n", reg_names
[12]);
5125 else if (flag_pic
> 1 || TARGET_RELOCATABLE
)
5127 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5128 reg_names
[0], reg_names
[1]);
5129 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
5130 rs6000_output_load_toc_table (file
, 12);
5131 asm_fprintf (file
, "\t{l|lwz} %s,", reg_names
[12]);
5132 assemble_name (file
, buf
);
5133 asm_fprintf (file
, "X(%s)\n", reg_names
[12]);
5134 asm_fprintf (file
, "%s\n", MINIMAL_TOC_SECTION_ASM_OP
);
5135 assemble_name (file
, buf
);
5136 fputs ("X = .-.LCTOC1\n", file
);
5137 fputs ("\t.long ", file
);
5138 assemble_name (file
, buf
);
5139 fputs ("\n\t.previous\n", file
);
5144 asm_fprintf (file
, "\t{liu|lis} %s,", reg_names
[12]);
5145 assemble_name (file
, buf
);
5146 fputs ("@ha\n", file
);
5147 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5148 reg_names
[0], reg_names
[1]);
5149 asm_fprintf (file
, "\t{cal|la} %s,", reg_names
[0]);
5150 assemble_name (file
, buf
);
5151 asm_fprintf (file
, "@l(%s)\n", reg_names
[12]);
5154 if (current_function_needs_context
)
5155 asm_fprintf (file
, "\tmr %s,%s\n",
5156 reg_names
[30], reg_names
[STATIC_CHAIN_REGNUM
]);
5157 fprintf (file
, "\tbl %s\n", RS6000_MCOUNT
);
5158 if (current_function_needs_context
)
5159 asm_fprintf (file
, "\tmr %s,%s\n",
5160 reg_names
[STATIC_CHAIN_REGNUM
], reg_names
[30]);
5164 /* Set up a TOC entry for the profiler label. */
5166 ASM_OUTPUT_INTERNAL_LABEL (file
, "LPC", labelno
);
5167 if (TARGET_MINIMAL_TOC
)
5169 fputs (TARGET_32BIT
? "\t.long " : "\t.llong ", file
);
5170 assemble_name (file
, buf
);
5175 fputs ("\t.tc\t", file
);
5176 assemble_name (file
, buf
);
5177 fputs ("[TC],", file
);
5178 assemble_name (file
, buf
);
5183 /* Figure out last used parameter register. The proper thing to do is
5184 to walk incoming args of the function. A function might have live
5185 parameter registers even if it has no incoming args. */
5187 for (last_parm_reg
= 10;
5188 last_parm_reg
> 2 && ! regs_ever_live
[last_parm_reg
];
5192 /* Save parameter registers in regs 23-30 and static chain in r22.
5193 Don't overwrite reg 31, since it might be set up as the frame pointer. */
5195 for (i
= 3, j
= 30; i
<= last_parm_reg
; i
++, j
--)
5196 asm_fprintf (file
, "\tmr %d,%d\n", j
, i
);
5197 if (current_function_needs_context
)
5198 asm_fprintf (file
, "\tmr %d,%d\n", j
, STATIC_CHAIN_REGNUM
);
5200 /* Load location address into r3, and call mcount. */
5202 ASM_GENERATE_INTERNAL_LABEL (buf
, "LPC", labelno
);
5203 asm_fprintf (file
, TARGET_32BIT
? "\t{l|lwz} %s," : "\tld %s,",
5205 assemble_name (file
, buf
);
5206 asm_fprintf (file
, "(%s)\n\tbl %s\n\t%s\n",
5207 reg_names
[2], RS6000_MCOUNT
, RS6000_CALL_GLUE
);
5209 /* Restore parameter registers and static chain. */
5211 for (i
= 3, j
= 30; i
<= last_parm_reg
; i
++, j
--)
5212 asm_fprintf (file
, "\tmr %d,%d\n", i
, j
);
5213 if (current_function_needs_context
)
5214 asm_fprintf (file
, "\tmr %d,%d\n", STATIC_CHAIN_REGNUM
, j
);
5220 /* Adjust the cost of a scheduling dependency. Return the new cost of
5221 a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
5224 rs6000_adjust_cost (insn
, link
, dep_insn
, cost
)
5227 rtx dep_insn ATTRIBUTE_UNUSED
;
5230 if (! recog_memoized (insn
))
5233 if (REG_NOTE_KIND (link
) != 0)
5236 if (REG_NOTE_KIND (link
) == 0)
5238 /* Data dependency; DEP_INSN writes a register that INSN reads some
5241 /* Tell the first scheduling pass about the latency between a mtctr
5242 and bctr (and mtlr and br/blr). The first scheduling pass will not
5243 know about this latency since the mtctr instruction, which has the
5244 latency associated to it, will be generated by reload. */
5245 if (get_attr_type (insn
) == TYPE_JMPREG
)
5246 return TARGET_POWER
? 5 : 4;
5248 /* Fall out to return default cost. */
5254 /* A C statement (sans semicolon) to update the integer scheduling priority
5255 INSN_PRIORITY (INSN). Reduce the priority to execute the INSN earlier,
5256 increase the priority to execute INSN later. Do not define this macro if
5257 you do not need to adjust the scheduling priorities of insns. */
5260 rs6000_adjust_priority (insn
, priority
)
5261 rtx insn ATTRIBUTE_UNUSED
;
5264 /* On machines (like the 750) which have asymetric integer units, where one
5265 integer unit can do multiply and divides and the other can't, reduce the
5266 priority of multiply/divide so it is scheduled before other integer
5270 if (GET_RTX_CLASS (GET_CODE (insn
)) != 'i')
5273 if (GET_CODE (PATTERN (insn
)) == USE
)
5276 switch (rs6000_cpu_attr
) {
5278 switch (get_attr_type (insn
))
5285 fprintf (stderr
, "priority was %#x (%d) before adjustment\n", priority
, priority
);
5286 if (priority
>= 0 && priority
< 0x01000000)
5296 /* Return how many instructions the machine can issue per cycle */
5297 int get_issue_rate()
5299 switch (rs6000_cpu_attr
) {
5322 /* Output assembler code for a block containing the constant parts
5323 of a trampoline, leaving space for the variable parts.
5325 The trampoline should set the static chain pointer to value placed
5326 into the trampoline and should branch to the specified routine. */
5329 rs6000_trampoline_template (file
)
5332 const char *sc
= reg_names
[STATIC_CHAIN_REGNUM
];
5333 const char *r0
= reg_names
[0];
5334 const char *r2
= reg_names
[2];
5336 switch (DEFAULT_ABI
)
5341 /* Under AIX, this is not code at all, but merely a data area,
5342 since that is the way all functions are called. The first word is
5343 the address of the function, the second word is the TOC pointer (r2),
5344 and the third word is the static chain value. */
5349 /* V.4/eabi function pointers are just a single pointer, so we need to
5350 do the full gory code to load up the static chain. */
5353 case ABI_AIX_NODESC
:
5356 /* NT function pointers point to a two word area (real address, TOC)
5357 which unfortunately does not include a static chain field. So we
5358 use the function field to point to ..LTRAMP1 and the toc field
5359 to point to the whole table. */
5361 if (STATIC_CHAIN_REGNUM
== 0
5362 || STATIC_CHAIN_REGNUM
== 2
5364 || !TARGET_NEW_MNEMONICS
)
5367 fprintf (file
, "\t.ualong 0\n"); /* offset 0 */
5368 fprintf (file
, "\t.ualong 0\n"); /* offset 4 */
5369 fprintf (file
, "\t.ualong 0\n"); /* offset 8 */
5370 fprintf (file
, "\t.ualong 0\n"); /* offset 12 */
5371 fprintf (file
, "\t.ualong 0\n"); /* offset 16 */
5372 fprintf (file
, "..LTRAMP1..0:\n"); /* offset 20 */
5373 fprintf (file
, "\tlwz %s,8(%s)\n", r0
, r2
); /* offset 24 */
5374 fprintf (file
, "\tlwz %s,12(%s)\n", sc
, r2
); /* offset 28 */
5375 fprintf (file
, "\tmtctr %s\n", r0
); /* offset 32 */
5376 fprintf (file
, "\tlwz %s,16(%s)\n", r2
, r2
); /* offset 36 */
5377 fprintf (file
, "\tbctr\n"); /* offset 40 */
5384 /* Length in units of the trampoline for entering a nested function. */
5387 rs6000_trampoline_size ()
5391 switch (DEFAULT_ABI
)
5397 ret
= (TARGET_32BIT
) ? 12 : 24;
5402 case ABI_AIX_NODESC
:
5403 ret
= (TARGET_32BIT
) ? 40 : 48;
5414 /* Emit RTL insns to initialize the variable parts of a trampoline.
5415 FNADDR is an RTX for the address of the function's pure code.
5416 CXT is an RTX for the static chain value for the function. */
5419 rs6000_initialize_trampoline (addr
, fnaddr
, cxt
)
5424 enum machine_mode pmode
= Pmode
;
5425 int regsize
= (TARGET_32BIT
) ? 4 : 8;
5426 rtx ctx_reg
= force_reg (pmode
, cxt
);
5428 switch (DEFAULT_ABI
)
5433 /* Macros to shorten the code expansions below. */
5434 #define MEM_DEREF(addr) gen_rtx_MEM (pmode, memory_address (pmode, addr))
5435 #define MEM_PLUS(addr,offset) gen_rtx_MEM (pmode, memory_address (pmode, plus_constant (addr, offset)))
5437 /* Under AIX, just build the 3 word function descriptor */
5440 rtx fn_reg
= gen_reg_rtx (pmode
);
5441 rtx toc_reg
= gen_reg_rtx (pmode
);
5442 emit_move_insn (fn_reg
, MEM_DEREF (fnaddr
));
5443 emit_move_insn (toc_reg
, MEM_PLUS (fnaddr
, 4));
5444 emit_move_insn (MEM_DEREF (addr
), fn_reg
);
5445 emit_move_insn (MEM_PLUS (addr
, regsize
), toc_reg
);
5446 emit_move_insn (MEM_PLUS (addr
, 2*regsize
), ctx_reg
);
5450 /* Under V.4/eabi, call __trampoline_setup to do the real work. */
5453 case ABI_AIX_NODESC
:
5454 emit_library_call (gen_rtx_SYMBOL_REF (SImode
, "__trampoline_setup"),
5457 GEN_INT (rs6000_trampoline_size ()), SImode
,
5462 /* Under NT, update the first word to point to the ..LTRAMP1..0 header,
5463 the second word will point to the whole trampoline, third-fifth words
5464 will then have the real address, static chain, and toc value. */
5467 rtx tramp_reg
= gen_reg_rtx (pmode
);
5468 rtx fn_reg
= gen_reg_rtx (pmode
);
5469 rtx toc_reg
= gen_reg_rtx (pmode
);
5471 emit_move_insn (tramp_reg
, gen_rtx_SYMBOL_REF (pmode
, "..LTRAMP1..0"));
5472 addr
= force_reg (pmode
, addr
);
5473 emit_move_insn (fn_reg
, MEM_DEREF (fnaddr
));
5474 emit_move_insn (toc_reg
, MEM_PLUS (fnaddr
, regsize
));
5475 emit_move_insn (MEM_DEREF (addr
), tramp_reg
);
5476 emit_move_insn (MEM_PLUS (addr
, regsize
), addr
);
5477 emit_move_insn (MEM_PLUS (addr
, 2*regsize
), fn_reg
);
5478 emit_move_insn (MEM_PLUS (addr
, 3*regsize
), ctx_reg
);
5479 emit_move_insn (MEM_PLUS (addr
, 4*regsize
), gen_rtx_REG (pmode
, 2));
5488 /* If defined, a C expression whose value is nonzero if IDENTIFIER
5489 with arguments ARGS is a valid machine specific attribute for DECL.
5490 The attributes in ATTRIBUTES have previously been assigned to DECL. */
5493 rs6000_valid_decl_attribute_p (decl
, attributes
, identifier
, args
)
5494 tree decl ATTRIBUTE_UNUSED
;
5495 tree attributes ATTRIBUTE_UNUSED
;
5496 tree identifier ATTRIBUTE_UNUSED
;
5497 tree args ATTRIBUTE_UNUSED
;
5502 /* If defined, a C expression whose value is nonzero if IDENTIFIER
5503 with arguments ARGS is a valid machine specific attribute for TYPE.
5504 The attributes in ATTRIBUTES have previously been assigned to TYPE. */
5507 rs6000_valid_type_attribute_p (type
, attributes
, identifier
, args
)
5509 tree attributes ATTRIBUTE_UNUSED
;
5513 if (TREE_CODE (type
) != FUNCTION_TYPE
5514 && TREE_CODE (type
) != FIELD_DECL
5515 && TREE_CODE (type
) != TYPE_DECL
)
5518 /* Longcall attribute says that the function is not within 2**26 bytes
5519 of the current function, and to do an indirect call. */
5520 if (is_attribute_p ("longcall", identifier
))
5521 return (args
== NULL_TREE
);
5523 if (DEFAULT_ABI
== ABI_NT
)
5525 /* Stdcall attribute says callee is responsible for popping arguments
5526 if they are not variable. */
5527 if (is_attribute_p ("stdcall", identifier
))
5528 return (args
== NULL_TREE
);
5530 /* Cdecl attribute says the callee is a normal C declaration */
5531 if (is_attribute_p ("cdecl", identifier
))
5532 return (args
== NULL_TREE
);
5534 /* Dllimport attribute says the caller is to call the function
5535 indirectly through a __imp_<name> pointer. */
5536 if (is_attribute_p ("dllimport", identifier
))
5537 return (args
== NULL_TREE
);
5539 /* Dllexport attribute says the callee is to create a __imp_<name>
5541 if (is_attribute_p ("dllexport", identifier
))
5542 return (args
== NULL_TREE
);
5544 /* Exception attribute allows the user to specify 1-2 strings or identifiers
5545 that will fill in the 3rd and 4th fields of the structured exception
5547 if (is_attribute_p ("exception", identifier
))
5551 if (args
== NULL_TREE
)
5554 for (i
= 0; i
< 2 && args
!= NULL_TREE
; i
++)
5556 tree this_arg
= TREE_VALUE (args
);
5557 args
= TREE_PURPOSE (args
);
5559 if (TREE_CODE (this_arg
) != STRING_CST
5560 && TREE_CODE (this_arg
) != IDENTIFIER_NODE
)
5564 return (args
== NULL_TREE
);
5571 /* If defined, a C expression whose value is zero if the attributes on
5572 TYPE1 and TYPE2 are incompatible, one if they are compatible, and
5573 two if they are nearly compatible (which causes a warning to be
5577 rs6000_comp_type_attributes (type1
, type2
)
5578 tree type1 ATTRIBUTE_UNUSED
;
5579 tree type2 ATTRIBUTE_UNUSED
;
5584 /* If defined, a C statement that assigns default attributes to newly
5588 rs6000_set_default_type_attributes (type
)
5589 tree type ATTRIBUTE_UNUSED
;
5593 /* Return a dll import reference corresponding to a call's SYMBOL_REF */
5595 rs6000_dll_import_ref (call_ref
)
5598 const char *call_name
;
5604 if (GET_CODE (call_ref
) != SYMBOL_REF
)
5607 call_name
= XSTR (call_ref
, 0);
5608 len
= sizeof ("__imp_") + strlen (call_name
);
5610 reg2
= gen_reg_rtx (Pmode
);
5612 strcpy (p
, "__imp_");
5613 strcat (p
, call_name
);
5614 node
= get_identifier (p
);
5616 reg1
= force_reg (Pmode
, gen_rtx_SYMBOL_REF (VOIDmode
, IDENTIFIER_POINTER (node
)));
5617 emit_move_insn (reg2
, gen_rtx_MEM (Pmode
, reg1
));
5622 /* Return a reference suitable for calling a function with the longcall attribute. */
5624 rs6000_longcall_ref (call_ref
)
5627 const char *call_name
;
5630 if (GET_CODE (call_ref
) != SYMBOL_REF
)
5633 /* System V adds '.' to the internal name, so skip them. */
5634 call_name
= XSTR (call_ref
, 0);
5635 if (*call_name
== '.')
5637 while (*call_name
== '.')
5640 node
= get_identifier (call_name
);
5641 call_ref
= gen_rtx_SYMBOL_REF (VOIDmode
, IDENTIFIER_POINTER (node
));
5644 return force_reg (Pmode
, call_ref
);
5648 /* A C statement or statements to switch to the appropriate section
5649 for output of RTX in mode MODE. You can assume that RTX is some
5650 kind of constant in RTL. The argument MODE is redundant except in
5651 the case of a `const_int' rtx. Select the section by calling
5652 `text_section' or one of the alternatives for other sections.
5654 Do not define this macro if you put all constants in the read-only
5660 rs6000_select_rtx_section (mode
, x
)
5661 enum machine_mode mode
;
5664 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x
))
5670 /* A C statement or statements to switch to the appropriate
5671 section for output of DECL. DECL is either a `VAR_DECL' node
5672 or a constant of some sort. RELOC indicates whether forming
5673 the initial value of DECL requires link-time relocations. */
5676 rs6000_select_section (decl
, reloc
)
5680 int size
= int_size_in_bytes (TREE_TYPE (decl
));
5682 if (TREE_CODE (decl
) == STRING_CST
)
5684 if (! flag_writable_strings
)
5689 else if (TREE_CODE (decl
) == VAR_DECL
)
5691 if ((flag_pic
&& reloc
)
5692 || !TREE_READONLY (decl
)
5693 || TREE_SIDE_EFFECTS (decl
)
5694 || !DECL_INITIAL (decl
)
5695 || (DECL_INITIAL (decl
) != error_mark_node
5696 && !TREE_CONSTANT (DECL_INITIAL (decl
))))
5698 if (rs6000_sdata
!= SDATA_NONE
&& (size
> 0) && (size
<= g_switch_value
))
5705 if (rs6000_sdata
!= SDATA_NONE
&& (size
> 0) && (size
<= g_switch_value
))
5707 if (rs6000_sdata
== SDATA_EABI
)
5710 sdata_section (); /* System V doesn't have .sdata2/.sbss2 */
5722 /* If we are referencing a function that is static or is known to be
5723 in this file, make the SYMBOL_REF special. We can use this to indicate
5724 that we can branch to this function without emitting a no-op after the
5725 call. For real AIX and NT calling sequences, we also replace the
5726 function name with the real name (1 or 2 leading .'s), rather than
5727 the function descriptor name. This saves a lot of overriding code
5728 to read the prefixes. */
5731 rs6000_encode_section_info (decl
)
5734 if (TREE_CODE (decl
) == FUNCTION_DECL
)
5736 rtx sym_ref
= XEXP (DECL_RTL (decl
), 0);
5737 if (TREE_ASM_WRITTEN (decl
) || ! TREE_PUBLIC (decl
))
5738 SYMBOL_REF_FLAG (sym_ref
) = 1;
5740 if (DEFAULT_ABI
== ABI_AIX
|| DEFAULT_ABI
== ABI_NT
)
5742 const char *prefix
= (DEFAULT_ABI
== ABI_AIX
) ? "." : "..";
5743 char *str
= permalloc (strlen (prefix
) + 1
5744 + strlen (XSTR (sym_ref
, 0)));
5745 strcpy (str
, prefix
);
5746 strcat (str
, XSTR (sym_ref
, 0));
5747 XSTR (sym_ref
, 0) = str
;
5750 else if (rs6000_sdata
!= SDATA_NONE
5751 && (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
5752 && TREE_CODE (decl
) == VAR_DECL
)
5754 int size
= int_size_in_bytes (TREE_TYPE (decl
));
5755 tree section_name
= DECL_SECTION_NAME (decl
);
5756 const char *name
= (char *)0;
5761 if (TREE_CODE (section_name
) == STRING_CST
)
5763 name
= TREE_STRING_POINTER (section_name
);
5764 len
= TREE_STRING_LENGTH (section_name
);
5770 if ((size
> 0 && size
<= g_switch_value
)
5772 && ((len
== sizeof (".sdata")-1 && strcmp (name
, ".sdata") == 0)
5773 || (len
== sizeof (".sdata2")-1 && strcmp (name
, ".sdata2") == 0)
5774 || (len
== sizeof (".sbss")-1 && strcmp (name
, ".sbss") == 0)
5775 || (len
== sizeof (".sbss2")-1 && strcmp (name
, ".sbss2") == 0)
5776 || (len
== sizeof (".PPC.EMB.sdata0")-1 && strcmp (name
, ".PPC.EMB.sdata0") == 0)
5777 || (len
== sizeof (".PPC.EMB.sbss0")-1 && strcmp (name
, ".PPC.EMB.sbss0") == 0))))
5779 rtx sym_ref
= XEXP (DECL_RTL (decl
), 0);
5780 char *str
= permalloc (2 + strlen (XSTR (sym_ref
, 0)));
5782 strcat (str
, XSTR (sym_ref
, 0));
5783 XSTR (sym_ref
, 0) = str
;
5788 #endif /* USING_SVR4_H */
5791 rs6000_fatal_bad_address (op
)
5794 fatal_insn ("bad address", op
);