OSDN Git Service

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