OSDN Git Service

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