OSDN Git Service

* config/rs6000/linux64.h (DBX_OUTPUT_BRAC): Define.
[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 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Yes!  We are AIX! Err. Wait. We're Linux!. No, wait, we're a
23   combo of both!*/
24 #undef  DEFAULT_ABI
25 #define DEFAULT_ABI ABI_AIX
26
27 #undef TARGET_AIX
28 #define TARGET_AIX 1
29
30 #undef TARGET_DEFAULT
31 #define TARGET_DEFAULT \
32   (MASK_POWERPC | MASK_POWERPC64 | MASK_64BIT | MASK_NEW_MNEMONICS)
33
34 #undef PROCESSOR_DEFAULT
35 #define PROCESSOR_DEFAULT PROCESSOR_PPC630
36 #undef PROCESSOR_DEFAULT64
37 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
38
39 #undef  ASM_DEFAULT_SPEC
40 #define ASM_DEFAULT_SPEC "-mppc64"
41
42 #undef  ASM_SPEC
43 #define ASM_SPEC "%{.s: %{mregnames} %{mno-regnames}} \
44 %{.S: %{mregnames} %{mno-regnames}} \
45 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \
46 %{v:-V} %{Qy:} %{!Qn:-Qy} -a64 %(asm_cpu) %{Wa,*:%*}"
47
48 /* 64-bit PowerPC Linux always has a TOC.  */
49 #undef  TARGET_NO_TOC
50 #define TARGET_NO_TOC           0
51 #undef  TARGET_TOC
52 #define TARGET_TOC              1
53
54 /* We use glibc _mcount for profiling.  */
55 #define NO_PROFILE_COUNTERS 1
56 #undef  PROFILE_BEFORE_PROLOGUE
57
58 /* Define this for kernel profiling, which just saves LR then calls
59    _mcount without worrying about arg saves.  The idea is to change
60    the function prologue as little as possible as it isn't easy to
61    account for arg save/restore code added just for _mcount.  */
62 /* #define PROFILE_KERNEL 1 */
63 #if PROFILE_KERNEL
64 #define PROFILE_BEFORE_PROLOGUE 1
65 #undef  PROFILE_HOOK
66 #else
67 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
68 #endif
69
70 /* We don't need to generate entries in .fixup.  */
71 #undef RELOCATABLE_NEEDS_FIXUP
72
73 #define USER_LABEL_PREFIX  ""
74
75 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
76 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
77   (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
78               ? get_inner_array_type (FIELD) \
79               : TREE_TYPE (FIELD)) == DFmode \
80    ? MIN ((COMPUTED), 32) : (COMPUTED))
81
82 /* AIX increases natural record alignment to doubleword if the first
83    field is an FP double while the FP fields remain word aligned.  */
84 #undef ROUND_TYPE_ALIGN
85 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)   \
86   ((TREE_CODE (STRUCT) == RECORD_TYPE                   \
87     || TREE_CODE (STRUCT) == UNION_TYPE                 \
88     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)           \
89    && TYPE_FIELDS (STRUCT) != 0                         \
90    && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode        \
91    ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64)            \
92    : MAX ((COMPUTED), (SPECIFIED)))
93
94 /* Indicate that jump tables go in the text section.  */
95 #undef  JUMP_TABLES_IN_TEXT_SECTION
96 #define JUMP_TABLES_IN_TEXT_SECTION 1
97
98 /* 64-bit PowerPC Linux always has GPR13 fixed.  */
99 #define FIXED_R13               1
100
101 /* __throw will restore its own return address to be the same as the
102    return address of the function that the throw is being made to.
103    This is unfortunate, because we want to check the original
104    return address to see if we need to restore the TOC.
105    So we have to squirrel it away with this.  */
106 #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
107
108 /* Don't assume anything about the header files.  */
109 #define NO_IMPLICIT_EXTERN_C
110
111 /* Override svr4.h  */
112 #undef MD_EXEC_PREFIX
113 #undef MD_STARTFILE_PREFIX
114
115 #undef TARGET_OS_CPP_BUILTINS
116 #define TARGET_OS_CPP_BUILTINS()            \
117   do                                        \
118     {                                       \
119       builtin_define ("__PPC__");           \
120       builtin_define ("__PPC64__");         \
121       builtin_define ("__powerpc__");       \
122       builtin_define ("__powerpc64__");     \
123       builtin_define ("__PIC__");           \
124       builtin_define ("__ELF__");           \
125       builtin_assert ("cpu=powerpc64");     \
126       builtin_assert ("machine=powerpc64"); \
127     }                                       \
128   while (0)
129
130 #undef  CPP_OS_DEFAULT_SPEC
131 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
132
133 /* The GNU C++ standard library currently requires _GNU_SOURCE being
134    defined on glibc-based systems. This temporary hack accomplishes this,
135    it should go away as soon as libstdc++-v3 has a real fix.  */
136 #undef  CPLUSPLUS_CPP_SPEC
137 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
138
139 #undef  LINK_SHLIB_SPEC
140 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
141
142 #undef  LIB_DEFAULT_SPEC
143 #define LIB_DEFAULT_SPEC "%(lib_linux)"
144
145 #undef  STARTFILE_DEFAULT_SPEC
146 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
147
148 #undef  ENDFILE_DEFAULT_SPEC
149 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
150
151 #undef  LINK_START_DEFAULT_SPEC
152 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
153
154 #undef  LINK_OS_DEFAULT_SPEC
155 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
156
157 #undef  LINK_OS_LINUX_SPEC
158 #define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
159   %{rdynamic:-export-dynamic} \
160   %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
161
162 #ifdef NATIVE_CROSS
163 #define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/"
164 #endif
165
166 #undef  STARTFILE_LINUX_SPEC
167 #define STARTFILE_LINUX_SPEC "\
168 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \
169 %{static:crtbeginT.o%s} \
170 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
171
172 #undef  ENDFILE_LINUX_SPEC
173 #define ENDFILE_LINUX_SPEC "\
174 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
175
176 #undef  TOC_SECTION_ASM_OP
177 #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
178
179 #undef  MINIMAL_TOC_SECTION_ASM_OP
180 #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\""
181
182 #undef  TARGET_VERSION
183 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
184
185 /* Must be at least as big as our pointer type.  */
186 #undef  SIZE_TYPE
187 #define SIZE_TYPE "long unsigned int"
188
189 #undef  PTRDIFF_TYPE
190 #define PTRDIFF_TYPE "long int"
191
192 #undef  WCHAR_TYPE
193 #define WCHAR_TYPE "int"
194 #undef  WCHAR_TYPE_SIZE
195 #define WCHAR_TYPE_SIZE 32
196
197 /* Override rs6000.h definition.  */
198 #undef  ASM_APP_ON
199 #define ASM_APP_ON "#APP\n"
200
201 /* Override rs6000.h definition.  */
202 #undef  ASM_APP_OFF
203 #define ASM_APP_OFF "#NO_APP\n"
204
205 /* PowerPC no-op instruction.  */
206 #undef  RS6000_CALL_GLUE
207 #define RS6000_CALL_GLUE "nop"
208
209 #undef  RS6000_MCOUNT
210 #define RS6000_MCOUNT "_mcount"
211
212 /* FP save and restore routines.  */
213 #undef  SAVE_FP_PREFIX
214 #define SAVE_FP_PREFIX "._savef"
215 #undef  SAVE_FP_SUFFIX
216 #define SAVE_FP_SUFFIX ""
217 #undef  RESTORE_FP_PREFIX
218 #define RESTORE_FP_PREFIX "._restf"
219 #undef  RESTORE_FP_SUFFIX
220 #define RESTORE_FP_SUFFIX ""
221
222 /* Dwarf2 debugging.  */
223 #undef  PREFERRED_DEBUGGING_TYPE
224 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
225
226 #undef  TARGET_ENCODE_SECTION_INFO
227 #define TARGET_ENCODE_SECTION_INFO  rs6000_xcoff_encode_section_info
228
229 /* This is how to output a reference to a user-level label named NAME.
230    `assemble_name' uses this.  */
231
232 /* Override elfos.h definition.  */
233 #undef  ASM_OUTPUT_LABELREF
234 #define ASM_OUTPUT_LABELREF(FILE,NAME)          \
235 do {                                            \
236   const char *_name = NAME;                     \
237   if (*_name == '@')                            \
238     _name++;                                    \
239                                                 \
240   if (*_name == '*')                            \
241     fprintf (FILE, "%s", _name + 1);            \
242   else                                          \
243     asm_fprintf (FILE, "%U%s", _name);          \
244 } while (0)
245
246 #undef  ASM_DECLARE_FUNCTION_NAME
247 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
248   do                                                                    \
249     {                                                                   \
250       fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE));      \
251       ASM_OUTPUT_LABEL ((FILE), (NAME));                                \
252       fputs (DOUBLE_INT_ASM_OP, (FILE));                                \
253       putc ('.', (FILE));                                               \
254       assemble_name ((FILE), (NAME));                                   \
255       fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE));       \
256       assemble_name ((FILE), (NAME));                                   \
257       fputs (",24\n\t.type\t.", (FILE));                                \
258       assemble_name ((FILE), (NAME));                                   \
259       fputs (",@function\n", (FILE));                                   \
260       if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL))                     \
261         {                                                               \
262           fputs ("\t.globl\t.", (FILE));                                \
263           assemble_name ((FILE), (NAME));                               \
264           putc ('\n', (FILE));                                          \
265         }                                                               \
266       ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL));                  \
267       putc ('.', (FILE));                                               \
268       ASM_OUTPUT_LABEL ((FILE), (NAME));                                \
269     }                                                                   \
270   while (0)
271
272 /* This is how to declare the size of a function.  */
273 #undef  ASM_DECLARE_FUNCTION_SIZE
274 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
275   do                                                                    \
276     {                                                                   \
277       if (!flag_inhibit_size_directive)                                 \
278         {                                                               \
279           fputs ("\t.size\t.", (FILE));                                 \
280           assemble_name ((FILE), (FNAME));                              \
281           fputs (",.-.", (FILE));                                       \
282           assemble_name ((FILE), (FNAME));                              \
283           putc ('\n', (FILE));                                          \
284         }                                                               \
285     }                                                                   \
286   while (0)
287
288 /* Return non-zero if this entry is to be written into the constant
289    pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
290    or a CONST containing one of them.  If -mfp-in-toc (the default),
291    we also do this for floating-point constants.  We actually can only
292    do this if the FP formats of the target and host machines are the
293    same, but we can't check that since not every file that uses
294    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  We also do this when
295    we can write the entry into the TOC and the entry is not larger
296    than a TOC entry.  */
297
298 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
299 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)                        \
300   (TARGET_TOC                                                           \
301    && (GET_CODE (X) == SYMBOL_REF                                       \
302        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
303            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
304        || GET_CODE (X) == LABEL_REF                                     \
305        || (GET_CODE (X) == CONST_INT                                    \
306            && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
307        || (GET_CODE (X) == CONST_DOUBLE                                 \
308            && (TARGET_POWERPC64                                         \
309                || TARGET_MINIMAL_TOC                                    \
310                || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT          \
311                    && ! TARGET_NO_FP_IN_TOC)))))
312
313 /* This is the same as the dbxelf.h version, except that we need to
314    use the function code label, not the function descriptor.  */
315 #undef  ASM_OUTPUT_SOURCE_LINE
316 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE)                              \
317 do                                                                      \
318   {                                                                     \
319     static int sym_lineno = 1;                                          \
320     char temp[256];                                                     \
321     ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno);               \
322     fprintf (FILE, "\t.stabn 68,0,%d,", LINE);                          \
323     assemble_name (FILE, temp);                                         \
324     fputs ("-.", FILE);                                                 \
325     assemble_name (FILE,                                                \
326                    XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
327     putc ('\n', FILE);                                                  \
328     ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno);                 \
329     sym_lineno += 1;                                                    \
330   }                                                                     \
331 while (0)
332
333 /* Similarly, we want the function code label here.  */
334 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
335   do                                                                    \
336     {                                                                   \
337       const char *flab;                                                 \
338       fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC);                  \
339       assemble_name (FILE, NAME);                                       \
340       putc ('-', FILE);                                                 \
341       if (current_function_func_begin_label != NULL_TREE)               \
342         flab = IDENTIFIER_POINTER (current_function_func_begin_label);  \
343       else                                                              \
344         {                                                               \
345           putc ('.', FILE);                                             \
346           flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);  \
347         }                                                               \
348       assemble_name (FILE, flab);                                       \
349       putc ('\n', FILE);                                                \
350     }                                                                   \
351   while (0)
352
353 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
354 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
355
356 /* Override sysv4.h as these are ABI_V4 only.  */
357 #undef  ASM_OUTPUT_REG_PUSH
358 #undef  ASM_OUTPUT_REG_POP