OSDN Git Service

* config/rs6000/darwin.h (SUBTARGET_OPTIONS): Move from here, to...
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / linux64.h
1 /* Definitions of target machine for GNU compiler,
2    for 64 bit PowerPC linux.
3    Copyright (C) 2000, 2001, 2002, 2003, 2004
4    Free Software Foundation, Inc.
5
6    This file is part of GCC.
7
8    GCC is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published
10    by the Free Software Foundation; either version 2, or (at your
11    option) any later version.
12
13    GCC is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16    License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING.  If not, write to the
20    Free Software Foundation, 59 Temple Place - Suite 330, Boston,
21    MA 02111-1307, USA.  */
22
23 #ifndef RS6000_BI_ARCH
24
25 #undef  DEFAULT_ABI
26 #define DEFAULT_ABI ABI_AIX
27
28 #undef  TARGET_64BIT
29 #define TARGET_64BIT 1
30
31 #define DEFAULT_ARCH64_P 1
32 #define RS6000_BI_ARCH_P 0
33
34 #else
35
36 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
37 #define RS6000_BI_ARCH_P 1
38
39 #endif
40
41 #ifdef IN_LIBGCC2
42 #undef TARGET_64BIT
43 #ifdef __powerpc64__
44 #define TARGET_64BIT 1
45 #else
46 #define TARGET_64BIT 0
47 #endif
48 #endif
49
50 #undef  TARGET_AIX
51 #define TARGET_AIX TARGET_64BIT
52
53 #ifdef HAVE_LD_NO_DOT_SYMS
54 /* New ABI uses a local sym for the function entry point.  */
55 extern int dot_symbols;
56 #undef DOT_SYMBOLS
57 #define DOT_SYMBOLS dot_symbols
58 #endif
59
60 #undef PROCESSOR_DEFAULT64
61 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
62
63 #undef  TARGET_RELOCATABLE
64 #define TARGET_RELOCATABLE (!TARGET_64BIT && (target_flags & MASK_RELOCATABLE))
65
66 #undef  RS6000_ABI_NAME
67 #define RS6000_ABI_NAME "linux"
68
69 #define INVALID_64BIT "-m%s not supported in this configuration"
70 #define INVALID_32BIT INVALID_64BIT
71
72 #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
73 #define SUBSUBTARGET_OVERRIDE_OPTIONS                           \
74   do                                                            \
75     {                                                           \
76       if (rs6000_alignment_string == 0)                         \
77         rs6000_alignment_flags = MASK_ALIGN_NATURAL;            \
78       if (TARGET_64BIT)                                         \
79         {                                                       \
80           if (DEFAULT_ABI != ABI_AIX)                           \
81             {                                                   \
82               rs6000_current_abi = ABI_AIX;                     \
83               error (INVALID_64BIT, "call");                    \
84             }                                                   \
85           dot_symbols = !strcmp (rs6000_abi_name, "aixdesc");   \
86           if (target_flags & MASK_RELOCATABLE)                  \
87             {                                                   \
88               target_flags &= ~MASK_RELOCATABLE;                \
89               error (INVALID_64BIT, "relocatable");             \
90             }                                                   \
91           if (target_flags & MASK_EABI)                         \
92             {                                                   \
93               target_flags &= ~MASK_EABI;                       \
94               error (INVALID_64BIT, "eabi");                    \
95             }                                                   \
96           if (target_flags & MASK_PROTOTYPE)                    \
97             {                                                   \
98               target_flags &= ~MASK_PROTOTYPE;                  \
99               error (INVALID_64BIT, "prototype");               \
100             }                                                   \
101           if ((target_flags & MASK_POWERPC64) == 0)             \
102             {                                                   \
103               target_flags |= MASK_POWERPC64;                   \
104               error ("-m64 requires a PowerPC64 cpu");          \
105             }                                                   \
106         }                                                       \
107       else                                                      \
108         {                                                       \
109           if (!RS6000_BI_ARCH_P)                                \
110             error (INVALID_32BIT, "32");                        \
111           if (TARGET_PROFILE_KERNEL)                            \
112             {                                                   \
113               target_flags &= ~MASK_PROFILE_KERNEL;             \
114               error (INVALID_32BIT, "profile-kernel");          \
115             }                                                   \
116         }                                                       \
117     }                                                           \
118   while (0)
119
120 #ifdef  RS6000_BI_ARCH
121
122 #undef  OVERRIDE_OPTIONS
123 #define OVERRIDE_OPTIONS \
124   rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \
125                            ? (char *) 0 : TARGET_CPU_DEFAULT)
126
127 #endif
128
129 #undef  ASM_DEFAULT_SPEC
130 #undef  ASM_SPEC
131 #undef  LINK_OS_LINUX_SPEC
132
133 #ifndef RS6000_BI_ARCH
134 #define ASM_DEFAULT_SPEC "-mppc64"
135 #define ASM_SPEC         "%(asm_spec64) %(asm_spec_common)"
136 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
137 #else
138 #if DEFAULT_ARCH64_P
139 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
140 #define ASM_SPEC         "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
141 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
142 #else
143 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
144 #define ASM_SPEC         "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
145 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
146 #endif
147 #endif
148
149 #define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
150 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
151 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
152 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
153     %{mcall-freebsd: -mbig} \
154     %{mcall-i960-old: -mlittle} \
155     %{mcall-linux: -mbig} \
156     %{mcall-gnu: -mbig} \
157     %{mcall-netbsd: -mbig} \
158 }}}}"
159
160 #define ASM_SPEC64 "-a64"
161
162 #define ASM_SPEC_COMMON "%(asm_cpu) \
163 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
164 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Wa,*:%*} \
165 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
166
167 #undef  SUBSUBTARGET_EXTRA_SPECS
168 #define SUBSUBTARGET_EXTRA_SPECS \
169   { "asm_spec_common",          ASM_SPEC_COMMON },                      \
170   { "asm_spec32",               ASM_SPEC32 },                           \
171   { "asm_spec64",               ASM_SPEC64 },                           \
172   { "link_os_linux_spec32",     LINK_OS_LINUX_SPEC32 },                 \
173   { "link_os_linux_spec64",     LINK_OS_LINUX_SPEC64 },
174
175 #undef  MULTILIB_DEFAULTS
176 #if DEFAULT_ARCH64_P
177 #define MULTILIB_DEFAULTS { "m64" }
178 #else
179 #define MULTILIB_DEFAULTS { "m32" }
180 #endif
181
182 #ifndef RS6000_BI_ARCH
183
184 /* 64-bit PowerPC Linux is always big-endian.  */
185 #undef  TARGET_LITTLE_ENDIAN
186 #define TARGET_LITTLE_ENDIAN    0
187
188 /* 64-bit PowerPC Linux always has a TOC.  */
189 #undef  TARGET_TOC
190 #define TARGET_TOC              1
191
192 /* Some things from sysv4.h we don't do when 64 bit.  */
193 #undef  TARGET_RELOCATABLE
194 #define TARGET_RELOCATABLE      0
195 #undef  TARGET_EABI
196 #define TARGET_EABI             0
197 #undef  TARGET_PROTOTYPE
198 #define TARGET_PROTOTYPE        0
199
200 #endif
201
202 #define MASK_PROFILE_KERNEL     0x00100000
203
204 /* Non-standard profiling for kernels, which just saves LR then calls
205    _mcount without worrying about arg saves.  The idea is to change
206    the function prologue as little as possible as it isn't easy to
207    account for arg save/restore code added just for _mcount.  */
208 #define TARGET_PROFILE_KERNEL   (target_flags & MASK_PROFILE_KERNEL)
209
210 /* Override sysv4.h.  */
211 #undef  EXTRA_SUBTARGET_SWITCHES
212 #define EXTRA_SUBTARGET_SWITCHES                                        \
213   {"profile-kernel",     MASK_PROFILE_KERNEL,                           \
214    N_("Call mcount for profiling before a function prologue") },        \
215   {"no-profile-kernel", -MASK_PROFILE_KERNEL,                           \
216    N_("Call mcount for profiling after a function prologue") },
217
218 /* We use glibc _mcount for profiling.  */
219 #define NO_PROFILE_COUNTERS TARGET_64BIT
220 #define PROFILE_HOOK(LABEL) \
221   do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
222
223 /* We don't need to generate entries in .fixup.  */
224 #undef RELOCATABLE_NEEDS_FIXUP
225
226 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given.  */
227 #undef  ADJUST_FIELD_ALIGN
228 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
229   ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)     \
230    ? 128                                                                \
231    : (TARGET_64BIT                                                      \
232       && TARGET_ALIGN_NATURAL == 0                                      \
233       && TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE         \
234                     ? get_inner_array_type (FIELD)                      \
235                     : TREE_TYPE (FIELD)) == DFmode)                     \
236    ? MIN ((COMPUTED), 32)                                               \
237    : (COMPUTED))
238
239 /* PowerPC64 Linux increases natural record alignment to doubleword if
240    the first field is an FP double, only if in power alignment mode.  */
241 #undef  ROUND_TYPE_ALIGN
242 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                   \
243   ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE)                \
244    ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)                           \
245    : (TARGET_64BIT                                                      \
246       && (TREE_CODE (STRUCT) == RECORD_TYPE                             \
247           || TREE_CODE (STRUCT) == UNION_TYPE                           \
248           || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                     \
249       && TARGET_ALIGN_NATURAL == 0)                                     \
250    ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)      \
251    : MAX ((COMPUTED), (SPECIFIED)))
252
253 /* Indicate that jump tables go in the text section.  */
254 #undef  JUMP_TABLES_IN_TEXT_SECTION
255 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
256
257 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
258    than a doubleword should be padded upward or downward.  You could
259    reasonably assume that they follow the normal rules for structure
260    layout treating the parameter area as any other block of memory,
261    then map the reg param area to registers.  ie. pad updard.
262    Setting both of the following defines results in this behavior.
263    Setting just the first one will result in aggregates that fit in a
264    doubleword being padded downward, and others being padded upward.
265    Not a bad idea as this results in struct { int x; } being passed
266    the same way as an int.  */
267 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
268 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
269
270 /* Specify padding for the last element of a block move between
271    registers and memory.  FIRST is nonzero if this is the only
272    element.  */
273 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
274   (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
275
276 /* __throw will restore its own return address to be the same as the
277    return address of the function that the throw is being made to.
278    This is unfortunate, because we want to check the original
279    return address to see if we need to restore the TOC.
280    So we have to squirrel it away with this.  */
281 #define SETUP_FRAME_ADDRESSES() \
282   do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
283
284 /* Override svr4.h  */
285 #undef MD_EXEC_PREFIX
286 #undef MD_STARTFILE_PREFIX
287
288 #undef  TARGET_OS_CPP_BUILTINS
289 #define TARGET_OS_CPP_BUILTINS()                        \
290   do                                                    \
291     {                                                   \
292       if (TARGET_64BIT)                                 \
293         {                                               \
294           builtin_define ("__PPC__");                   \
295           builtin_define ("__PPC64__");                 \
296           builtin_define ("__powerpc__");               \
297           builtin_define ("__powerpc64__");             \
298           builtin_define ("__PIC__");                   \
299           builtin_assert ("cpu=powerpc64");             \
300           builtin_assert ("machine=powerpc64");         \
301         }                                               \
302       else                                              \
303         {                                               \
304           builtin_define_std ("PPC");                   \
305           builtin_define_std ("powerpc");               \
306           builtin_assert ("cpu=powerpc");               \
307           builtin_assert ("machine=powerpc");           \
308           TARGET_OS_SYSV_CPP_BUILTINS ();               \
309         }                                               \
310     }                                                   \
311   while (0)
312
313 #undef  CPP_OS_DEFAULT_SPEC
314 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
315
316 /* The GNU C++ standard library currently requires _GNU_SOURCE being
317    defined on glibc-based systems. This temporary hack accomplishes this,
318    it should go away as soon as libstdc++-v3 has a real fix.  */
319 #undef  CPLUSPLUS_CPP_SPEC
320 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
321
322 #undef  LINK_SHLIB_SPEC
323 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
324
325 #undef  LIB_DEFAULT_SPEC
326 #define LIB_DEFAULT_SPEC "%(lib_linux)"
327
328 #undef  STARTFILE_DEFAULT_SPEC
329 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
330
331 #undef  ENDFILE_DEFAULT_SPEC
332 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
333
334 #undef  LINK_START_DEFAULT_SPEC
335 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
336
337 #undef  LINK_OS_DEFAULT_SPEC
338 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
339
340 #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
341   %{rdynamic:-export-dynamic} \
342   %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
343
344 #define LINK_OS_LINUX_SPEC64 "-m elf64ppc %{!shared: %{!static: \
345   %{rdynamic:-export-dynamic} \
346   %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
347
348 #undef  TOC_SECTION_ASM_OP
349 #define TOC_SECTION_ASM_OP \
350   (TARGET_64BIT                                         \
351    ? "\t.section\t\".toc\",\"aw\""                      \
352    : "\t.section\t\".got\",\"aw\"")
353
354 #undef  MINIMAL_TOC_SECTION_ASM_OP
355 #define MINIMAL_TOC_SECTION_ASM_OP \
356   (TARGET_64BIT                                         \
357    ? "\t.section\t\".toc1\",\"aw\""                     \
358    : ((TARGET_RELOCATABLE || flag_pic)                  \
359       ? "\t.section\t\".got2\",\"aw\""                  \
360       : "\t.section\t\".got1\",\"aw\""))
361
362 #undef  TARGET_VERSION
363 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
364
365 /* Must be at least as big as our pointer type.  */
366 #undef  SIZE_TYPE
367 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
368
369 #undef  PTRDIFF_TYPE
370 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
371
372 #undef  WCHAR_TYPE
373 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
374 #undef  WCHAR_TYPE_SIZE
375 #define WCHAR_TYPE_SIZE 32
376
377 /* Override rs6000.h definition.  */
378 #undef  ASM_APP_ON
379 #define ASM_APP_ON "#APP\n"
380
381 /* Override rs6000.h definition.  */
382 #undef  ASM_APP_OFF
383 #define ASM_APP_OFF "#NO_APP\n"
384
385 /* PowerPC no-op instruction.  */
386 #undef  RS6000_CALL_GLUE
387 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
388
389 #undef  RS6000_MCOUNT
390 #define RS6000_MCOUNT "_mcount"
391
392 #ifdef __powerpc64__
393 /* _init and _fini functions are built from bits spread across many
394    object files, each potentially with a different TOC pointer.  For
395    that reason, place a nop after the call so that the linker can
396    restore the TOC pointer if a TOC adjusting call stub is needed.  */
397 #if DOT_SYMBOLS
398 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)      \
399   asm (SECTION_OP "\n"                                  \
400 "       bl ." #FUNC "\n"                                \
401 "       nop\n"                                          \
402 "       .previous");
403 #else
404 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)      \
405   asm (SECTION_OP "\n"                                  \
406 "       bl " #FUNC "\n"                                 \
407 "       nop\n"                                          \
408 "       .previous");
409 #endif
410 #endif
411
412 /* FP save and restore routines.  */
413 #undef  SAVE_FP_PREFIX
414 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
415 #undef  SAVE_FP_SUFFIX
416 #define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
417 #undef  RESTORE_FP_PREFIX
418 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
419 #undef  RESTORE_FP_SUFFIX
420 #define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
421
422 /* Dwarf2 debugging.  */
423 #undef  PREFERRED_DEBUGGING_TYPE
424 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
425
426 /* This is how to declare the size of a function.  */
427 #undef  ASM_DECLARE_FUNCTION_SIZE
428 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
429   do                                                                    \
430     {                                                                   \
431       if (!flag_inhibit_size_directive)                                 \
432         {                                                               \
433           fputs ("\t.size\t", (FILE));                                  \
434           if (TARGET_64BIT && DOT_SYMBOLS)                              \
435             putc ('.', (FILE));                                         \
436           assemble_name ((FILE), (FNAME));                              \
437           fputs (",.-", (FILE));                                        \
438           rs6000_output_function_entry (FILE, FNAME);                   \
439           putc ('\n', (FILE));                                          \
440         }                                                               \
441     }                                                                   \
442   while (0)
443
444 /* Return nonzero if this entry is to be written into the constant
445    pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
446    or a CONST containing one of them.  If -mfp-in-toc (the default),
447    we also do this for floating-point constants.  We actually can only
448    do this if the FP formats of the target and host machines are the
449    same, but we can't check that since not every file that uses
450    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  We also do this when
451    we can write the entry into the TOC and the entry is not larger
452    than a TOC entry.  */
453
454 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
455 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)                        \
456   (TARGET_TOC                                                           \
457    && (GET_CODE (X) == SYMBOL_REF                                       \
458        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
459            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
460        || GET_CODE (X) == LABEL_REF                                     \
461        || (GET_CODE (X) == CONST_INT                                    \
462            && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
463        || (GET_CODE (X) == CONST_DOUBLE                                 \
464            && ((TARGET_64BIT                                            \
465                 && (TARGET_POWERPC64                                    \
466                     || TARGET_MINIMAL_TOC                               \
467                     || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT     \
468                         && ! TARGET_NO_FP_IN_TOC)))                     \
469                || (!TARGET_64BIT                                        \
470                    && !TARGET_NO_FP_IN_TOC                              \
471                    && !TARGET_RELOCATABLE                               \
472                    && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT       \
473                    && BITS_PER_WORD == HOST_BITS_PER_INT)))))
474
475 /* This is the same as the dbxelf.h version, except that we need to
476    use the function code label, not the function descriptor.  */
477 #undef  ASM_OUTPUT_SOURCE_LINE
478 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER)                     \
479 do                                                                      \
480   {                                                                     \
481     char temp[256];                                                     \
482     const char *s;                                                      \
483     ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER);                  \
484     fprintf (FILE, "\t.stabn 68,0,%d,", LINE);                          \
485     assemble_name (FILE, temp);                                         \
486     putc ('-', FILE);                                                   \
487     s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);           \
488     rs6000_output_function_entry (FILE, s);                             \
489     putc ('\n', FILE);                                                  \
490     (*targetm.asm_out.internal_label) (FILE, "LM", COUNTER);            \
491   }                                                                     \
492 while (0)
493
494 /* Similarly, we want the function code label here.  */
495 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
496   do                                                                    \
497     {                                                                   \
498       const char *s;                                                    \
499       fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC);                  \
500       assemble_name (FILE, NAME);                                       \
501       putc ('-', FILE);                                                 \
502       if (current_function_func_begin_label != NULL_TREE)               \
503         {                                                               \
504           s = IDENTIFIER_POINTER (current_function_func_begin_label);   \
505           assemble_name (FILE, s);                                      \
506         }                                                               \
507       else                                                              \
508         {                                                               \
509           s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);     \
510           rs6000_output_function_entry (FILE, s);                       \
511         }                                                               \
512       putc ('\n', FILE);                                                \
513     }                                                                   \
514   while (0)
515
516 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
517 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
518
519 /* Another case where we want the dot name.  */
520 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL)                             \
521   do                                                                    \
522     {                                                                   \
523       const char *s;                                                    \
524       fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);            \
525       assemble_name (FILE, LSCOPE);                                     \
526       putc ('-', FILE);                                                 \
527       s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);         \
528       rs6000_output_function_entry (FILE, s);                           \
529       putc ('\n', FILE);                                                \
530     }                                                                   \
531   while (0)
532
533 /* Select a format to encode pointers in exception handling data.  CODE
534    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
535    true if the symbol may be affected by dynamic relocations.  */
536 #undef  ASM_PREFERRED_EH_DATA_FORMAT
537 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
538   ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE)                     \
539    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel               \
540       | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4))             \
541    : DW_EH_PE_absptr)
542
543 /* For backward compatibility, we must continue to use the AIX
544    structure return convention.  */
545 #undef DRAFT_V4_STRUCT_RET
546 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
547
548 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
549
550 #define TARGET_HAS_F_SETLKW
551
552 #define LINK_GCC_C_SEQUENCE_SPEC \
553   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
554
555 /* Use --as-needed -lgcc_s for eh support.  */
556 #ifdef HAVE_LD_AS_NEEDED
557 #define USE_LD_AS_NEEDED 1
558 #endif
559
560 /* Do code reading to identify a signal frame, and set the frame
561    state data appropriately.  See unwind-dw2.c for the structs.  */
562
563 #ifdef IN_LIBGCC2
564 #include <signal.h>
565 #ifdef __powerpc64__
566 #include <sys/ucontext.h>
567
568 enum { SIGNAL_FRAMESIZE = 128 };
569
570 #else
571
572 /* During the 2.5 kernel series the kernel ucontext was changed, but
573    the new layout is compatible with the old one, so we just define
574    and use the old one here for simplicity and compatibility.  */
575
576 struct kernel_old_ucontext {
577   unsigned long     uc_flags;
578   struct ucontext  *uc_link;
579   stack_t           uc_stack;
580   struct sigcontext_struct uc_mcontext;
581   sigset_t          uc_sigmask;
582 };
583 enum { SIGNAL_FRAMESIZE = 64 };
584 #endif
585
586 #endif
587
588 #ifdef __powerpc64__
589
590 /* If the current unwind info (FS) does not contain explicit info
591    saving R2, then we have to do a minor amount of code reading to
592    figure out if it was saved.  The big problem here is that the
593    code that does the save/restore is generated by the linker, so
594    we have no good way to determine at compile time what to do.  */
595
596 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
597   do {                                                                  \
598     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
599       {                                                                 \
600         unsigned int *insn                                              \
601           = (unsigned int *)                                            \
602             _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
603         if (*insn == 0xE8410028)                                        \
604           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40);                 \
605       }                                                                 \
606   } while (0)
607
608 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
609   do {                                                                  \
610     unsigned char *pc_ = (CONTEXT)->ra;                                 \
611     struct sigcontext *sc_;                                             \
612     long new_cfa_;                                                      \
613     int i_;                                                             \
614                                                                         \
615     /* addi r1, r1, 128; li r0, 0x0077; sc  (sigreturn) */              \
616     /* addi r1, r1, 128; li r0, 0x00AC; sc  (rt_sigreturn) */           \
617     if (*(unsigned int *) (pc_+0) != 0x38210000 + SIGNAL_FRAMESIZE      \
618         || *(unsigned int *) (pc_+8) != 0x44000002)                     \
619       break;                                                            \
620     if (*(unsigned int *) (pc_+4) == 0x38000077)                        \
621       {                                                                 \
622         struct sigframe {                                               \
623           char gap[SIGNAL_FRAMESIZE];                                   \
624           struct sigcontext sigctx;                                     \
625         } *rt_ = (CONTEXT)->cfa;                                        \
626         sc_ = &rt_->sigctx;                                             \
627       }                                                                 \
628     else if (*(unsigned int *) (pc_+4) == 0x380000AC)                   \
629       {                                                                 \
630         struct rt_sigframe {                                            \
631           int tramp[6];                                                 \
632           struct siginfo *pinfo;                                        \
633           struct ucontext *puc;                                         \
634         } *rt_ = (struct rt_sigframe *) pc_;                            \
635         sc_ = &rt_->puc->uc_mcontext;                                   \
636       }                                                                 \
637     else                                                                \
638       break;                                                            \
639                                                                         \
640     new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM];                    \
641     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
642     (FS)->cfa_reg = STACK_POINTER_REGNUM;                               \
643     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
644                                                                         \
645     for (i_ = 0; i_ < 32; i_++)                                         \
646       if (i_ != STACK_POINTER_REGNUM)                                   \
647         {                                                               \
648           (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                    \
649           (FS)->regs.reg[i_].loc.offset                                 \
650             = (long)&(sc_->regs->gpr[i_]) - new_cfa_;                   \
651         }                                                               \
652                                                                         \
653     (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET;        \
654     (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset                     \
655       = (long)&(sc_->regs->link) - new_cfa_;                            \
656                                                                         \
657     (FS)->regs.reg[ARG_POINTER_REGNUM].how = REG_SAVED_OFFSET;          \
658     (FS)->regs.reg[ARG_POINTER_REGNUM].loc.offset                       \
659       = (long)&(sc_->regs->nip) - new_cfa_;                             \
660     (FS)->retaddr_column = ARG_POINTER_REGNUM;                          \
661     goto SUCCESS;                                                       \
662   } while (0)
663
664 #else
665
666 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
667   do {                                                                  \
668     unsigned char *pc_ = (CONTEXT)->ra;                                 \
669     struct sigcontext *sc_;                                             \
670     long new_cfa_;                                                      \
671     int i_;                                                             \
672                                                                         \
673     /* li r0, 0x7777; sc  (sigreturn old)  */                           \
674     /* li r0, 0x0077; sc  (sigreturn new)  */                           \
675     /* li r0, 0x6666; sc  (rt_sigreturn old)  */                        \
676     /* li r0, 0x00AC; sc  (rt_sigreturn new)  */                        \
677     if (*(unsigned int *) (pc_+4) != 0x44000002)                        \
678       break;                                                            \
679     if (*(unsigned int *) (pc_+0) == 0x38007777                         \
680         || *(unsigned int *) (pc_+0) == 0x38000077)                     \
681       {                                                                 \
682         struct sigframe {                                               \
683           char gap[SIGNAL_FRAMESIZE];                                   \
684           struct sigcontext sigctx;                                     \
685         } *rt_ = (CONTEXT)->cfa;                                        \
686         sc_ = &rt_->sigctx;                                             \
687       }                                                                 \
688     else if (*(unsigned int *) (pc_+0) == 0x38006666                    \
689              || *(unsigned int *) (pc_+0) == 0x380000AC)                \
690       {                                                                 \
691         struct rt_sigframe {                                            \
692           char gap[SIGNAL_FRAMESIZE];                                   \
693           unsigned long _unused[2];                                     \
694           struct siginfo *pinfo;                                        \
695           void *puc;                                                    \
696           struct siginfo info;                                          \
697           struct kernel_old_ucontext uc;                                \
698         } *rt_ = (CONTEXT)->cfa;                                        \
699         sc_ = &rt_->uc.uc_mcontext;                                     \
700       }                                                                 \
701     else                                                                \
702       break;                                                            \
703                                                                         \
704     new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM];                    \
705     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
706     (FS)->cfa_reg = STACK_POINTER_REGNUM;                               \
707     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
708                                                                         \
709     for (i_ = 0; i_ < 32; i_++)                                         \
710       if (i_ != STACK_POINTER_REGNUM)                                   \
711         {                                                               \
712           (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                    \
713           (FS)->regs.reg[i_].loc.offset                                 \
714             = (long)&(sc_->regs->gpr[i_]) - new_cfa_;                   \
715         }                                                               \
716                                                                         \
717     (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET;        \
718     (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset                     \
719       = (long)&(sc_->regs->link) - new_cfa_;                            \
720                                                                         \
721     (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET;                   \
722     (FS)->regs.reg[CR0_REGNO].loc.offset                                \
723       = (long)&(sc_->regs->nip) - new_cfa_;                             \
724     (FS)->retaddr_column = CR0_REGNO;                                   \
725     goto SUCCESS;                                                       \
726   } while (0)
727
728 #endif
729
730
731 #define OS_MISSING_POWERPC64 !TARGET_64BIT