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. */
2397 rs6000_got_register (value
)
2400 /* The second flow pass currently (June 1999) can't update regs_ever_live
2401 without disturbing other parts of the compiler, so update it here to
2402 make the prolog/epilogue code happy. */
2403 if (no_new_pseudos
&& !regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
])
2404 regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
] = 1;
2406 current_function_uses_pic_offset_table
= 1;
2407 return pic_offset_table_rtx
;
2410 /* Search for any occurrence of the GOT_TOC register marker that should
2411 have been eliminated, but may have crept back in.
2413 This function could completely go away now (June 1999), but we leave it
2414 in for a while until all the possible issues with the new -fpic handling
2421 if (flag_pic
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
2423 rtx got_reg
= gen_rtx_REG (Pmode
, 2);
2424 for ( ; insn
!= NULL_RTX
; insn
= NEXT_INSN (insn
))
2425 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i'
2426 && reg_mentioned_p (got_reg
, PATTERN (insn
)))
2427 fatal_insn ("GOT/TOC register marker not removed:", PATTERN (insn
));
2432 /* Define the structure for the machine field in struct function. */
2433 struct machine_function
2441 /* Functions to save and restore rs6000_fpmem_size.
2442 These will be called, via pointer variables,
2443 from push_function_context and pop_function_context. */
2446 rs6000_save_machine_status (p
)
2449 struct machine_function
*machine
=
2450 (struct machine_function
*) xmalloc (sizeof (struct machine_function
));
2452 p
->machine
= machine
;
2453 machine
->sysv_varargs_p
= rs6000_sysv_varargs_p
;
2454 machine
->fpmem_size
= rs6000_fpmem_size
;
2455 machine
->fpmem_offset
= rs6000_fpmem_offset
;
2459 rs6000_restore_machine_status (p
)
2462 struct machine_function
*machine
= p
->machine
;
2464 rs6000_sysv_varargs_p
= machine
->sysv_varargs_p
;
2465 rs6000_fpmem_size
= machine
->fpmem_size
;
2466 rs6000_fpmem_offset
= machine
->fpmem_offset
;
2469 p
->machine
= (struct machine_function
*)0;
2472 /* Do anything needed before RTL is emitted for each function. */
2475 rs6000_init_expanders ()
2477 /* Reset varargs and save TOC indicator */
2478 rs6000_sysv_varargs_p
= 0;
2479 rs6000_fpmem_size
= 0;
2480 rs6000_fpmem_offset
= 0;
2482 /* Arrange to save and restore machine status around nested functions. */
2483 save_machine_status
= rs6000_save_machine_status
;
2484 restore_machine_status
= rs6000_restore_machine_status
;
2488 /* Print an operand. Recognize special options, documented below. */
2491 #define SMALL_DATA_RELOC ((rs6000_sdata == SDATA_EABI) ? "sda21" : "sdarel")
2492 #define SMALL_DATA_REG ((rs6000_sdata == SDATA_EABI) ? 0 : 13)
2494 #define SMALL_DATA_RELOC "sda21"
2495 #define SMALL_DATA_REG 0
2499 print_operand (file
, x
, code
)
2507 /* These macros test for integers and extract the low-order bits. */
2509 ((GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE) \
2510 && GET_MODE (X) == VOIDmode)
2512 #define INT_LOWPART(X) \
2513 (GET_CODE (X) == CONST_INT ? INTVAL (X) : CONST_DOUBLE_LOW (X))
2518 /* Write out an instruction after the call which may be replaced
2519 with glue code by the loader. This depends on the AIX version. */
2520 asm_fprintf (file
, RS6000_CALL_GLUE
);
2524 /* Write the register number of the TOC register. */
2525 fputs (TARGET_MINIMAL_TOC
? reg_names
[30] : reg_names
[2 /* PIC_OFFSET_TABLE_REGNUM? */ ], file
);
2529 /* Write out either a '.' or '$' for the current location, depending
2530 on whether this is Solaris or not. */
2531 putc ((DEFAULT_ABI
== ABI_SOLARIS
) ? '.' : '$', file
);
2535 /* If X is a constant integer whose low-order 5 bits are zero,
2536 write 'l'. Otherwise, write 'r'. This is a kludge to fix a bug
2537 in the AIX assembler where "sri" with a zero shift count
2538 write a trash instruction. */
2539 if (GET_CODE (x
) == CONST_INT
&& (INTVAL (x
) & 31) == 0)
2546 /* Low-order 16 bits of constant, unsigned. */
2548 output_operand_lossage ("invalid %%b value");
2550 fprintf (file
, "%d", INT_LOWPART (x
) & 0xffff);
2554 /* If the low-order bit is zero, write 'r'; otherwise, write 'l'
2555 for 64-bit mask direction. */
2556 putc (((INT_LOWPART(x
) & 1) == 0 ? 'r' : 'l'), file
);
2560 /* This is an optional cror needed for LE or GE floating-point
2561 comparisons. Otherwise write nothing. */
2562 if ((GET_CODE (x
) == LE
|| GET_CODE (x
) == GE
)
2563 && GET_MODE (XEXP (x
, 0)) == CCFPmode
)
2565 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2567 fprintf (file
, "cror %d,%d,%d\n\t", base_bit
+ 3,
2568 base_bit
+ 2, base_bit
+ (GET_CODE (x
) == GE
));
2573 /* Similar, except that this is for an scc, so we must be able to
2574 encode the test in a single bit that is one. We do the above
2575 for any LE, GE, GEU, or LEU and invert the bit for NE. */
2576 if (GET_CODE (x
) == LE
|| GET_CODE (x
) == GE
2577 || GET_CODE (x
) == LEU
|| GET_CODE (x
) == GEU
)
2579 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2581 fprintf (file
, "cror %d,%d,%d\n\t", base_bit
+ 3,
2583 base_bit
+ (GET_CODE (x
) == GE
|| GET_CODE (x
) == GEU
));
2586 else if (GET_CODE (x
) == NE
)
2588 int base_bit
= 4 * (REGNO (XEXP (x
, 0)) - 68);
2590 fprintf (file
, "crnor %d,%d,%d\n\t", base_bit
+ 3,
2591 base_bit
+ 2, base_bit
+ 2);
2596 /* X is a CR register. Print the number of the third bit of the CR */
2597 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2598 output_operand_lossage ("invalid %%E value");
2600 fprintf(file
, "%d", 4 * (REGNO (x
) - 68) + 3);
2604 /* X is a CR register. Print the shift count needed to move it
2605 to the high-order four bits. */
2606 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2607 output_operand_lossage ("invalid %%f value");
2609 fprintf (file
, "%d", 4 * (REGNO (x
) - 68));
2613 /* Similar, but print the count for the rotate in the opposite
2615 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2616 output_operand_lossage ("invalid %%F value");
2618 fprintf (file
, "%d", 32 - 4 * (REGNO (x
) - 68));
2622 /* X is a constant integer. If it is negative, print "m",
2623 otherwise print "z". This is to make a aze or ame insn. */
2624 if (GET_CODE (x
) != CONST_INT
)
2625 output_operand_lossage ("invalid %%G value");
2626 else if (INTVAL (x
) >= 0)
2633 /* If constant, output low-order five bits. Otherwise,
2636 fprintf (file
, "%d", INT_LOWPART (x
) & 31);
2638 print_operand (file
, x
, 0);
2642 /* If constant, output low-order six bits. Otherwise,
2645 fprintf (file
, "%d", INT_LOWPART (x
) & 63);
2647 print_operand (file
, x
, 0);
2651 /* Print `i' if this is a constant, else nothing. */
2657 /* Write the bit number in CCR for jump. */
2660 output_operand_lossage ("invalid %%j code");
2662 fprintf (file
, "%d", i
);
2666 /* Similar, but add one for shift count in rlinm for scc and pass
2667 scc flag to `ccr_bit'. */
2670 output_operand_lossage ("invalid %%J code");
2672 /* If we want bit 31, write a shift count of zero, not 32. */
2673 fprintf (file
, "%d", i
== 31 ? 0 : i
+ 1);
2677 /* X must be a constant. Write the 1's complement of the
2680 output_operand_lossage ("invalid %%k value");
2682 fprintf (file
, "%d", ~ INT_LOWPART (x
));
2686 /* Write second word of DImode or DFmode reference. Works on register
2687 or non-indexed memory only. */
2688 if (GET_CODE (x
) == REG
)
2689 fprintf (file
, "%s", reg_names
[REGNO (x
) + 1]);
2690 else if (GET_CODE (x
) == MEM
)
2692 /* Handle possible auto-increment. Since it is pre-increment and
2693 we have already done it, we can just use an offset of word. */
2694 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
2695 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
2696 output_address (plus_constant_for_output (XEXP (XEXP (x
, 0), 0),
2699 output_address (plus_constant_for_output (XEXP (x
, 0),
2701 if (small_data_operand (x
, GET_MODE (x
)))
2702 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
2703 reg_names
[SMALL_DATA_REG
]);
2708 /* MB value for a mask operand. */
2709 if (! mask_operand (x
, VOIDmode
))
2710 output_operand_lossage ("invalid %%m value");
2712 val
= INT_LOWPART (x
);
2714 /* If the high bit is set and the low bit is not, the value is zero.
2715 If the high bit is zero, the value is the first 1 bit we find from
2717 if ((val
& 0x80000000) && ((val
& 1) == 0))
2722 else if ((val
& 0x80000000) == 0)
2724 for (i
= 1; i
< 32; i
++)
2725 if ((val
<<= 1) & 0x80000000)
2727 fprintf (file
, "%d", i
);
2731 /* Otherwise, look for the first 0 bit from the right. The result is its
2732 number plus 1. We know the low-order bit is one. */
2733 for (i
= 0; i
< 32; i
++)
2734 if (((val
>>= 1) & 1) == 0)
2737 /* If we ended in ...01, i would be 0. The correct value is 31, so
2739 fprintf (file
, "%d", 31 - i
);
2743 /* ME value for a mask operand. */
2744 if (! mask_operand (x
, VOIDmode
))
2745 output_operand_lossage ("invalid %%M value");
2747 val
= INT_LOWPART (x
);
2749 /* If the low bit is set and the high bit is not, the value is 31.
2750 If the low bit is zero, the value is the first 1 bit we find from
2752 if ((val
& 1) && ((val
& 0x80000000) == 0))
2757 else if ((val
& 1) == 0)
2759 for (i
= 0; i
< 32; i
++)
2760 if ((val
>>= 1) & 1)
2763 /* If we had ....10, i would be 0. The result should be
2764 30, so we need 30 - i. */
2765 fprintf (file
, "%d", 30 - i
);
2769 /* Otherwise, look for the first 0 bit from the left. The result is its
2770 number minus 1. We know the high-order bit is one. */
2771 for (i
= 0; i
< 32; i
++)
2772 if (((val
<<= 1) & 0x80000000) == 0)
2775 fprintf (file
, "%d", i
);
2779 /* Write the number of elements in the vector times 4. */
2780 if (GET_CODE (x
) != PARALLEL
)
2781 output_operand_lossage ("invalid %%N value");
2783 fprintf (file
, "%d", XVECLEN (x
, 0) * 4);
2787 /* Similar, but subtract 1 first. */
2788 if (GET_CODE (x
) != PARALLEL
)
2789 output_operand_lossage ("invalid %%O value");
2791 fprintf (file
, "%d", (XVECLEN (x
, 0) - 1) * 4);
2795 /* X is a CONST_INT that is a power of two. Output the logarithm. */
2797 || (i
= exact_log2 (INT_LOWPART (x
))) < 0)
2798 output_operand_lossage ("invalid %%p value");
2800 fprintf (file
, "%d", i
);
2804 /* The operand must be an indirect memory reference. The result
2805 is the register number. */
2806 if (GET_CODE (x
) != MEM
|| GET_CODE (XEXP (x
, 0)) != REG
2807 || REGNO (XEXP (x
, 0)) >= 32)
2808 output_operand_lossage ("invalid %%P value");
2810 fprintf (file
, "%d", REGNO (XEXP (x
, 0)));
2814 /* X is a CR register. Print the mask for `mtcrf'. */
2815 if (GET_CODE (x
) != REG
|| ! CR_REGNO_P (REGNO (x
)))
2816 output_operand_lossage ("invalid %%R value");
2818 fprintf (file
, "%d", 128 >> (REGNO (x
) - 68));
2822 /* Low 5 bits of 32 - value */
2824 output_operand_lossage ("invalid %%s value");
2826 fprintf (file
, "%d", (32 - INT_LOWPART (x
)) & 31);
2830 /* PowerPC64 mask position. All 0's and all 1's are excluded.
2831 CONST_INT 32-bit mask is considered sign-extended so any
2832 transition must occur within the CONST_INT, not on the boundary. */
2833 if (! mask64_operand (x
, VOIDmode
))
2834 output_operand_lossage ("invalid %%S value");
2836 val
= INT_LOWPART (x
);
2838 if (val
& 1) /* Clear Left */
2840 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
; i
++)
2841 if (!((val
>>= 1) & 1))
2844 #if HOST_BITS_PER_WIDE_INT == 32
2845 if (GET_CODE (x
) == CONST_DOUBLE
&& i
== 32)
2847 val
= CONST_DOUBLE_HIGH (x
);
2852 for (i
= 32; i
< 64; i
++)
2853 if (!((val
>>= 1) & 1))
2857 /* i = index of last set bit from right
2858 mask begins at 63 - i from left */
2860 output_operand_lossage ("%%S computed all 1's mask");
2861 fprintf (file
, "%d", 63 - i
);
2864 else /* Clear Right */
2866 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
; i
++)
2867 if ((val
>>= 1) & 1)
2870 #if HOST_BITS_PER_WIDE_INT == 32
2871 if (GET_CODE (x
) == CONST_DOUBLE
&& i
== 32)
2873 val
= CONST_DOUBLE_HIGH (x
);
2875 if (val
== (HOST_WIDE_INT
) -1)
2878 for (i
= 32; i
< 64; i
++)
2879 if ((val
>>= 1) & 1)
2883 /* i = index of last clear bit from right
2884 mask ends at 62 - i from left */
2886 output_operand_lossage ("%%S computed all 0's mask");
2887 fprintf (file
, "%d", 62 - i
);
2892 /* Write 12 if this jump operation will branch if true, 4 otherwise.
2893 All floating-point operations except NE branch true and integer
2894 EQ, LT, GT, LTU and GTU also branch true. */
2895 if (GET_RTX_CLASS (GET_CODE (x
)) != '<')
2896 output_operand_lossage ("invalid %%t value");
2898 else if ((GET_MODE (XEXP (x
, 0)) == CCFPmode
2899 && GET_CODE (x
) != NE
)
2900 || GET_CODE (x
) == EQ
2901 || GET_CODE (x
) == LT
|| GET_CODE (x
) == GT
2902 || GET_CODE (x
) == LTU
|| GET_CODE (x
) == GTU
)
2909 /* Opposite of 't': write 4 if this jump operation will branch if true,
2911 if (GET_RTX_CLASS (GET_CODE (x
)) != '<')
2912 output_operand_lossage ("invalid %%T value");
2914 else if ((GET_MODE (XEXP (x
, 0)) == CCFPmode
2915 && GET_CODE (x
) != NE
)
2916 || GET_CODE (x
) == EQ
2917 || GET_CODE (x
) == LT
|| GET_CODE (x
) == GT
2918 || GET_CODE (x
) == LTU
|| GET_CODE (x
) == GTU
)
2925 /* High-order 16 bits of constant for use in unsigned operand. */
2927 output_operand_lossage ("invalid %%u value");
2929 fprintf (file
, "0x%x", (INT_LOWPART (x
) >> 16) & 0xffff);
2933 /* High-order 16 bits of constant for use in signed operand. */
2935 output_operand_lossage ("invalid %%v value");
2938 int value
= (INT_LOWPART (x
) >> 16) & 0xffff;
2940 /* Solaris assembler doesn't like lis 0,0x8000 */
2941 if (DEFAULT_ABI
== ABI_SOLARIS
&& (value
& 0x8000) != 0)
2942 fprintf (file
, "%d", value
| (~0 << 16));
2944 fprintf (file
, "0x%x", value
);
2949 /* Print `u' if this has an auto-increment or auto-decrement. */
2950 if (GET_CODE (x
) == MEM
2951 && (GET_CODE (XEXP (x
, 0)) == PRE_INC
2952 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
))
2957 /* Print the trap code for this operand. */
2958 switch (GET_CODE (x
))
2961 fputs ("eq", file
); /* 4 */
2964 fputs ("ne", file
); /* 24 */
2967 fputs ("lt", file
); /* 16 */
2970 fputs ("le", file
); /* 20 */
2973 fputs ("gt", file
); /* 8 */
2976 fputs ("ge", file
); /* 12 */
2979 fputs ("llt", file
); /* 2 */
2982 fputs ("lle", file
); /* 6 */
2985 fputs ("lgt", file
); /* 1 */
2988 fputs ("lge", file
); /* 5 */
2996 /* If constant, low-order 16 bits of constant, signed. Otherwise, write
2999 fprintf (file
, "%d", ((INT_LOWPART (x
) & 0xffff) ^ 0x8000) - 0x8000);
3001 print_operand (file
, x
, 0);
3005 /* If constant, low-order 16 bits of constant, unsigned.
3006 Otherwise, write normally. */
3008 fprintf (file
, "%d", INT_LOWPART (x
) & 0xffff);
3010 print_operand (file
, x
, 0);
3014 if (GET_CODE (x
) == MEM
3015 && LEGITIMATE_INDEXED_ADDRESS_P (XEXP (x
, 0)))
3020 /* Like 'L', for third word of TImode */
3021 if (GET_CODE (x
) == REG
)
3022 fprintf (file
, "%s", reg_names
[REGNO (x
) + 2]);
3023 else if (GET_CODE (x
) == MEM
)
3025 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
3026 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3027 output_address (plus_constant (XEXP (XEXP (x
, 0), 0), 8));
3029 output_address (plus_constant (XEXP (x
, 0), 8));
3030 if (small_data_operand (x
, GET_MODE (x
)))
3031 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3032 reg_names
[SMALL_DATA_REG
]);
3037 /* X is a SYMBOL_REF. Write out the name preceded by a
3038 period and without any trailing data in brackets. Used for function
3039 names. If we are configured for System V (or the embedded ABI) on
3040 the PowerPC, do not emit the period, since those systems do not use
3041 TOCs and the like. */
3042 if (GET_CODE (x
) != SYMBOL_REF
)
3045 if (XSTR (x
, 0)[0] != '.')
3047 switch (DEFAULT_ABI
)
3057 case ABI_AIX_NODESC
:
3066 RS6000_OUTPUT_BASENAME (file
, XSTR (x
, 0));
3070 /* Like 'L', for last word of TImode. */
3071 if (GET_CODE (x
) == REG
)
3072 fprintf (file
, "%s", reg_names
[REGNO (x
) + 3]);
3073 else if (GET_CODE (x
) == MEM
)
3075 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
3076 || GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3077 output_address (plus_constant (XEXP (XEXP (x
, 0), 0), 12));
3079 output_address (plus_constant (XEXP (x
, 0), 12));
3080 if (small_data_operand (x
, GET_MODE (x
)))
3081 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3082 reg_names
[SMALL_DATA_REG
]);
3087 if (GET_CODE (x
) == REG
)
3088 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
3089 else if (GET_CODE (x
) == MEM
)
3091 /* We need to handle PRE_INC and PRE_DEC here, since we need to
3092 know the width from the mode. */
3093 if (GET_CODE (XEXP (x
, 0)) == PRE_INC
)
3094 fprintf (file
, "%d(%d)", GET_MODE_SIZE (GET_MODE (x
)),
3095 REGNO (XEXP (XEXP (x
, 0), 0)));
3096 else if (GET_CODE (XEXP (x
, 0)) == PRE_DEC
)
3097 fprintf (file
, "%d(%d)", - GET_MODE_SIZE (GET_MODE (x
)),
3098 REGNO (XEXP (XEXP (x
, 0), 0)));
3100 output_address (XEXP (x
, 0));
3103 output_addr_const (file
, x
);
3107 output_operand_lossage ("invalid %%xn code");
3111 /* Print the address of an operand. */
3114 print_operand_address (file
, x
)
3118 if (GET_CODE (x
) == REG
)
3119 fprintf (file
, "0(%s)", reg_names
[ REGNO (x
) ]);
3120 else if (GET_CODE (x
) == SYMBOL_REF
|| GET_CODE (x
) == CONST
|| GET_CODE (x
) == LABEL_REF
)
3122 output_addr_const (file
, x
);
3123 if (small_data_operand (x
, GET_MODE (x
)))
3124 fprintf (file
, "@%s(%s)", SMALL_DATA_RELOC
,
3125 reg_names
[SMALL_DATA_REG
]);
3127 #ifdef TARGET_NO_TOC
3128 else if (TARGET_NO_TOC
)
3132 fprintf (file
, "(%s)", reg_names
[ TARGET_MINIMAL_TOC
? 30 : 2 /* PIC_OFFSET_TABLE_REGNUM? */ ]);
3134 else if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 1)) == REG
)
3136 if (REGNO (XEXP (x
, 0)) == 0)
3137 fprintf (file
, "%s,%s", reg_names
[ REGNO (XEXP (x
, 1)) ],
3138 reg_names
[ REGNO (XEXP (x
, 0)) ]);
3140 fprintf (file
, "%s,%s", reg_names
[ REGNO (XEXP (x
, 0)) ],
3141 reg_names
[ REGNO (XEXP (x
, 1)) ]);
3143 else if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 1)) == CONST_INT
)
3144 fprintf (file
, "%d(%s)", INTVAL (XEXP (x
, 1)), reg_names
[ REGNO (XEXP (x
, 0)) ]);
3145 else if (TARGET_ELF
&& !TARGET_64BIT
&& GET_CODE (x
) == LO_SUM
3146 && GET_CODE (XEXP (x
, 0)) == REG
&& CONSTANT_P (XEXP (x
, 1)))
3148 output_addr_const (file
, XEXP (x
, 1));
3149 fprintf (file
, "@l(%s)", reg_names
[ REGNO (XEXP (x
, 0)) ]);
3155 /* This page contains routines that are used to determine what the function
3156 prologue and epilogue code will do and write them out. */
3158 /* Return the first fixed-point register that is required to be saved. 32 if
3162 first_reg_to_save ()
3166 /* Find lowest numbered live register. */
3167 for (first_reg
= 13; first_reg
<= 31; first_reg
++)
3168 if (regs_ever_live
[first_reg
])
3173 /* AIX must save/restore every register that contains a parameter
3174 before/after the .__mcount call plus an additional register
3175 for the static chain, if needed; use registers from 30 down to 22
3177 if (DEFAULT_ABI
== ABI_AIX
)
3179 int last_parm_reg
, profile_first_reg
;
3181 /* Figure out last used parameter register. The proper thing
3182 to do is to walk incoming args of the function. A function
3183 might have live parameter registers even if it has no
3185 for (last_parm_reg
= 10;
3186 last_parm_reg
> 2 && ! regs_ever_live
[last_parm_reg
];
3190 /* Calculate first reg for saving parameter registers
3192 Skip reg 31 which may contain the frame pointer. */
3193 profile_first_reg
= (33 - last_parm_reg
3194 - (current_function_needs_context
? 1 : 0));
3195 /* Do not save frame pointer if no parameters needs to be saved. */
3196 if (profile_first_reg
== 31)
3197 profile_first_reg
= 32;
3199 if (first_reg
> profile_first_reg
)
3200 first_reg
= profile_first_reg
;
3203 /* SVR4 may need one register to preserve the static chain. */
3204 else if (current_function_needs_context
)
3206 /* Skip reg 31 which may contain the frame pointer. */
3215 /* Similar, for FP regs. */
3218 first_fp_reg_to_save ()
3222 /* Find lowest numbered live register. */
3223 for (first_reg
= 14 + 32; first_reg
<= 63; first_reg
++)
3224 if (regs_ever_live
[first_reg
])
3230 /* Return non-zero if this function makes calls. */
3233 rs6000_makes_calls ()
3237 /* If we are profiling, we will be making a call to __mcount.
3238 Under the System V ABI's, we store the LR directly, so
3239 we don't need to do it here. */
3240 if (DEFAULT_ABI
== ABI_AIX
&& profile_flag
)
3243 for (insn
= get_insns (); insn
; insn
= next_insn (insn
))
3244 if (GET_CODE (insn
) == CALL_INSN
)
3251 /* Calculate the stack information for the current function. This is
3252 complicated by having two separate calling sequences, the AIX calling
3253 sequence and the V.4 calling sequence.
3255 AIX stack frames look like:
3257 SP----> +---------------------------------------+
3258 | back chain to caller | 0 0
3259 +---------------------------------------+
3260 | saved CR | 4 8 (8-11)
3261 +---------------------------------------+
3263 +---------------------------------------+
3264 | reserved for compilers | 12 24
3265 +---------------------------------------+
3266 | reserved for binders | 16 32
3267 +---------------------------------------+
3268 | saved TOC pointer | 20 40
3269 +---------------------------------------+
3270 | Parameter save area (P) | 24 48
3271 +---------------------------------------+
3272 | Alloca space (A) | 24+P etc.
3273 +---------------------------------------+
3274 | Local variable space (L) | 24+P+A
3275 +---------------------------------------+
3276 | Float/int conversion temporary (X) | 24+P+A+L
3277 +---------------------------------------+
3278 | Save area for GP registers (G) | 24+P+A+X+L
3279 +---------------------------------------+
3280 | Save area for FP registers (F) | 24+P+A+X+L+G
3281 +---------------------------------------+
3282 old SP->| back chain to caller's caller |
3283 +---------------------------------------+
3285 The required alignment for AIX configurations is two words (i.e., 8
3289 V.4 stack frames look like:
3291 SP----> +---------------------------------------+
3292 | back chain to caller | 0
3293 +---------------------------------------+
3294 | caller's saved LR | 4
3295 +---------------------------------------+
3296 | Parameter save area (P) | 8
3297 +---------------------------------------+
3298 | Alloca space (A) | 8+P
3299 +---------------------------------------+
3300 | Varargs save area (V) | 8+P+A
3301 +---------------------------------------+
3302 | Local variable space (L) | 8+P+A+V
3303 +---------------------------------------+
3304 | Float/int conversion temporary (X) | 8+P+A+V+L
3305 +---------------------------------------+
3306 | saved CR (C) | 8+P+A+V+L+X
3307 +---------------------------------------+
3308 | Save area for GP registers (G) | 8+P+A+V+L+X+C
3309 +---------------------------------------+
3310 | Save area for FP registers (F) | 8+P+A+V+L+X+C+G
3311 +---------------------------------------+
3312 old SP->| back chain to caller's caller |
3313 +---------------------------------------+
3315 The required alignment for V.4 is 16 bytes, or 8 bytes if -meabi is
3316 given. (But note below and in sysv4.h that we require only 8 and
3317 may round up the size of our stack frame anyways. The historical
3318 reason is early versions of powerpc-linux which didn't properly
3319 align the stack at program startup. A happy side-effect is that
3320 -mno-eabi libraries can be used with -meabi programs.)
3323 A PowerPC Windows/NT frame looks like:
3325 SP----> +---------------------------------------+
3326 | back chain to caller | 0
3327 +---------------------------------------+
3329 +---------------------------------------+
3331 +---------------------------------------+
3333 +---------------------------------------+
3335 +---------------------------------------+
3337 +---------------------------------------+
3338 | Parameter save area (P) | 24
3339 +---------------------------------------+
3340 | Alloca space (A) | 24+P
3341 +---------------------------------------+
3342 | Local variable space (L) | 24+P+A
3343 +---------------------------------------+
3344 | Float/int conversion temporary (X) | 24+P+A+L
3345 +---------------------------------------+
3346 | Save area for FP registers (F) | 24+P+A+L+X
3347 +---------------------------------------+
3348 | Possible alignment area (Y) | 24+P+A+L+X+F
3349 +---------------------------------------+
3350 | Save area for GP registers (G) | 24+P+A+L+X+F+Y
3351 +---------------------------------------+
3352 | Save area for CR (C) | 24+P+A+L+X+F+Y+G
3353 +---------------------------------------+
3354 | Save area for TOC (T) | 24+P+A+L+X+F+Y+G+C
3355 +---------------------------------------+
3356 | Save area for LR (R) | 24+P+A+L+X+F+Y+G+C+T
3357 +---------------------------------------+
3358 old SP->| back chain to caller's caller |
3359 +---------------------------------------+
3361 For NT, there is no specific order to save the registers, but in
3362 order to support __builtin_return_address, the save area for the
3363 link register needs to be in a known place, so we use -4 off of the
3364 old SP. To support calls through pointers, we also allocate a
3365 fixed slot to store the TOC, -8 off the old SP.
3367 The required alignment for NT is 16 bytes.
3370 The EABI configuration defaults to the V.4 layout, unless
3371 -mcall-aix is used, in which case the AIX layout is used. However,
3372 the stack alignment requirements may differ. If -mno-eabi is not
3373 given, the required stack alignment is 8 bytes; if -mno-eabi is
3374 given, the required alignment is 16 bytes. (But see V.4 comment
3377 #ifndef ABI_STACK_BOUNDARY
3378 #define ABI_STACK_BOUNDARY STACK_BOUNDARY
3382 rs6000_stack_info ()
3384 static rs6000_stack_t info
, zero_info
;
3385 rs6000_stack_t
*info_ptr
= &info
;
3386 int reg_size
= TARGET_32BIT
? 4 : 8;
3387 enum rs6000_abi abi
;
3390 /* Zero all fields portably */
3393 /* Select which calling sequence */
3394 info_ptr
->abi
= abi
= DEFAULT_ABI
;
3396 /* Calculate which registers need to be saved & save area size */
3397 info_ptr
->first_gp_reg_save
= first_reg_to_save ();
3398 info_ptr
->gp_size
= reg_size
* (32 - info_ptr
->first_gp_reg_save
);
3400 info_ptr
->first_fp_reg_save
= first_fp_reg_to_save ();
3401 info_ptr
->fp_size
= 8 * (64 - info_ptr
->first_fp_reg_save
);
3403 /* Does this function call anything? */
3404 info_ptr
->calls_p
= rs6000_makes_calls ();
3406 /* Allocate space to save the toc. */
3407 if (abi
== ABI_NT
&& info_ptr
->calls_p
)
3409 info_ptr
->toc_save_p
= 1;
3410 info_ptr
->toc_size
= reg_size
;
3413 /* Does this machine need the float/int conversion area? */
3414 info_ptr
->fpmem_p
= regs_ever_live
[FPMEM_REGNUM
];
3416 /* If this is main and we need to call a function to set things up,
3417 save main's arguments around the call. */
3422 if (strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl
)), "main") == 0
3423 && DECL_CONTEXT (current_function_decl
) == NULL_TREE
)
3425 info_ptr
->main_p
= 1;
3428 info_ptr
->calls_p
= 1;
3430 if (DECL_ARGUMENTS (current_function_decl
))
3435 info_ptr
->main_save_p
= 1;
3436 info_ptr
->main_size
= 0;
3438 for ((i
= 0), (arg
= DECL_ARGUMENTS (current_function_decl
));
3439 arg
!= NULL_TREE
&& i
< 8;
3440 (arg
= TREE_CHAIN (arg
)), i
++)
3442 info_ptr
->main_size
+= reg_size
;
3449 /* Determine if we need to save the link register */
3450 if (regs_ever_live
[65]
3451 || (DEFAULT_ABI
== ABI_AIX
&& profile_flag
)
3452 #ifdef TARGET_RELOCATABLE
3453 || (TARGET_RELOCATABLE
&& (get_pool_size () != 0))
3455 || (info_ptr
->first_fp_reg_save
!= 64
3456 && !FP_SAVE_INLINE (info_ptr
->first_fp_reg_save
))
3457 || (abi
== ABI_V4
&& current_function_calls_alloca
)
3458 || (abi
== ABI_SOLARIS
&& current_function_calls_alloca
)
3459 || info_ptr
->calls_p
)
3461 info_ptr
->lr_save_p
= 1;
3462 regs_ever_live
[65] = 1;
3464 info_ptr
->lr_size
= reg_size
;
3467 /* Determine if we need to save the condition code registers */
3468 if (regs_ever_live
[70] || regs_ever_live
[71] || regs_ever_live
[72])
3470 info_ptr
->cr_save_p
= 1;
3471 if (abi
== ABI_V4
|| abi
== ABI_NT
|| abi
== ABI_SOLARIS
)
3472 info_ptr
->cr_size
= reg_size
;
3475 /* Determine various sizes */
3476 info_ptr
->reg_size
= reg_size
;
3477 info_ptr
->fixed_size
= RS6000_SAVE_AREA
;
3478 info_ptr
->varargs_size
= RS6000_VARARGS_AREA
;
3479 info_ptr
->vars_size
= RS6000_ALIGN (get_frame_size (), 8);
3480 info_ptr
->parm_size
= RS6000_ALIGN (current_function_outgoing_args_size
, 8);
3481 info_ptr
->fpmem_size
= (info_ptr
->fpmem_p
) ? 8 : 0;
3482 info_ptr
->save_size
= RS6000_ALIGN (info_ptr
->fp_size
3486 + info_ptr
->toc_size
3487 + info_ptr
->main_size
, 8);
3489 /* Calculate the offsets */
3497 case ABI_AIX_NODESC
:
3498 info_ptr
->fp_save_offset
= - info_ptr
->fp_size
;
3499 info_ptr
->gp_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->gp_size
;
3500 info_ptr
->main_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->main_size
;
3501 info_ptr
->cr_save_offset
= reg_size
; /* first word when 64-bit. */
3502 info_ptr
->lr_save_offset
= 2*reg_size
;
3507 info_ptr
->fp_save_offset
= - info_ptr
->fp_size
;
3508 info_ptr
->gp_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->gp_size
;
3509 info_ptr
->cr_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->cr_size
;
3510 info_ptr
->toc_save_offset
= info_ptr
->cr_save_offset
- info_ptr
->toc_size
;
3511 info_ptr
->main_save_offset
= info_ptr
->toc_save_offset
- info_ptr
->main_size
;
3512 info_ptr
->lr_save_offset
= reg_size
;
3516 info_ptr
->lr_save_offset
= -reg_size
;
3517 info_ptr
->toc_save_offset
= info_ptr
->lr_save_offset
- info_ptr
->lr_size
;
3518 info_ptr
->cr_save_offset
= info_ptr
->toc_save_offset
- info_ptr
->toc_size
;
3519 info_ptr
->gp_save_offset
= info_ptr
->cr_save_offset
- info_ptr
->cr_size
- info_ptr
->gp_size
+ reg_size
;
3520 info_ptr
->fp_save_offset
= info_ptr
->gp_save_offset
- info_ptr
->fp_size
;
3521 if (info_ptr
->fp_size
&& ((- info_ptr
->fp_save_offset
) % 8) != 0)
3522 info_ptr
->fp_save_offset
-= reg_size
;
3524 info_ptr
->main_save_offset
= info_ptr
->fp_save_offset
- info_ptr
->main_size
;
3528 /* Ensure that fpmem_offset will be aligned to an 8-byte boundary. */
3529 if (info_ptr
->fpmem_p
3530 && (info_ptr
->main_save_offset
- info_ptr
->fpmem_size
) % 8)
3531 info_ptr
->fpmem_size
+= reg_size
;
3533 total_raw_size
= (info_ptr
->vars_size
3534 + info_ptr
->parm_size
3535 + info_ptr
->fpmem_size
3536 + info_ptr
->save_size
3537 + info_ptr
->varargs_size
3538 + info_ptr
->fixed_size
);
3540 info_ptr
->total_size
= RS6000_ALIGN (total_raw_size
, ABI_STACK_BOUNDARY
/ BITS_PER_UNIT
);
3542 /* Determine if we need to allocate any stack frame:
3544 For AIX we need to push the stack if a frame pointer is needed (because
3545 the stack might be dynamically adjusted), if we are debugging, if we
3546 make calls, or if the sum of fp_save, gp_save, fpmem, and local variables
3547 are more than the space needed to save all non-volatile registers:
3548 32-bit: 18*8 + 19*4 = 220 or 64-bit: 18*8 + 18*8 = 288 (GPR13 reserved).
3550 For V.4 we don't have the stack cushion that AIX uses, but assume that
3551 the debugger can handle stackless frames. */
3553 if (info_ptr
->calls_p
)
3554 info_ptr
->push_p
= 1;
3556 else if (abi
== ABI_V4
|| abi
== ABI_NT
|| abi
== ABI_SOLARIS
)
3557 info_ptr
->push_p
= (total_raw_size
> info_ptr
->fixed_size
3558 || (abi
== ABI_NT
? info_ptr
->lr_save_p
3559 : info_ptr
->calls_p
));
3562 info_ptr
->push_p
= (frame_pointer_needed
3563 || write_symbols
!= NO_DEBUG
3564 || ((total_raw_size
- info_ptr
->fixed_size
)
3565 > (TARGET_32BIT
? 220 : 288)));
3567 if (info_ptr
->fpmem_p
)
3569 info_ptr
->fpmem_offset
= info_ptr
->main_save_offset
- info_ptr
->fpmem_size
;
3570 rs6000_fpmem_size
= info_ptr
->fpmem_size
;
3571 rs6000_fpmem_offset
= (info_ptr
->push_p
3572 ? info_ptr
->total_size
+ info_ptr
->fpmem_offset
3573 : info_ptr
->fpmem_offset
);
3576 info_ptr
->fpmem_offset
= 0;
3578 /* Zero offsets if we're not saving those registers */
3579 if (info_ptr
->fp_size
== 0)
3580 info_ptr
->fp_save_offset
= 0;
3582 if (info_ptr
->gp_size
== 0)
3583 info_ptr
->gp_save_offset
= 0;
3585 if (!info_ptr
->lr_save_p
)
3586 info_ptr
->lr_save_offset
= 0;
3588 if (!info_ptr
->cr_save_p
)
3589 info_ptr
->cr_save_offset
= 0;
3591 if (!info_ptr
->toc_save_p
)
3592 info_ptr
->toc_save_offset
= 0;
3594 if (!info_ptr
->main_save_p
)
3595 info_ptr
->main_save_offset
= 0;
3601 debug_stack_info (info
)
3602 rs6000_stack_t
*info
;
3604 const char *abi_string
;
3607 info
= rs6000_stack_info ();
3609 fprintf (stderr
, "\nStack information for function %s:\n",
3610 ((current_function_decl
&& DECL_NAME (current_function_decl
))
3611 ? IDENTIFIER_POINTER (DECL_NAME (current_function_decl
))
3616 default: abi_string
= "Unknown"; break;
3617 case ABI_NONE
: abi_string
= "NONE"; break;
3618 case ABI_AIX
: abi_string
= "AIX"; break;
3619 case ABI_AIX_NODESC
: abi_string
= "AIX"; break;
3620 case ABI_V4
: abi_string
= "V.4"; break;
3621 case ABI_SOLARIS
: abi_string
= "Solaris"; break;
3622 case ABI_NT
: abi_string
= "NT"; break;
3625 fprintf (stderr
, "\tABI = %5s\n", abi_string
);
3627 if (info
->first_gp_reg_save
!= 32)
3628 fprintf (stderr
, "\tfirst_gp_reg_save = %5d\n", info
->first_gp_reg_save
);
3630 if (info
->first_fp_reg_save
!= 64)
3631 fprintf (stderr
, "\tfirst_fp_reg_save = %5d\n", info
->first_fp_reg_save
);
3633 if (info
->lr_save_p
)
3634 fprintf (stderr
, "\tlr_save_p = %5d\n", info
->lr_save_p
);
3636 if (info
->cr_save_p
)
3637 fprintf (stderr
, "\tcr_save_p = %5d\n", info
->cr_save_p
);
3639 if (info
->toc_save_p
)
3640 fprintf (stderr
, "\ttoc_save_p = %5d\n", info
->toc_save_p
);
3643 fprintf (stderr
, "\tpush_p = %5d\n", info
->push_p
);
3646 fprintf (stderr
, "\tcalls_p = %5d\n", info
->calls_p
);
3649 fprintf (stderr
, "\tmain_p = %5d\n", info
->main_p
);
3651 if (info
->main_save_p
)
3652 fprintf (stderr
, "\tmain_save_p = %5d\n", info
->main_save_p
);
3655 fprintf (stderr
, "\tfpmem_p = %5d\n", info
->fpmem_p
);
3657 if (info
->gp_save_offset
)
3658 fprintf (stderr
, "\tgp_save_offset = %5d\n", info
->gp_save_offset
);
3660 if (info
->fp_save_offset
)
3661 fprintf (stderr
, "\tfp_save_offset = %5d\n", info
->fp_save_offset
);
3663 if (info
->lr_save_offset
)
3664 fprintf (stderr
, "\tlr_save_offset = %5d\n", info
->lr_save_offset
);
3666 if (info
->cr_save_offset
)
3667 fprintf (stderr
, "\tcr_save_offset = %5d\n", info
->cr_save_offset
);
3669 if (info
->toc_save_offset
)
3670 fprintf (stderr
, "\ttoc_save_offset = %5d\n", info
->toc_save_offset
);
3672 if (info
->varargs_save_offset
)
3673 fprintf (stderr
, "\tvarargs_save_offset = %5d\n", info
->varargs_save_offset
);
3675 if (info
->main_save_offset
)
3676 fprintf (stderr
, "\tmain_save_offset = %5d\n", info
->main_save_offset
);
3678 if (info
->fpmem_offset
)
3679 fprintf (stderr
, "\tfpmem_offset = %5d\n", info
->fpmem_offset
);
3681 if (info
->total_size
)
3682 fprintf (stderr
, "\ttotal_size = %5d\n", info
->total_size
);
3684 if (info
->varargs_size
)
3685 fprintf (stderr
, "\tvarargs_size = %5d\n", info
->varargs_size
);
3687 if (info
->vars_size
)
3688 fprintf (stderr
, "\tvars_size = %5d\n", info
->vars_size
);
3690 if (info
->parm_size
)
3691 fprintf (stderr
, "\tparm_size = %5d\n", info
->parm_size
);
3693 if (info
->fpmem_size
)
3694 fprintf (stderr
, "\tfpmem_size = %5d\n", info
->fpmem_size
);
3696 if (info
->fixed_size
)
3697 fprintf (stderr
, "\tfixed_size = %5d\n", info
->fixed_size
);
3700 fprintf (stderr
, "\tgp_size = %5d\n", info
->gp_size
);
3703 fprintf (stderr
, "\tfp_size = %5d\n", info
->fp_size
);
3706 fprintf (stderr
, "\tlr_size = %5d\n", info
->cr_size
);
3709 fprintf (stderr
, "\tcr_size = %5d\n", info
->cr_size
);
3712 fprintf (stderr
, "\ttoc_size = %5d\n", info
->toc_size
);
3714 if (info
->main_size
)
3715 fprintf (stderr
, "\tmain_size = %5d\n", info
->main_size
);
3717 if (info
->save_size
)
3718 fprintf (stderr
, "\tsave_size = %5d\n", info
->save_size
);
3720 if (info
->reg_size
!= 4)
3721 fprintf (stderr
, "\treg_size = %5d\n", info
->reg_size
);
3723 fprintf (stderr
, "\n");
3726 /* Write out an instruction to load the TOC_TABLE address into register 30.
3727 This is only needed when TARGET_TOC, TARGET_MINIMAL_TOC, and there is
3731 rs6000_output_load_toc_table (file
, reg
)
3738 if (TARGET_RELOCATABLE
)
3740 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3741 fprintf (file
, "\tbl ");
3742 assemble_name (file
, buf
);
3743 fprintf (file
, "\n");
3745 /* possibly create the toc section */
3746 if (!toc_initialized
)
3749 function_section (current_function_decl
);
3752 /* If not first call in this function, we need to put the
3753 different between .LCTOC1 and the address we get to right
3754 after the bl. It will mess up disassembling the instructions
3755 but that can't be helped. We will later need to bias the
3756 address before loading. */
3757 if (rs6000_pic_func_labelno
!= rs6000_pic_labelno
)
3759 const char *init_ptr
= TARGET_32BIT
? ".long" : ".quad";
3762 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCL", rs6000_pic_labelno
);
3764 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 1);
3765 STRIP_NAME_ENCODING (buf_ptr
, buf
);
3766 fprintf (file
, "\t%s %s-", init_ptr
, buf_ptr
);
3768 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3769 fprintf (file
, "%s\n", buf_ptr
);
3772 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCF", rs6000_pic_labelno
);
3773 fprintf (file
, "\tmflr %s\n", reg_names
[reg
]);
3775 if (rs6000_pic_func_labelno
!= rs6000_pic_labelno
)
3776 asm_fprintf(file
, "\t{cal|la} %s,%d(%s)\n", reg_names
[reg
],
3777 (TARGET_32BIT
? 4 : 8), reg_names
[reg
]);
3779 asm_fprintf (file
, (TARGET_32BIT
) ? "\t{l|lwz} %s,(" : "\tld %s,(",
3781 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCL", rs6000_pic_labelno
);
3782 assemble_name (file
, buf
);
3784 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCF", rs6000_pic_labelno
);
3785 assemble_name (file
, buf
);
3786 fprintf (file
, ")(%s)\n", reg_names
[reg
]);
3787 asm_fprintf (file
, "\t{cax|add} %s,%s,%s\n",
3788 reg_names
[reg
], reg_names
[0], reg_names
[reg
]);
3789 rs6000_pic_labelno
++;
3791 else if (! TARGET_64BIT
)
3793 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 1);
3794 asm_fprintf (file
, "\t{liu|lis} %s,", reg_names
[reg
]);
3795 assemble_name (file
, buf
);
3796 fputs ("@ha\n", file
);
3797 asm_fprintf (file
, "\t{cal|la} %s,", reg_names
[reg
]);
3798 assemble_name (file
, buf
);
3799 asm_fprintf (file
, "@l(%s)\n", reg_names
[reg
]);
3804 #else /* !USING_SVR4_H */
3805 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCTOC", 0);
3806 asm_fprintf (file
, TARGET_32BIT
? "\t{l|lwz} %s," : "\tld %s,",
3808 assemble_name (file
, buf
);
3809 asm_fprintf (file
, "(%s)\n", reg_names
[2]);
3810 #endif /* USING_SVR4_H */
3814 /* Emit the correct code for allocating stack space. If COPY_R12, make sure a copy
3815 of the old frame is left in r12. */
3818 rs6000_allocate_stack_space (file
, size
, copy_r12
)
3823 int neg_size
= -size
;
3828 (TARGET_32BIT
) ? "\t{stu|stwu} %s,%d(%s)\n" : "\tstdu %s,%d(%s)\n",
3829 reg_names
[1], neg_size
, reg_names
[1]);
3833 fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
3835 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
3836 reg_names
[0], (neg_size
>> 16) & 0xffff,
3837 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
3839 (TARGET_32BIT
) ? "\t{stux|stwux} %s,%s,%s\n" : "\tstdux %s,%s,%s\n",
3840 reg_names
[1], reg_names
[1], reg_names
[0]);
3845 fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
3847 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
3848 reg_names
[1], neg_size
, reg_names
[1]);
3851 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
3852 reg_names
[0], (neg_size
>> 16) & 0xffff,
3853 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
3854 asm_fprintf (file
, "\t{cax|add} %s,%s,%s\n", reg_names
[1],
3855 reg_names
[0], reg_names
[1]);
3859 (TARGET_32BIT
) ? "\t{st|stw} %s,0(%s)\n" : "\tstd %s,0(%s)\n",
3860 reg_names
[12], reg_names
[1]);
3865 /* Write function prologue. */
3867 output_prolog (file
, size
)
3869 int size ATTRIBUTE_UNUSED
;
3871 rs6000_stack_t
*info
= rs6000_stack_info ();
3872 int reg_size
= info
->reg_size
;
3873 const char *store_reg
;
3874 const char *load_reg
;
3880 store_reg
= "\t{st|stw} %s,%d(%s)\n";
3881 load_reg
= "\t{l|lwz} %s,%d(%s)\n";
3885 store_reg
= "\tstd %s,%d(%s)\n";
3886 load_reg
= "\tlld %s,%d(%s)\n";
3889 if (TARGET_DEBUG_STACK
)
3890 debug_stack_info (info
);
3892 /* Write .extern for any function we will call to save and restore fp
3894 if (info
->first_fp_reg_save
< 64 && !FP_SAVE_INLINE (info
->first_fp_reg_save
))
3895 fprintf (file
, "\t.extern %s%d%s\n\t.extern %s%d%s\n",
3896 SAVE_FP_PREFIX
, info
->first_fp_reg_save
- 32, SAVE_FP_SUFFIX
,
3897 RESTORE_FP_PREFIX
, info
->first_fp_reg_save
- 32, RESTORE_FP_SUFFIX
);
3899 /* Write .extern for truncation routines, if needed. */
3900 if (rs6000_trunc_used
&& ! trunc_defined
)
3902 fprintf (file
, "\t.extern .%s\n\t.extern .%s\n",
3903 RS6000_ITRUNC
, RS6000_UITRUNC
);
3907 /* Write .extern for AIX common mode routines, if needed. */
3908 if (! TARGET_POWER
&& ! TARGET_POWERPC
&& ! common_mode_defined
)
3910 fputs ("\t.extern __mulh\n", file
);
3911 fputs ("\t.extern __mull\n", file
);
3912 fputs ("\t.extern __divss\n", file
);
3913 fputs ("\t.extern __divus\n", file
);
3914 fputs ("\t.extern __quoss\n", file
);
3915 fputs ("\t.extern __quous\n", file
);
3916 common_mode_defined
= 1;
3919 /* For V.4, update stack before we do any saving and set back pointer. */
3920 if (info
->push_p
&& (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
))
3922 if (info
->total_size
< 32767)
3923 sp_offset
= info
->total_size
;
3926 rs6000_allocate_stack_space (file
, info
->total_size
, sp_reg
== 12);
3929 /* If we use the link register, get it into r0. */
3930 if (info
->lr_save_p
)
3931 asm_fprintf (file
, "\tmflr %s\n", reg_names
[0]);
3933 /* If we need to save CR, put it into r12. */
3934 if (info
->cr_save_p
&& sp_reg
!= 12)
3935 asm_fprintf (file
, "\tmfcr %s\n", reg_names
[12]);
3937 /* Do any required saving of fpr's. If only one or two to save, do it
3938 ourself. Otherwise, call function. Note that since they are statically
3939 linked, we do not need a nop following them. */
3940 if (FP_SAVE_INLINE (info
->first_fp_reg_save
))
3942 int regno
= info
->first_fp_reg_save
;
3943 int loc
= info
->fp_save_offset
+ sp_offset
;
3945 for ( ; regno
< 64; regno
++, loc
+= 8)
3946 asm_fprintf (file
, "\tstfd %s,%d(%s)\n", reg_names
[regno
], loc
, reg_names
[sp_reg
]);
3948 else if (info
->first_fp_reg_save
!= 64)
3949 asm_fprintf (file
, "\tbl %s%d%s\n", SAVE_FP_PREFIX
,
3950 info
->first_fp_reg_save
- 32, SAVE_FP_SUFFIX
);
3952 /* Now save gpr's. */
3953 if (! TARGET_MULTIPLE
|| info
->first_gp_reg_save
== 31 || TARGET_64BIT
)
3955 int regno
= info
->first_gp_reg_save
;
3956 int loc
= info
->gp_save_offset
+ sp_offset
;
3958 for ( ; regno
< 32; regno
++, loc
+= reg_size
)
3959 asm_fprintf (file
, store_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
3962 else if (info
->first_gp_reg_save
!= 32)
3963 asm_fprintf (file
, "\t{stm|stmw} %s,%d(%s)\n",
3964 reg_names
[info
->first_gp_reg_save
],
3965 info
->gp_save_offset
+ sp_offset
,
3968 /* Save main's arguments if we need to call a function */
3970 if (info
->main_save_p
)
3973 int loc
= info
->main_save_offset
+ sp_offset
;
3974 int size
= info
->main_size
;
3976 for (regno
= 3; size
> 0; regno
++, loc
+= reg_size
, size
-= reg_size
)
3977 asm_fprintf (file
, store_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
3981 /* Save lr if we used it. */
3982 if (info
->lr_save_p
)
3983 asm_fprintf (file
, store_reg
, reg_names
[0], info
->lr_save_offset
+ sp_offset
,
3986 /* Save CR if we use any that must be preserved. */
3987 if (info
->cr_save_p
)
3989 if (sp_reg
== 12) /* If r12 is used to hold the original sp, copy cr now */
3991 asm_fprintf (file
, "\tmfcr %s\n", reg_names
[0]);
3992 asm_fprintf (file
, store_reg
, reg_names
[0],
3993 info
->cr_save_offset
+ sp_offset
,
3997 asm_fprintf (file
, store_reg
, reg_names
[12], info
->cr_save_offset
+ sp_offset
,
4001 /* If we need PIC_OFFSET_TABLE_REGNUM, initialize it now */
4002 if ((DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
4003 && flag_pic
== 1 && regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
])
4005 if (!info
->lr_save_p
)
4006 asm_fprintf (file
, "\tmflr %s\n", reg_names
[0]);
4008 fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file
);
4009 asm_fprintf (file
, "\tmflr %s\n", reg_names
[PIC_OFFSET_TABLE_REGNUM
]);
4011 if (!info
->lr_save_p
)
4012 asm_fprintf (file
, "\tmtlr %s\n", reg_names
[0]);
4015 /* NT needs us to probe the stack frame every 4k pages for large frames, so
4017 if (DEFAULT_ABI
== ABI_NT
&& info
->total_size
> 4096)
4019 if (info
->total_size
< 32768)
4021 int probe_offset
= 4096;
4022 while (probe_offset
< info
->total_size
)
4024 asm_fprintf (file
, "\t{l|lwz} %s,%d(%s)\n", reg_names
[0], -probe_offset
, reg_names
[1]);
4025 probe_offset
+= 4096;
4030 int probe_iterations
= info
->total_size
/ 4096;
4031 static int probe_labelno
= 0;
4034 if (probe_iterations
< 32768)
4035 asm_fprintf (file
, "\tli %s,%d\n", reg_names
[12], probe_iterations
);
4038 asm_fprintf (file
, "\tlis %s,%d\n", reg_names
[12], probe_iterations
>> 16);
4039 if (probe_iterations
& 0xffff)
4040 asm_fprintf (file
, "\tori %s,%s,%d\n", reg_names
[12], reg_names
[12],
4041 probe_iterations
& 0xffff);
4043 asm_fprintf (file
, "\tmtctr %s\n", reg_names
[12]);
4044 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[12], reg_names
[1]);
4045 ASM_OUTPUT_INTERNAL_LABEL (file
, "LCprobe", probe_labelno
);
4046 asm_fprintf (file
, "\t{lu|lwzu} %s,-4096(%s)\n", reg_names
[0], reg_names
[12]);
4047 ASM_GENERATE_INTERNAL_LABEL (buf
, "LCprobe", probe_labelno
++);
4048 fputs ("\tbdnz ", file
);
4049 assemble_name (file
, buf
);
4054 /* Update stack and set back pointer unless this is V.4, which was done previously */
4055 if (info
->push_p
&& DEFAULT_ABI
!= ABI_V4
&& DEFAULT_ABI
!= ABI_SOLARIS
)
4056 rs6000_allocate_stack_space (file
, info
->total_size
, FALSE
);
4058 /* Set frame pointer, if needed. */
4059 if (frame_pointer_needed
)
4060 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[31], reg_names
[1]);
4063 /* If we need to call a function to set things up for main, do so now
4064 before dealing with the TOC. */
4067 const char *prefix
= "";
4069 switch (DEFAULT_ABI
)
4071 case ABI_AIX
: prefix
= "."; break;
4072 case ABI_NT
: prefix
= ".."; break;
4075 fprintf (file
, "\tbl %s%s\n", prefix
, NAME__MAIN
);
4076 #ifdef RS6000_CALL_GLUE2
4077 fprintf (file
, "\t%s%s%s\n", RS6000_CALL_GLUE2
, prefix
, NAME_MAIN
);
4079 #ifdef RS6000_CALL_GLUE
4080 if (DEFAULT_ABI
== ABI_AIX
|| DEFAULT_ABI
== ABI_NT
)
4083 asm_fprintf (file
, RS6000_CALL_GLUE
);
4089 if (info
->main_save_p
)
4093 int size
= info
->main_size
;
4095 if (info
->total_size
< 32767)
4097 loc
= info
->total_size
+ info
->main_save_offset
;
4098 for (regno
= 3; size
> 0; regno
++, size
-= reg_size
, loc
+= reg_size
)
4099 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[1]);
4103 int neg_size
= info
->main_save_offset
- info
->total_size
;
4105 asm_fprintf (file
, "\t{liu|lis} %s,0x%x\n\t{oril|ori} %s,%s,%d\n",
4106 reg_names
[0], (neg_size
>> 16) & 0xffff,
4107 reg_names
[0], reg_names
[0], neg_size
& 0xffff);
4109 asm_fprintf (file
, "\t{sf|subf} %s,%s,%s\n", reg_names
[0], reg_names
[0],
4112 for (regno
= 3; size
> 0; regno
++, size
-= reg_size
, loc
+= reg_size
)
4113 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[0]);
4120 /* If TARGET_MINIMAL_TOC, and the constant pool is needed, then load the
4121 TOC_TABLE address into register 30. */
4122 if (TARGET_TOC
&& TARGET_MINIMAL_TOC
&& get_pool_size () != 0)
4126 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
4128 rs6000_output_load_toc_table (file
, 30);
4131 if (DEFAULT_ABI
== ABI_NT
)
4133 assemble_name (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4134 fputs (".b:\n", file
);
4138 /* Write function epilogue. */
4141 output_epilog (file
, size
)
4143 int size ATTRIBUTE_UNUSED
;
4145 rs6000_stack_t
*info
= rs6000_stack_info ();
4146 const char *load_reg
= (TARGET_32BIT
) ? "\t{l|lwz} %s,%d(%s)\n" : "\tld %s,%d(%s)\n";
4147 rtx insn
= get_last_insn ();
4151 /* If the last insn was a BARRIER, we don't have to write anything except
4153 if (GET_CODE (insn
) == NOTE
)
4154 insn
= prev_nonnote_insn (insn
);
4155 if (insn
== 0 || GET_CODE (insn
) != BARRIER
)
4157 /* If we have a frame pointer, a call to alloca, or a large stack
4158 frame, restore the old stack pointer using the backchain. Otherwise,
4159 we know what size to update it with. */
4160 if (frame_pointer_needed
|| current_function_calls_alloca
4161 || info
->total_size
> 32767)
4163 /* Under V.4, don't reset the stack pointer until after we're done
4164 loading the saved registers. */
4165 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
4168 asm_fprintf (file
, load_reg
, reg_names
[sp_reg
], 0, reg_names
[1]);
4170 else if (info
->push_p
)
4172 if (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
4173 sp_offset
= info
->total_size
;
4175 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
4176 reg_names
[1], info
->total_size
, reg_names
[1]);
4179 /* Get the old lr if we saved it. */
4180 if (info
->lr_save_p
)
4181 asm_fprintf (file
, load_reg
, reg_names
[0], info
->lr_save_offset
+ sp_offset
, reg_names
[sp_reg
]);
4183 /* Get the old cr if we saved it. */
4184 if (info
->cr_save_p
)
4185 asm_fprintf (file
, load_reg
, reg_names
[12], info
->cr_save_offset
+ sp_offset
, reg_names
[sp_reg
]);
4187 /* Set LR here to try to overlap restores below. */
4188 if (info
->lr_save_p
)
4189 asm_fprintf (file
, "\tmtlr %s\n", reg_names
[0]);
4191 /* Restore gpr's. */
4192 if (! TARGET_MULTIPLE
|| info
->first_gp_reg_save
== 31 || TARGET_64BIT
)
4194 int regno
= info
->first_gp_reg_save
;
4195 int loc
= info
->gp_save_offset
+ sp_offset
;
4196 int reg_size
= (TARGET_32BIT
) ? 4 : 8;
4198 for ( ; regno
< 32; regno
++, loc
+= reg_size
)
4199 asm_fprintf (file
, load_reg
, reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4202 else if (info
->first_gp_reg_save
!= 32)
4203 asm_fprintf (file
, "\t{lm|lmw} %s,%d(%s)\n",
4204 reg_names
[info
->first_gp_reg_save
],
4205 info
->gp_save_offset
+ sp_offset
,
4208 /* Restore fpr's if we can do it without calling a function. */
4209 if (FP_SAVE_INLINE (info
->first_fp_reg_save
))
4211 int regno
= info
->first_fp_reg_save
;
4212 int loc
= info
->fp_save_offset
+ sp_offset
;
4214 for ( ; regno
< 64; regno
++, loc
+= 8)
4215 asm_fprintf (file
, "\tlfd %s,%d(%s)\n", reg_names
[regno
], loc
, reg_names
[sp_reg
]);
4218 /* If we saved cr, restore it here. Just those of cr2, cr3, and cr4
4220 if (info
->cr_save_p
)
4221 asm_fprintf (file
, "\tmtcrf %d,%s\n",
4222 (regs_ever_live
[70] != 0) * 0x20
4223 + (regs_ever_live
[71] != 0) * 0x10
4224 + (regs_ever_live
[72] != 0) * 0x8, reg_names
[12]);
4226 /* If this is V.4, unwind the stack pointer after all of the loads
4229 asm_fprintf (file
, "\t{cal|la} %s,%d(%s)\n",
4230 reg_names
[1], sp_offset
, reg_names
[1]);
4231 else if (sp_reg
!= 1)
4232 asm_fprintf (file
, "\tmr %s,%s\n", reg_names
[1], reg_names
[sp_reg
]);
4234 /* If we have to restore more than two FP registers, branch to the
4235 restore function. It will return to our caller. */
4236 if (info
->first_fp_reg_save
!= 64 && !FP_SAVE_INLINE (info
->first_fp_reg_save
))
4237 asm_fprintf (file
, "\tb %s%d%s\n", RESTORE_FP_PREFIX
,
4238 info
->first_fp_reg_save
- 32, RESTORE_FP_SUFFIX
);
4240 asm_fprintf (file
, "\t{br|blr}\n");
4243 /* Output a traceback table here. See /usr/include/sys/debug.h for info
4246 We don't output a traceback table if -finhibit-size-directive was
4247 used. The documentation for -finhibit-size-directive reads
4248 ``don't output a @code{.size} assembler directive, or anything
4249 else that would cause trouble if the function is split in the
4250 middle, and the two halves are placed at locations far apart in
4251 memory.'' The traceback table has this property, since it
4252 includes the offset from the start of the function to the
4253 traceback table itself.
4255 System V.4 Powerpc's (and the embedded ABI derived from it) use a
4256 different traceback table. */
4257 if (DEFAULT_ABI
== ABI_AIX
&& ! flag_inhibit_size_directive
)
4259 char *fname
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
4260 int fixed_parms
, float_parms
, parm_info
;
4263 while (*fname
== '.') /* V.4 encodes . in the name */
4266 /* Need label immediately before tbtab, so we can compute its offset
4267 from the function start. */
4270 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LT");
4271 ASM_OUTPUT_LABEL (file
, fname
);
4273 /* The .tbtab pseudo-op can only be used for the first eight
4274 expressions, since it can't handle the possibly variable
4275 length fields that follow. However, if you omit the optional
4276 fields, the assembler outputs zeros for all optional fields
4277 anyways, giving each variable length field is minimum length
4278 (as defined in sys/debug.h). Thus we can not use the .tbtab
4279 pseudo-op at all. */
4281 /* An all-zero word flags the start of the tbtab, for debuggers
4282 that have to find it by searching forward from the entry
4283 point or from the current pc. */
4284 fputs ("\t.long 0\n", file
);
4286 /* Tbtab format type. Use format type 0. */
4287 fputs ("\t.byte 0,", file
);
4289 /* Language type. Unfortunately, there doesn't seem to be any
4290 official way to get this info, so we use language_string. C
4291 is 0. C++ is 9. No number defined for Obj-C, so use the
4292 value for C for now. There is no official value for Java,
4293 although IBM appears to be using 13. There is no official value
4294 for Chill, so we've choosen 44 pseudo-randomly. */
4295 if (! strcmp (language_string
, "GNU C")
4296 || ! strcmp (language_string
, "GNU Obj-C"))
4298 else if (! strcmp (language_string
, "GNU F77"))
4300 else if (! strcmp (language_string
, "GNU Ada"))
4302 else if (! strcmp (language_string
, "GNU Pascal"))
4304 else if (! strcmp (language_string
, "GNU C++"))
4306 else if (! strcmp (language_string
, "GNU Java"))
4308 else if (! strcmp (language_string
, "GNU CHILL"))
4312 fprintf (file
, "%d,", i
);
4314 /* 8 single bit fields: global linkage (not set for C extern linkage,
4315 apparently a PL/I convention?), out-of-line epilogue/prologue, offset
4316 from start of procedure stored in tbtab, internal function, function
4317 has controlled storage, function has no toc, function uses fp,
4318 function logs/aborts fp operations. */
4319 /* Assume that fp operations are used if any fp reg must be saved. */
4320 fprintf (file
, "%d,", (1 << 5) | ((info
->first_fp_reg_save
!= 64) << 1));
4322 /* 6 bitfields: function is interrupt handler, name present in
4323 proc table, function calls alloca, on condition directives
4324 (controls stack walks, 3 bits), saves condition reg, saves
4326 /* The `function calls alloca' bit seems to be set whenever reg 31 is
4327 set up as a frame pointer, even when there is no alloca call. */
4328 fprintf (file
, "%d,",
4329 ((1 << 6) | (frame_pointer_needed
<< 5)
4330 | (info
->cr_save_p
<< 1) | (info
->lr_save_p
)));
4332 /* 3 bitfields: saves backchain, spare bit, number of fpr saved
4334 fprintf (file
, "%d,",
4335 (info
->push_p
<< 7) | (64 - info
->first_fp_reg_save
));
4337 /* 2 bitfields: spare bits (2 bits), number of gpr saved (6 bits). */
4338 fprintf (file
, "%d,", (32 - first_reg_to_save ()));
4341 /* Compute the parameter info from the function decl argument
4344 int next_parm_info_bit
;
4346 next_parm_info_bit
= 31;
4351 for (decl
= DECL_ARGUMENTS (current_function_decl
);
4352 decl
; decl
= TREE_CHAIN (decl
))
4354 rtx parameter
= DECL_INCOMING_RTL (decl
);
4355 enum machine_mode mode
= GET_MODE (parameter
);
4357 if (GET_CODE (parameter
) == REG
)
4359 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
4367 else if (mode
== DFmode
)
4372 /* If only one bit will fit, don't or in this entry. */
4373 if (next_parm_info_bit
> 0)
4374 parm_info
|= (bits
<< (next_parm_info_bit
- 1));
4375 next_parm_info_bit
-= 2;
4379 fixed_parms
+= ((GET_MODE_SIZE (mode
)
4380 + (UNITS_PER_WORD
- 1))
4382 next_parm_info_bit
-= 1;
4388 /* Number of fixed point parameters. */
4389 /* This is actually the number of words of fixed point parameters; thus
4390 an 8 byte struct counts as 2; and thus the maximum value is 8. */
4391 fprintf (file
, "%d,", fixed_parms
);
4393 /* 2 bitfields: number of floating point parameters (7 bits), parameters
4395 /* This is actually the number of fp registers that hold parameters;
4396 and thus the maximum value is 13. */
4397 /* Set parameters on stack bit if parameters are not in their original
4398 registers, regardless of whether they are on the stack? Xlc
4399 seems to set the bit when not optimizing. */
4400 fprintf (file
, "%d\n", ((float_parms
<< 1) | (! optimize
)));
4402 /* Optional fields follow. Some are variable length. */
4404 /* Parameter types, left adjusted bit fields: 0 fixed, 10 single float,
4406 /* There is an entry for each parameter in a register, in the order that
4407 they occur in the parameter list. Any intervening arguments on the
4408 stack are ignored. If the list overflows a long (max possible length
4409 34 bits) then completely leave off all elements that don't fit. */
4410 /* Only emit this long if there was at least one parameter. */
4411 if (fixed_parms
|| float_parms
)
4412 fprintf (file
, "\t.long %d\n", parm_info
);
4414 /* Offset from start of code to tb table. */
4415 fputs ("\t.long ", file
);
4416 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LT");
4417 RS6000_OUTPUT_BASENAME (file
, fname
);
4419 RS6000_OUTPUT_BASENAME (file
, fname
);
4422 /* Interrupt handler mask. */
4423 /* Omit this long, since we never set the interrupt handler bit
4426 /* Number of CTL (controlled storage) anchors. */
4427 /* Omit this long, since the has_ctl bit is never set above. */
4429 /* Displacement into stack of each CTL anchor. */
4430 /* Omit this list of longs, because there are no CTL anchors. */
4432 /* Length of function name. */
4433 fprintf (file
, "\t.short %d\n", (int) strlen (fname
));
4435 /* Function name. */
4436 assemble_string (fname
, strlen (fname
));
4438 /* Register for alloca automatic storage; this is always reg 31.
4439 Only emit this if the alloca bit was set above. */
4440 if (frame_pointer_needed
)
4441 fputs ("\t.byte 31\n", file
);
4444 if (DEFAULT_ABI
== ABI_NT
)
4446 RS6000_OUTPUT_BASENAME (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4447 fputs (".e:\nFE_MOT_RESVD..", file
);
4448 RS6000_OUTPUT_BASENAME (file
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
4449 fputs (":\n", file
);
4453 /* A C compound statement that outputs the assembler code for a thunk function,
4454 used to implement C++ virtual function calls with multiple inheritance. The
4455 thunk acts as a wrapper around a virtual function, adjusting the implicit
4456 object parameter before handing control off to the real function.
4458 First, emit code to add the integer DELTA to the location that contains the
4459 incoming first argument. Assume that this argument contains a pointer, and
4460 is the one used to pass the `this' pointer in C++. This is the incoming
4461 argument *before* the function prologue, e.g. `%o0' on a sparc. The
4462 addition must preserve the values of all other incoming arguments.
4464 After the addition, emit code to jump to FUNCTION, which is a
4465 `FUNCTION_DECL'. This is a direct pure jump, not a call, and does not touch
4466 the return address. Hence returning from FUNCTION will return to whoever
4467 called the current `thunk'.
4469 The effect must be as if FUNCTION had been called directly with the adjusted
4470 first argument. This macro is responsible for emitting all of the code for
4471 a thunk function; `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE' are not
4474 The THUNK_FNDECL is redundant. (DELTA and FUNCTION have already been
4475 extracted from it.) It might possibly be useful on some targets, but
4478 If you do not define this macro, the target-independent code in the C++
4479 frontend will generate a less efficient heavyweight thunk that calls
4480 FUNCTION instead of jumping to it. The generic approach does not support
4484 output_mi_thunk (file
, thunk_fndecl
, delta
, function
)
4486 tree thunk_fndecl ATTRIBUTE_UNUSED
;
4490 const char *this_reg
= reg_names
[ aggregate_value_p (TREE_TYPE (TREE_TYPE (function
))) ? 4 : 3 ];
4493 const char *r0
= reg_names
[0];
4494 const char *sp
= reg_names
[1];
4495 const char *toc
= reg_names
[2];
4496 const char *schain
= reg_names
[11];
4497 const char *r12
= reg_names
[12];
4499 static int labelno
= 0;
4501 /* Small constants that can be done by one add instruction */
4502 if (delta
>= -32768 && delta
<= 32767)
4504 if (! TARGET_NEW_MNEMONICS
)
4505 fprintf (file
, "\tcal %s,%d(%s)\n", this_reg
, delta
, this_reg
);
4507 fprintf (file
, "\taddi %s,%s,%d\n", this_reg
, this_reg
, delta
);
4510 /* Large constants that can be done by one addis instruction */
4511 else if ((delta
& 0xffff) == 0 && num_insns_constant_wide (delta
) == 1)
4512 asm_fprintf (file
, "\t{cau|addis} %s,%s,%d\n", this_reg
, this_reg
,
4515 /* 32-bit constants that can be done by an add and addis instruction. */
4516 else if (TARGET_32BIT
|| num_insns_constant_wide (delta
) == 1)
4518 /* Break into two pieces, propagating the sign bit from the low word to
4520 int delta_high
= delta
>> 16;
4521 int delta_low
= delta
& 0xffff;
4522 if ((delta_low
& 0x8000) != 0)
4525 delta_low
= (delta_low
^ 0x8000) - 0x8000; /* sign extend */
4528 asm_fprintf (file
, "\t{cau|addis} %s,%s,%d\n", this_reg
, this_reg
,
4531 if (! TARGET_NEW_MNEMONICS
)
4532 fprintf (file
, "\tcal %s,%d(%s)\n", this_reg
, delta_low
, this_reg
);
4534 fprintf (file
, "\taddi %s,%s,%d\n", this_reg
, this_reg
, delta_low
);
4537 /* 64-bit constants, fixme */
4541 /* Get the prefix in front of the names. */
4542 switch (DEFAULT_ABI
)
4552 case ABI_AIX_NODESC
:
4562 /* If the function is compiled in this module, jump to it directly.
4563 Otherwise, load up its address and jump to it. */
4565 fname
= XSTR (XEXP (DECL_RTL (function
), 0), 0);
4567 if (current_file_function_operand (XEXP (DECL_RTL (function
), 0))
4568 && ! lookup_attribute ("longcall",
4569 TYPE_ATTRIBUTES (TREE_TYPE (function
))))
4571 fprintf (file
, "\tb %s", prefix
);
4572 assemble_name (file
, fname
);
4573 if (DEFAULT_ABI
== ABI_V4
&& flag_pic
) fputs ("@local", file
);
4579 switch (DEFAULT_ABI
)
4586 /* Set up a TOC entry for the function. */
4587 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lthunk", labelno
);
4589 ASM_OUTPUT_INTERNAL_LABEL (file
, "Lthunk", labelno
);
4592 /* Note, MINIMAL_TOC doesn't make sense in the case of a thunk, since
4593 there will be only one TOC entry for this function. */
4594 fputs ("\t.tc\t", file
);
4595 assemble_name (file
, buf
);
4596 fputs ("[TC],", file
);
4597 assemble_name (file
, buf
);
4600 asm_fprintf (file
, (TARGET_32BIT
) ? "\t{l|lwz} %s," : "\tld %s", r12
);
4601 assemble_name (file
, buf
);
4602 asm_fprintf (file
, "(%s)\n", reg_names
[2]);
4604 (TARGET_32BIT
) ? "\t{l|lwz} %s,0(%s)\n" : "\tld %s,0(%s)\n",
4608 (TARGET_32BIT
) ? "\t{l|lwz} %s,4(%s)\n" : "\tld %s,8(%s)\n",
4611 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4613 (TARGET_32BIT
) ? "\t{l|lwz} %s,8(%s)\n" : "\tld %s,16(%s)\n",
4616 asm_fprintf (file
, "\tbctr\n");
4620 fprintf (file
, "\tb %s", prefix
);
4621 assemble_name (file
, fname
);
4622 if (flag_pic
) fputs ("@plt", file
);
4626 /* Don't use r11, that contains the static chain, just use r0/r12. */
4627 case ABI_AIX_NODESC
:
4631 fprintf (file
, "\tmflr %s\n", r0
);
4632 fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file
);
4633 asm_fprintf (file
, "\tmflr %s\n", r12
);
4634 asm_fprintf (file
, "\tmtlr %s\n", r0
);
4635 asm_fprintf (file
, "\t{l|lwz} %s,", r0
);
4636 assemble_name (file
, fname
);
4637 asm_fprintf (file
, "@got(%s)\n", r12
);
4638 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4639 asm_fprintf (file
, "\tbctr\n");
4642 else if (flag_pic
> 1 || TARGET_RELOCATABLE
)
4644 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lthunk", labelno
);
4646 fprintf (file
, "\tmflr %s\n", r0
);
4647 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n", r0
, sp
);
4648 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
4649 rs6000_output_load_toc_table (file
, 12);
4650 asm_fprintf (file
, "\t{l|lwz} %s,", r0
);
4651 assemble_name (file
, buf
);
4652 asm_fprintf (file
, "(%s)\n", r12
);
4653 asm_fprintf (file
, "\t{l|lwz} %s,4(%s)\n", r12
, sp
);
4654 asm_fprintf (file
, "\tmtlr %s\n", r12
);
4655 asm_fprintf (file
, "\tmtctr %s\n", r0
);
4656 asm_fprintf (file
, "\tbctr\n");
4657 asm_fprintf (file
, "%s\n", MINIMAL_TOC_SECTION_ASM_OP
);
4658 assemble_name (file
, buf
);
4659 fputs (" = .-.LCTOC1\n", file
);
4660 fputs ("\t.long ", file
);
4661 assemble_name (file
, fname
);
4662 fputs ("\n\t.previous\n", file
);
4664 #endif /* TARGET_ELF */
4668 asm_fprintf (file
, "\t{liu|lis} %s,", r12
);
4669 assemble_name (file
, fname
);
4670 asm_fprintf (file
, "@ha\n");
4671 asm_fprintf (file
, "\t{cal|la} %s,", r12
);
4672 assemble_name (file
, fname
);
4673 asm_fprintf (file
, "@l(%s)\n", r12
);
4674 asm_fprintf (file
, "\tmtctr %s\n", r12
);
4675 asm_fprintf (file
, "\tbctr\n");
4684 /* Output a TOC entry. We derive the entry name from what is
4688 output_toc (file
, x
, labelno
)
4702 /* if we're going to put a double constant in the TOC, make sure it's
4703 aligned properly when strict alignment is on. */
4704 if (GET_CODE (x
) == CONST_DOUBLE
4706 && GET_MODE (x
) == DFmode
4707 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
)) {
4708 ASM_OUTPUT_ALIGN (file
, 3);
4712 if (TARGET_ELF
&& TARGET_MINIMAL_TOC
)
4714 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LC");
4715 fprintf (file
, "%d = .-", labelno
);
4716 ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file
, "LCTOC");
4717 fputs ("1\n", file
);
4720 ASM_OUTPUT_INTERNAL_LABEL (file
, "LC", labelno
);
4722 /* Handle FP constants specially. Note that if we have a minimal
4723 TOC, things we put here aren't actually in the TOC, so we can allow
4725 if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == DFmode
4726 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4731 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
4732 REAL_VALUE_TO_TARGET_DOUBLE (rv
, k
);
4736 if (TARGET_MINIMAL_TOC
)
4737 fprintf (file
, "\t.llong 0x%lx%08lx\n", k
[0], k
[1]);
4739 fprintf (file
, "\t.tc FD_%lx_%lx[TC],0x%lx%08lx\n",
4740 k
[0], k
[1], k
[0] & 0xffffffff, k
[1] & 0xffffffff);
4745 if (TARGET_MINIMAL_TOC
)
4746 fprintf (file
, "\t.long 0x%lx\n\t.long 0x%lx\n", k
[0], k
[1]);
4748 fprintf (file
, "\t.tc FD_%lx_%lx[TC],0x%lx,0x%lx\n",
4749 k
[0], k
[1], k
[0], k
[1]);
4753 else if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == SFmode
4754 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4759 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
4760 REAL_VALUE_TO_TARGET_SINGLE (rv
, l
);
4764 if (TARGET_MINIMAL_TOC
)
4765 fprintf (file
, "\t.llong 0x%lx00000000\n", l
);
4767 fprintf (file
, "\t.tc FS_%lx[TC],0x%lx00000000\n", l
, l
);
4772 if (TARGET_MINIMAL_TOC
)
4773 fprintf (file
, "\t.long 0x%lx\n", l
);
4775 fprintf (file
, "\t.tc FS_%lx[TC],0x%lx\n", l
, l
);
4779 else if (GET_MODE (x
) == DImode
4780 && (GET_CODE (x
) == CONST_INT
|| GET_CODE (x
) == CONST_DOUBLE
)
4781 && ! (TARGET_NO_FP_IN_TOC
&& ! TARGET_MINIMAL_TOC
))
4786 if (GET_CODE (x
) == CONST_DOUBLE
)
4788 low
= CONST_DOUBLE_LOW (x
);
4789 high
= CONST_DOUBLE_HIGH (x
);
4792 #if HOST_BITS_PER_WIDE_INT == 32
4795 high
= (low
< 0) ? ~0 : 0;
4799 low
= INTVAL (x
) & 0xffffffff;
4800 high
= (HOST_WIDE_INT
) INTVAL (x
) >> 32;
4806 if (TARGET_MINIMAL_TOC
)
4807 fprintf (file
, "\t.llong 0x%lx%08lx\n", (long)high
, (long)low
);
4809 fprintf (file
, "\t.tc ID_%lx_%lx[TC],0x%lx%08lx\n",
4810 (long)high
, (long)low
, (long)high
, (long)low
);
4815 if (TARGET_MINIMAL_TOC
)
4816 fprintf (file
, "\t.long %ld\n\t.long %ld\n",
4817 (long)high
, (long)low
);
4819 fprintf (file
, "\t.tc ID_%lx_%lx[TC],%ld,%ld\n",
4820 (long)high
, (long)low
, (long)high
, (long)low
);
4825 if (GET_CODE (x
) == CONST
)
4827 base
= XEXP (XEXP (x
, 0), 0);
4828 offset
= INTVAL (XEXP (XEXP (x
, 0), 1));
4831 if (GET_CODE (base
) == SYMBOL_REF
)
4832 name
= XSTR (base
, 0);
4833 else if (GET_CODE (base
) == LABEL_REF
)
4834 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (XEXP (base
, 0)));
4835 else if (GET_CODE (base
) == CODE_LABEL
)
4836 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (base
));
4840 STRIP_NAME_ENCODING (real_name
, name
);
4841 if (TARGET_MINIMAL_TOC
)
4842 fputs (TARGET_32BIT
? "\t.long " : "\t.llong ", file
);
4845 fprintf (file
, "\t.tc %s", real_name
);
4848 fprintf (file
, ".N%d", - offset
);
4850 fprintf (file
, ".P%d", offset
);
4852 fputs ("[TC],", file
);
4855 /* Currently C++ toc references to vtables can be emitted before it
4856 is decided whether the vtable is public or private. If this is
4857 the case, then the linker will eventually complain that there is
4858 a TOC reference to an unknown section. Thus, for vtables only,
4859 we emit the TOC reference to reference the symbol and not the
4861 if (!strncmp ("_vt.", name
, 4))
4863 RS6000_OUTPUT_BASENAME (file
, name
);
4865 fprintf (file
, "%d", offset
);
4866 else if (offset
> 0)
4867 fprintf (file
, "+%d", offset
);
4870 output_addr_const (file
, x
);
4874 /* Output an assembler pseudo-op to write an ASCII string of N characters
4875 starting at P to FILE.
4877 On the RS/6000, we have to do this using the .byte operation and
4878 write out special characters outside the quoted string.
4879 Also, the assembler is broken; very long strings are truncated,
4880 so we must artificially break them up early. */
4883 output_ascii (file
, p
, n
)
4889 int i
, count_string
;
4890 const char *for_string
= "\t.byte \"";
4891 const char *for_decimal
= "\t.byte ";
4892 const char *to_close
= NULL
;
4895 for (i
= 0; i
< n
; i
++)
4898 if (c
>= ' ' && c
< 0177)
4901 fputs (for_string
, file
);
4904 /* Write two quotes to get one. */
4912 for_decimal
= "\"\n\t.byte ";
4916 if (count_string
>= 512)
4918 fputs (to_close
, file
);
4920 for_string
= "\t.byte \"";
4921 for_decimal
= "\t.byte ";
4929 fputs (for_decimal
, file
);
4930 fprintf (file
, "%d", c
);
4932 for_string
= "\n\t.byte \"";
4939 /* Now close the string if we have written one. Then end the line. */
4941 fprintf (file
, to_close
);
4944 /* Generate a unique section name for FILENAME for a section type
4945 represented by SECTION_DESC. Output goes into BUF.
4947 SECTION_DESC can be any string, as long as it is different for each
4948 possible section type.
4950 We name the section in the same manner as xlc. The name begins with an
4951 underscore followed by the filename (after stripping any leading directory
4952 names) with the last period replaced by the string SECTION_DESC. If
4953 FILENAME does not contain a period, SECTION_DESC is appended to the end of
4957 rs6000_gen_section_name (buf
, filename
, section_desc
)
4962 char *q
, *after_last_slash
, *last_period
= 0;
4966 after_last_slash
= filename
;
4967 for (q
= filename
; *q
; q
++)
4970 after_last_slash
= q
+ 1;
4975 len
= strlen (after_last_slash
) + strlen (section_desc
) + 2;
4976 *buf
= (char *) permalloc (len
);
4981 for (q
= after_last_slash
; *q
; q
++)
4983 if (q
== last_period
)
4985 strcpy (p
, section_desc
);
4986 p
+= strlen (section_desc
);
4989 else if (ISALNUM (*q
))
4993 if (last_period
== 0)
4994 strcpy (p
, section_desc
);
4999 /* Write function profiler code. */
5002 output_function_profiler (file
, labelno
)
5006 /* The last used parameter register. */
5011 ASM_GENERATE_INTERNAL_LABEL (buf
, "LP", labelno
);
5012 switch (DEFAULT_ABI
)
5019 case ABI_AIX_NODESC
:
5020 fprintf (file
, "\tmflr %s\n", reg_names
[0]);
5023 fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file
);
5024 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5025 reg_names
[0], reg_names
[1]);
5026 asm_fprintf (file
, "\tmflr %s\n", reg_names
[12]);
5027 asm_fprintf (file
, "\t{l|lwz} %s,", reg_names
[0]);
5028 assemble_name (file
, buf
);
5029 asm_fprintf (file
, "@got(%s)\n", reg_names
[12]);
5032 else if (flag_pic
> 1 || TARGET_RELOCATABLE
)
5034 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5035 reg_names
[0], reg_names
[1]);
5036 rs6000_pic_func_labelno
= rs6000_pic_labelno
;
5037 rs6000_output_load_toc_table (file
, 12);
5038 asm_fprintf (file
, "\t{l|lwz} %s,", reg_names
[12]);
5039 assemble_name (file
, buf
);
5040 asm_fprintf (file
, "X(%s)\n", reg_names
[12]);
5041 asm_fprintf (file
, "%s\n", MINIMAL_TOC_SECTION_ASM_OP
);
5042 assemble_name (file
, buf
);
5043 fputs ("X = .-.LCTOC1\n", file
);
5044 fputs ("\t.long ", file
);
5045 assemble_name (file
, buf
);
5046 fputs ("\n\t.previous\n", file
);
5051 asm_fprintf (file
, "\t{liu|lis} %s,", reg_names
[12]);
5052 assemble_name (file
, buf
);
5053 fputs ("@ha\n", file
);
5054 asm_fprintf (file
, "\t{st|stw} %s,4(%s)\n",
5055 reg_names
[0], reg_names
[1]);
5056 asm_fprintf (file
, "\t{cal|la} %s,", reg_names
[0]);
5057 assemble_name (file
, buf
);
5058 asm_fprintf (file
, "@l(%s)\n", reg_names
[12]);
5061 if (current_function_needs_context
)
5062 asm_fprintf (file
, "\tmr %s,%s\n",
5063 reg_names
[30], reg_names
[STATIC_CHAIN_REGNUM
]);
5064 fprintf (file
, "\tbl %s\n", RS6000_MCOUNT
);
5065 if (current_function_needs_context
)
5066 asm_fprintf (file
, "\tmr %s,%s\n",
5067 reg_names
[STATIC_CHAIN_REGNUM
], reg_names
[30]);
5071 /* Set up a TOC entry for the profiler label. */
5073 ASM_OUTPUT_INTERNAL_LABEL (file
, "LPC", labelno
);
5074 if (TARGET_MINIMAL_TOC
)
5076 fputs (TARGET_32BIT
? "\t.long " : "\t.llong ", file
);
5077 assemble_name (file
, buf
);
5082 fputs ("\t.tc\t", file
);
5083 assemble_name (file
, buf
);
5084 fputs ("[TC],", file
);
5085 assemble_name (file
, buf
);
5090 /* Figure out last used parameter register. The proper thing to do is
5091 to walk incoming args of the function. A function might have live
5092 parameter registers even if it has no incoming args. */
5094 for (last_parm_reg
= 10;
5095 last_parm_reg
> 2 && ! regs_ever_live
[last_parm_reg
];
5099 /* Save parameter registers in regs 23-30 and static chain in r22.
5100 Don't overwrite reg 31, since it might be set up as the frame pointer. */
5102 for (i
= 3, j
= 30; i
<= last_parm_reg
; i
++, j
--)
5103 asm_fprintf (file
, "\tmr %d,%d\n", j
, i
);
5104 if (current_function_needs_context
)
5105 asm_fprintf (file
, "\tmr %d,%d\n", j
, STATIC_CHAIN_REGNUM
);
5107 /* Load location address into r3, and call mcount. */
5109 ASM_GENERATE_INTERNAL_LABEL (buf
, "LPC", labelno
);
5110 asm_fprintf (file
, TARGET_32BIT
? "\t{l|lwz} %s," : "\tld %s,",
5112 assemble_name (file
, buf
);
5113 asm_fprintf (file
, "(%s)\n\tbl %s\n\t", reg_names
[2], RS6000_MCOUNT
);
5114 asm_fprintf (file
, RS6000_CALL_GLUE
);
5117 /* Restore parameter registers and static chain. */
5119 for (i
= 3, j
= 30; i
<= last_parm_reg
; i
++, j
--)
5120 asm_fprintf (file
, "\tmr %d,%d\n", i
, j
);
5121 if (current_function_needs_context
)
5122 asm_fprintf (file
, "\tmr %d,%d\n", STATIC_CHAIN_REGNUM
, j
);
5128 /* Adjust the cost of a scheduling dependency. Return the new cost of
5129 a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
5132 rs6000_adjust_cost (insn
, link
, dep_insn
, cost
)
5135 rtx dep_insn ATTRIBUTE_UNUSED
;
5138 if (! recog_memoized (insn
))
5141 if (REG_NOTE_KIND (link
) != 0)
5144 if (REG_NOTE_KIND (link
) == 0)
5146 /* Data dependency; DEP_INSN writes a register that INSN reads some
5149 /* Tell the first scheduling pass about the latency between a mtctr
5150 and bctr (and mtlr and br/blr). The first scheduling pass will not
5151 know about this latency since the mtctr instruction, which has the
5152 latency associated to it, will be generated by reload. */
5153 if (get_attr_type (insn
) == TYPE_JMPREG
)
5154 return TARGET_POWER
? 5 : 4;
5156 /* Fall out to return default cost. */
5162 /* A C statement (sans semicolon) to update the integer scheduling priority
5163 INSN_PRIORITY (INSN). Reduce the priority to execute the INSN earlier,
5164 increase the priority to execute INSN later. Do not define this macro if
5165 you do not need to adjust the scheduling priorities of insns. */
5168 rs6000_adjust_priority (insn
, priority
)
5169 rtx insn ATTRIBUTE_UNUSED
;
5172 /* On machines (like the 750) which have asymetric integer units, where one
5173 integer unit can do multiply and divides and the other can't, reduce the
5174 priority of multiply/divide so it is scheduled before other integer
5178 if (GET_RTX_CLASS (GET_CODE (insn
)) != 'i')
5181 if (GET_CODE (PATTERN (insn
)) == USE
)
5184 switch (rs6000_cpu_attr
) {
5186 switch (get_attr_type (insn
))
5193 fprintf (stderr
, "priority was %#x (%d) before adjustment\n", priority
, priority
);
5194 if (priority
>= 0 && priority
< 0x01000000)
5204 /* Return how many instructions the machine can issue per cycle */
5205 int get_issue_rate()
5207 switch (rs6000_cpu_attr
) {
5230 /* Output assembler code for a block containing the constant parts
5231 of a trampoline, leaving space for the variable parts.
5233 The trampoline should set the static chain pointer to value placed
5234 into the trampoline and should branch to the specified routine. */
5237 rs6000_trampoline_template (file
)
5240 const char *sc
= reg_names
[STATIC_CHAIN_REGNUM
];
5241 const char *r0
= reg_names
[0];
5242 const char *r2
= reg_names
[2];
5244 switch (DEFAULT_ABI
)
5249 /* Under AIX, this is not code at all, but merely a data area,
5250 since that is the way all functions are called. The first word is
5251 the address of the function, the second word is the TOC pointer (r2),
5252 and the third word is the static chain value. */
5257 /* V.4/eabi function pointers are just a single pointer, so we need to
5258 do the full gory code to load up the static chain. */
5261 case ABI_AIX_NODESC
:
5264 /* NT function pointers point to a two word area (real address, TOC)
5265 which unfortunately does not include a static chain field. So we
5266 use the function field to point to ..LTRAMP1 and the toc field
5267 to point to the whole table. */
5269 if (STATIC_CHAIN_REGNUM
== 0
5270 || STATIC_CHAIN_REGNUM
== 2
5272 || !TARGET_NEW_MNEMONICS
)
5275 fprintf (file
, "\t.ualong 0\n"); /* offset 0 */
5276 fprintf (file
, "\t.ualong 0\n"); /* offset 4 */
5277 fprintf (file
, "\t.ualong 0\n"); /* offset 8 */
5278 fprintf (file
, "\t.ualong 0\n"); /* offset 12 */
5279 fprintf (file
, "\t.ualong 0\n"); /* offset 16 */
5280 fprintf (file
, "..LTRAMP1..0:\n"); /* offset 20 */
5281 fprintf (file
, "\tlwz %s,8(%s)\n", r0
, r2
); /* offset 24 */
5282 fprintf (file
, "\tlwz %s,12(%s)\n", sc
, r2
); /* offset 28 */
5283 fprintf (file
, "\tmtctr %s\n", r0
); /* offset 32 */
5284 fprintf (file
, "\tlwz %s,16(%s)\n", r2
, r2
); /* offset 36 */
5285 fprintf (file
, "\tbctr\n"); /* offset 40 */
5292 /* Length in units of the trampoline for entering a nested function. */
5295 rs6000_trampoline_size ()
5299 switch (DEFAULT_ABI
)
5305 ret
= (TARGET_32BIT
) ? 12 : 24;
5310 case ABI_AIX_NODESC
:
5311 ret
= (TARGET_32BIT
) ? 40 : 48;
5322 /* Emit RTL insns to initialize the variable parts of a trampoline.
5323 FNADDR is an RTX for the address of the function's pure code.
5324 CXT is an RTX for the static chain value for the function. */
5327 rs6000_initialize_trampoline (addr
, fnaddr
, cxt
)
5332 enum machine_mode pmode
= Pmode
;
5333 int regsize
= (TARGET_32BIT
) ? 4 : 8;
5334 rtx ctx_reg
= force_reg (pmode
, cxt
);
5336 switch (DEFAULT_ABI
)
5341 /* Macros to shorten the code expansions below. */
5342 #define MEM_DEREF(addr) gen_rtx_MEM (pmode, memory_address (pmode, addr))
5343 #define MEM_PLUS(addr,offset) gen_rtx_MEM (pmode, memory_address (pmode, plus_constant (addr, offset)))
5345 /* Under AIX, just build the 3 word function descriptor */
5348 rtx fn_reg
= gen_reg_rtx (pmode
);
5349 rtx toc_reg
= gen_reg_rtx (pmode
);
5350 emit_move_insn (fn_reg
, MEM_DEREF (fnaddr
));
5351 emit_move_insn (toc_reg
, MEM_PLUS (fnaddr
, 4));
5352 emit_move_insn (MEM_DEREF (addr
), fn_reg
);
5353 emit_move_insn (MEM_PLUS (addr
, regsize
), toc_reg
);
5354 emit_move_insn (MEM_PLUS (addr
, 2*regsize
), ctx_reg
);
5358 /* Under V.4/eabi, call __trampoline_setup to do the real work. */
5361 case ABI_AIX_NODESC
:
5362 emit_library_call (gen_rtx_SYMBOL_REF (SImode
, "__trampoline_setup"),
5365 GEN_INT (rs6000_trampoline_size ()), SImode
,
5370 /* Under NT, update the first word to point to the ..LTRAMP1..0 header,
5371 the second word will point to the whole trampoline, third-fifth words
5372 will then have the real address, static chain, and toc value. */
5375 rtx tramp_reg
= gen_reg_rtx (pmode
);
5376 rtx fn_reg
= gen_reg_rtx (pmode
);
5377 rtx toc_reg
= gen_reg_rtx (pmode
);
5379 emit_move_insn (tramp_reg
, gen_rtx_SYMBOL_REF (pmode
, "..LTRAMP1..0"));
5380 addr
= force_reg (pmode
, addr
);
5381 emit_move_insn (fn_reg
, MEM_DEREF (fnaddr
));
5382 emit_move_insn (toc_reg
, MEM_PLUS (fnaddr
, regsize
));
5383 emit_move_insn (MEM_DEREF (addr
), tramp_reg
);
5384 emit_move_insn (MEM_PLUS (addr
, regsize
), addr
);
5385 emit_move_insn (MEM_PLUS (addr
, 2*regsize
), fn_reg
);
5386 emit_move_insn (MEM_PLUS (addr
, 3*regsize
), ctx_reg
);
5387 emit_move_insn (MEM_PLUS (addr
, 4*regsize
), gen_rtx_REG (pmode
, 2));
5396 /* If defined, a C expression whose value is nonzero if IDENTIFIER
5397 with arguments ARGS is a valid machine specific attribute for DECL.
5398 The attributes in ATTRIBUTES have previously been assigned to DECL. */
5401 rs6000_valid_decl_attribute_p (decl
, attributes
, identifier
, args
)
5402 tree decl ATTRIBUTE_UNUSED
;
5403 tree attributes ATTRIBUTE_UNUSED
;
5404 tree identifier ATTRIBUTE_UNUSED
;
5405 tree args ATTRIBUTE_UNUSED
;
5410 /* If defined, a C expression whose value is nonzero if IDENTIFIER
5411 with arguments ARGS is a valid machine specific attribute for TYPE.
5412 The attributes in ATTRIBUTES have previously been assigned to TYPE. */
5415 rs6000_valid_type_attribute_p (type
, attributes
, identifier
, args
)
5417 tree attributes ATTRIBUTE_UNUSED
;
5421 if (TREE_CODE (type
) != FUNCTION_TYPE
5422 && TREE_CODE (type
) != FIELD_DECL
5423 && TREE_CODE (type
) != TYPE_DECL
)
5426 /* Longcall attribute says that the function is not within 2**26 bytes
5427 of the current function, and to do an indirect call. */
5428 if (is_attribute_p ("longcall", identifier
))
5429 return (args
== NULL_TREE
);
5431 if (DEFAULT_ABI
== ABI_NT
)
5433 /* Stdcall attribute says callee is responsible for popping arguments
5434 if they are not variable. */
5435 if (is_attribute_p ("stdcall", identifier
))
5436 return (args
== NULL_TREE
);
5438 /* Cdecl attribute says the callee is a normal C declaration */
5439 if (is_attribute_p ("cdecl", identifier
))
5440 return (args
== NULL_TREE
);
5442 /* Dllimport attribute says the caller is to call the function
5443 indirectly through a __imp_<name> pointer. */
5444 if (is_attribute_p ("dllimport", identifier
))
5445 return (args
== NULL_TREE
);
5447 /* Dllexport attribute says the callee is to create a __imp_<name>
5449 if (is_attribute_p ("dllexport", identifier
))
5450 return (args
== NULL_TREE
);
5452 /* Exception attribute allows the user to specify 1-2 strings or identifiers
5453 that will fill in the 3rd and 4th fields of the structured exception
5455 if (is_attribute_p ("exception", identifier
))
5459 if (args
== NULL_TREE
)
5462 for (i
= 0; i
< 2 && args
!= NULL_TREE
; i
++)
5464 tree this_arg
= TREE_VALUE (args
);
5465 args
= TREE_PURPOSE (args
);
5467 if (TREE_CODE (this_arg
) != STRING_CST
5468 && TREE_CODE (this_arg
) != IDENTIFIER_NODE
)
5472 return (args
== NULL_TREE
);
5479 /* If defined, a C expression whose value is zero if the attributes on
5480 TYPE1 and TYPE2 are incompatible, one if they are compatible, and
5481 two if they are nearly compatible (which causes a warning to be
5485 rs6000_comp_type_attributes (type1
, type2
)
5486 tree type1 ATTRIBUTE_UNUSED
;
5487 tree type2 ATTRIBUTE_UNUSED
;
5492 /* If defined, a C statement that assigns default attributes to newly
5496 rs6000_set_default_type_attributes (type
)
5497 tree type ATTRIBUTE_UNUSED
;
5501 /* Return a dll import reference corresponding to a call's SYMBOL_REF */
5503 rs6000_dll_import_ref (call_ref
)
5506 const char *call_name
;
5512 if (GET_CODE (call_ref
) != SYMBOL_REF
)
5515 call_name
= XSTR (call_ref
, 0);
5516 len
= sizeof ("__imp_") + strlen (call_name
);
5518 reg2
= gen_reg_rtx (Pmode
);
5520 strcpy (p
, "__imp_");
5521 strcat (p
, call_name
);
5522 node
= get_identifier (p
);
5524 reg1
= force_reg (Pmode
, gen_rtx_SYMBOL_REF (VOIDmode
, IDENTIFIER_POINTER (node
)));
5525 emit_move_insn (reg2
, gen_rtx_MEM (Pmode
, reg1
));
5530 /* Return a reference suitable for calling a function with the longcall attribute. */
5532 rs6000_longcall_ref (call_ref
)
5535 const char *call_name
;
5538 if (GET_CODE (call_ref
) != SYMBOL_REF
)
5541 /* System V adds '.' to the internal name, so skip them. */
5542 call_name
= XSTR (call_ref
, 0);
5543 if (*call_name
== '.')
5545 while (*call_name
== '.')
5548 node
= get_identifier (call_name
);
5549 call_ref
= gen_rtx_SYMBOL_REF (VOIDmode
, IDENTIFIER_POINTER (node
));
5552 return force_reg (Pmode
, call_ref
);
5556 /* A C statement or statements to switch to the appropriate section
5557 for output of RTX in mode MODE. You can assume that RTX is some
5558 kind of constant in RTL. The argument MODE is redundant except in
5559 the case of a `const_int' rtx. Select the section by calling
5560 `text_section' or one of the alternatives for other sections.
5562 Do not define this macro if you put all constants in the read-only
5568 rs6000_select_rtx_section (mode
, x
)
5569 enum machine_mode mode
;
5572 if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x
))
5578 /* A C statement or statements to switch to the appropriate
5579 section for output of DECL. DECL is either a `VAR_DECL' node
5580 or a constant of some sort. RELOC indicates whether forming
5581 the initial value of DECL requires link-time relocations. */
5584 rs6000_select_section (decl
, reloc
)
5588 int size
= int_size_in_bytes (TREE_TYPE (decl
));
5590 if (TREE_CODE (decl
) == STRING_CST
)
5592 if (! flag_writable_strings
)
5597 else if (TREE_CODE (decl
) == VAR_DECL
)
5599 if ((flag_pic
&& reloc
)
5600 || !TREE_READONLY (decl
)
5601 || TREE_SIDE_EFFECTS (decl
)
5602 || !DECL_INITIAL (decl
)
5603 || (DECL_INITIAL (decl
) != error_mark_node
5604 && !TREE_CONSTANT (DECL_INITIAL (decl
))))
5606 if (rs6000_sdata
!= SDATA_NONE
&& (size
> 0) && (size
<= g_switch_value
))
5613 if (rs6000_sdata
!= SDATA_NONE
&& (size
> 0) && (size
<= g_switch_value
))
5615 if (rs6000_sdata
== SDATA_EABI
)
5618 sdata_section (); /* System V doesn't have .sdata2/.sbss2 */
5630 /* If we are referencing a function that is static or is known to be
5631 in this file, make the SYMBOL_REF special. We can use this to indicate
5632 that we can branch to this function without emitting a no-op after the
5633 call. For real AIX and NT calling sequences, we also replace the
5634 function name with the real name (1 or 2 leading .'s), rather than
5635 the function descriptor name. This saves a lot of overriding code
5636 to read the prefixes. */
5639 rs6000_encode_section_info (decl
)
5642 if (TREE_CODE (decl
) == FUNCTION_DECL
)
5644 rtx sym_ref
= XEXP (DECL_RTL (decl
), 0);
5645 if (TREE_ASM_WRITTEN (decl
) || ! TREE_PUBLIC (decl
))
5646 SYMBOL_REF_FLAG (sym_ref
) = 1;
5648 if (DEFAULT_ABI
== ABI_AIX
|| DEFAULT_ABI
== ABI_NT
)
5650 const char *prefix
= (DEFAULT_ABI
== ABI_AIX
) ? "." : "..";
5651 char *str
= permalloc (strlen (prefix
) + 1
5652 + strlen (XSTR (sym_ref
, 0)));
5653 strcpy (str
, prefix
);
5654 strcat (str
, XSTR (sym_ref
, 0));
5655 XSTR (sym_ref
, 0) = str
;
5658 else if (rs6000_sdata
!= SDATA_NONE
5659 && (DEFAULT_ABI
== ABI_V4
|| DEFAULT_ABI
== ABI_SOLARIS
)
5660 && TREE_CODE (decl
) == VAR_DECL
)
5662 int size
= int_size_in_bytes (TREE_TYPE (decl
));
5663 tree section_name
= DECL_SECTION_NAME (decl
);
5664 const char *name
= (char *)0;
5669 if (TREE_CODE (section_name
) == STRING_CST
)
5671 name
= TREE_STRING_POINTER (section_name
);
5672 len
= TREE_STRING_LENGTH (section_name
);
5678 if ((size
> 0 && size
<= g_switch_value
)
5680 && ((len
== sizeof (".sdata")-1 && strcmp (name
, ".sdata") == 0)
5681 || (len
== sizeof (".sdata2")-1 && strcmp (name
, ".sdata2") == 0)
5682 || (len
== sizeof (".sbss")-1 && strcmp (name
, ".sbss") == 0)
5683 || (len
== sizeof (".sbss2")-1 && strcmp (name
, ".sbss2") == 0)
5684 || (len
== sizeof (".PPC.EMB.sdata0")-1 && strcmp (name
, ".PPC.EMB.sdata0") == 0)
5685 || (len
== sizeof (".PPC.EMB.sbss0")-1 && strcmp (name
, ".PPC.EMB.sbss0") == 0))))
5687 rtx sym_ref
= XEXP (DECL_RTL (decl
), 0);
5688 char *str
= permalloc (2 + strlen (XSTR (sym_ref
, 0)));
5690 strcat (str
, XSTR (sym_ref
, 0));
5691 XSTR (sym_ref
, 0) = str
;
5696 #endif /* USING_SVR4_H */
5699 /* Return a REG that occurs in ADDR with coefficient 1.
5700 ADDR can be effectively incremented by incrementing REG.
5702 r0 is special and we must not select it as an address
5703 register by this routine since our caller will try to
5704 increment the returned register via an "la" instruction. */
5707 find_addr_reg (addr
)
5710 while (GET_CODE (addr
) == PLUS
)
5712 if (GET_CODE (XEXP (addr
, 0)) == REG
5713 && REGNO (XEXP (addr
, 0)) != 0)
5714 addr
= XEXP (addr
, 0);
5715 else if (GET_CODE (XEXP (addr
, 1)) == REG
5716 && REGNO (XEXP (addr
, 1)) != 0)
5717 addr
= XEXP (addr
, 1);
5718 else if (CONSTANT_P (XEXP (addr
, 0)))
5719 addr
= XEXP (addr
, 1);
5720 else if (CONSTANT_P (XEXP (addr
, 1)))
5721 addr
= XEXP (addr
, 0);
5725 if (GET_CODE (addr
) == REG
&& REGNO (addr
) != 0)
5731 rs6000_fatal_bad_address (op
)
5734 fatal_insn ("bad address", op
);