OSDN Git Service

Replace "GNU CC" with "GCC"
[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 /* 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 /* This is always a 64 bit compiler.  */
49 #undef  TARGET_64BIT
50 #define TARGET_64BIT            1
51
52 /* 64-bit PowerPC Linux always has a TOC.  */
53 #undef  TARGET_NO_TOC
54 #define TARGET_NO_TOC           0
55 #undef  TARGET_TOC
56 #define TARGET_TOC              1
57
58 /* Some things from sysv4.h we don't do.  */
59 #undef  TARGET_RELOCATABLE
60 #define TARGET_RELOCATABLE      0
61 #undef  TARGET_EABI
62 #define TARGET_EABI             0
63 #undef  TARGET_PROTOTYPE
64 #define TARGET_PROTOTYPE        0
65
66 /* Reuse sysv4 mask bits we made available above.  */
67 #define MASK_PROFILE_KERNEL     0x08000000
68
69 /* Non-standard profiling for kernels, which just saves LR then calls
70    _mcount without worrying about arg saves.  The idea is to change
71    the function prologue as little as possible as it isn't easy to
72    account for arg save/restore code added just for _mcount.  */
73 #define TARGET_PROFILE_KERNEL   (target_flags & MASK_PROFILE_KERNEL)
74
75 /* Override sysv4.h.  */
76 #undef  SUBTARGET_SWITCHES
77 #define SUBTARGET_SWITCHES                                              \
78   {"bit-align", -MASK_NO_BITFIELD_TYPE,                                 \
79     N_("Align to the base type of the bit-field") },                    \
80   {"no-bit-align",       MASK_NO_BITFIELD_TYPE,                         \
81     N_("Don't align to the base type of the bit-field") },              \
82   {"strict-align",       MASK_STRICT_ALIGN,                             \
83     N_("Don't assume that unaligned accesses are handled by the system") }, \
84   {"no-strict-align",   -MASK_STRICT_ALIGN,                             \
85     N_("Assume that unaligned accesses are handled by the system") },   \
86   {"little-endian",      MASK_LITTLE_ENDIAN,                            \
87     N_("Produce little endian code") },                                 \
88   {"little",             MASK_LITTLE_ENDIAN,                            \
89     N_("Produce little endian code") },                                 \
90   {"big-endian",        -MASK_LITTLE_ENDIAN,                            \
91     N_("Produce big endian code") },                                    \
92   {"big",               -MASK_LITTLE_ENDIAN,                            \
93     N_("Produce big endian code") },                                    \
94   {"bit-word",          -MASK_NO_BITFIELD_WORD,                         \
95     N_("Allow bit-fields to cross word boundaries") },                  \
96   {"no-bit-word",        MASK_NO_BITFIELD_WORD,                         \
97     N_("Do not allow bit-fields to cross word boundaries") },           \
98   {"regnames",           MASK_REGNAMES,                                 \
99     N_("Use alternate register names") },                               \
100   {"no-regnames",       -MASK_REGNAMES,                                 \
101     N_("Don't use alternate register names") },                         \
102   {"profile-kernel",     MASK_PROFILE_KERNEL,                           \
103    N_("Call mcount for profiling before a function prologue") },        \
104   {"no-profile-kernel", -MASK_PROFILE_KERNEL,                           \
105    N_("Call mcount for profiling after a function prologue") },
106
107 #undef  SUBTARGET_OPTIONS
108 #define SUBTARGET_OPTIONS
109
110 #undef  SUBTARGET_OVERRIDE_OPTIONS
111 #define SUBTARGET_OVERRIDE_OPTIONS {}
112
113 /* We use glibc _mcount for profiling.  */
114 #define NO_PROFILE_COUNTERS 1
115 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
116
117 /* We don't need to generate entries in .fixup.  */
118 #undef RELOCATABLE_NEEDS_FIXUP
119
120 #define USER_LABEL_PREFIX  ""
121
122 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
123 #undef  ADJUST_FIELD_ALIGN
124 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
125   (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
126               ? get_inner_array_type (FIELD) \
127               : TREE_TYPE (FIELD)) == DFmode \
128    ? MIN ((COMPUTED), 32) : (COMPUTED))
129
130 /* AIX increases natural record alignment to doubleword if the first
131    field is an FP double while the FP fields remain word aligned.  */
132 #undef  ROUND_TYPE_ALIGN
133 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)   \
134   ((TREE_CODE (STRUCT) == RECORD_TYPE                   \
135     || TREE_CODE (STRUCT) == UNION_TYPE                 \
136     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)           \
137    && TYPE_FIELDS (STRUCT) != 0                         \
138    && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode        \
139    ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64)            \
140    : MAX ((COMPUTED), (SPECIFIED)))
141
142 /* Indicate that jump tables go in the text section.  */
143 #undef  JUMP_TABLES_IN_TEXT_SECTION
144 #define JUMP_TABLES_IN_TEXT_SECTION 1
145
146 /* 64-bit PowerPC Linux always has GPR13 fixed.  */
147 #define FIXED_R13               1
148
149 /* __throw will restore its own return address to be the same as the
150    return address of the function that the throw is being made to.
151    This is unfortunate, because we want to check the original
152    return address to see if we need to restore the TOC.
153    So we have to squirrel it away with this.  */
154 #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
155
156 /* Override svr4.h  */
157 #undef MD_EXEC_PREFIX
158 #undef MD_STARTFILE_PREFIX
159
160 /* Override sysv4.h  */
161 #undef  CPP_SYSV_SPEC
162 #define CPP_SYSV_SPEC ""
163
164 #undef  TARGET_OS_CPP_BUILTINS
165 #define TARGET_OS_CPP_BUILTINS()            \
166   do                                        \
167     {                                       \
168       builtin_define ("__PPC__");           \
169       builtin_define ("__PPC64__");         \
170       builtin_define ("__powerpc__");       \
171       builtin_define ("__powerpc64__");     \
172       builtin_define ("__PIC__");           \
173       builtin_define ("__ELF__");           \
174       builtin_assert ("cpu=powerpc64");     \
175       builtin_assert ("machine=powerpc64"); \
176     }                                       \
177   while (0)
178
179 #undef  CPP_OS_DEFAULT_SPEC
180 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
181
182 /* The GNU C++ standard library currently requires _GNU_SOURCE being
183    defined on glibc-based systems. This temporary hack accomplishes this,
184    it should go away as soon as libstdc++-v3 has a real fix.  */
185 #undef  CPLUSPLUS_CPP_SPEC
186 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
187
188 #undef  LINK_SHLIB_SPEC
189 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
190
191 #undef  LIB_DEFAULT_SPEC
192 #define LIB_DEFAULT_SPEC "%(lib_linux)"
193
194 #undef  STARTFILE_DEFAULT_SPEC
195 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
196
197 #undef  ENDFILE_DEFAULT_SPEC
198 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
199
200 #undef  LINK_START_DEFAULT_SPEC
201 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
202
203 #undef  LINK_OS_DEFAULT_SPEC
204 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
205
206 #undef  LINK_OS_LINUX_SPEC
207 #define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
208   %{rdynamic:-export-dynamic} \
209   %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
210
211 #ifdef NATIVE_CROSS
212 #define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/"
213 #endif
214
215 #undef  STARTFILE_LINUX_SPEC
216 #define STARTFILE_LINUX_SPEC "\
217 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \
218 %{static:crtbeginT.o%s} \
219 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
220
221 #undef  ENDFILE_LINUX_SPEC
222 #define ENDFILE_LINUX_SPEC "\
223 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
224
225 #undef  TOC_SECTION_ASM_OP
226 #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
227
228 #undef  MINIMAL_TOC_SECTION_ASM_OP
229 #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\""
230
231 #undef  TARGET_VERSION
232 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
233
234 /* Must be at least as big as our pointer type.  */
235 #undef  SIZE_TYPE
236 #define SIZE_TYPE "long unsigned int"
237
238 #undef  PTRDIFF_TYPE
239 #define PTRDIFF_TYPE "long int"
240
241 #undef  WCHAR_TYPE
242 #define WCHAR_TYPE "int"
243 #undef  WCHAR_TYPE_SIZE
244 #define WCHAR_TYPE_SIZE 32
245
246 /* Override rs6000.h definition.  */
247 #undef  ASM_APP_ON
248 #define ASM_APP_ON "#APP\n"
249
250 /* Override rs6000.h definition.  */
251 #undef  ASM_APP_OFF
252 #define ASM_APP_OFF "#NO_APP\n"
253
254 /* PowerPC no-op instruction.  */
255 #undef  RS6000_CALL_GLUE
256 #define RS6000_CALL_GLUE "nop"
257
258 #undef  RS6000_MCOUNT
259 #define RS6000_MCOUNT "_mcount"
260
261 /* FP save and restore routines.  */
262 #undef  SAVE_FP_PREFIX
263 #define SAVE_FP_PREFIX "._savef"
264 #undef  SAVE_FP_SUFFIX
265 #define SAVE_FP_SUFFIX ""
266 #undef  RESTORE_FP_PREFIX
267 #define RESTORE_FP_PREFIX "._restf"
268 #undef  RESTORE_FP_SUFFIX
269 #define RESTORE_FP_SUFFIX ""
270
271 /* Dwarf2 debugging.  */
272 #undef  PREFERRED_DEBUGGING_TYPE
273 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
274
275 /* This is how to output a reference to a user-level label named NAME.
276    `assemble_name' uses this.  */
277
278 /* Override elfos.h definition.  */
279 #undef  ASM_OUTPUT_LABELREF
280 #define ASM_OUTPUT_LABELREF(FILE,NAME)          \
281 do {                                            \
282   const char *_name = NAME;                     \
283   if (*_name == '@')                            \
284     _name++;                                    \
285                                                 \
286   if (*_name == '*')                            \
287     fprintf (FILE, "%s", _name + 1);            \
288   else                                          \
289     asm_fprintf (FILE, "%U%s", _name);          \
290 } while (0)
291
292 #undef  ASM_DECLARE_FUNCTION_NAME
293 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
294   do                                                                    \
295     {                                                                   \
296       fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE));      \
297       ASM_OUTPUT_LABEL ((FILE), (NAME));                                \
298       fputs (DOUBLE_INT_ASM_OP, (FILE));                                \
299       putc ('.', (FILE));                                               \
300       assemble_name ((FILE), (NAME));                                   \
301       fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE));       \
302       assemble_name ((FILE), (NAME));                                   \
303       fputs (",24\n\t.type\t.", (FILE));                                \
304       assemble_name ((FILE), (NAME));                                   \
305       fputs (",@function\n", (FILE));                                   \
306       if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL))                     \
307         {                                                               \
308           fputs ("\t.globl\t.", (FILE));                                \
309           assemble_name ((FILE), (NAME));                               \
310           putc ('\n', (FILE));                                          \
311         }                                                               \
312       ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL));                  \
313       putc ('.', (FILE));                                               \
314       ASM_OUTPUT_LABEL ((FILE), (NAME));                                \
315     }                                                                   \
316   while (0)
317
318 /* This is how to declare the size of a function.  */
319 #undef  ASM_DECLARE_FUNCTION_SIZE
320 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
321   do                                                                    \
322     {                                                                   \
323       if (!flag_inhibit_size_directive)                                 \
324         {                                                               \
325           fputs ("\t.size\t.", (FILE));                                 \
326           assemble_name ((FILE), (FNAME));                              \
327           fputs (",.-.", (FILE));                                       \
328           assemble_name ((FILE), (FNAME));                              \
329           putc ('\n', (FILE));                                          \
330         }                                                               \
331     }                                                                   \
332   while (0)
333
334 /* Return nonzero if this entry is to be written into the constant
335    pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
336    or a CONST containing one of them.  If -mfp-in-toc (the default),
337    we also do this for floating-point constants.  We actually can only
338    do this if the FP formats of the target and host machines are the
339    same, but we can't check that since not every file that uses
340    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  We also do this when
341    we can write the entry into the TOC and the entry is not larger
342    than a TOC entry.  */
343
344 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
345 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)                        \
346   (TARGET_TOC                                                           \
347    && (GET_CODE (X) == SYMBOL_REF                                       \
348        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
349            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
350        || GET_CODE (X) == LABEL_REF                                     \
351        || (GET_CODE (X) == CONST_INT                                    \
352            && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
353        || (GET_CODE (X) == CONST_DOUBLE                                 \
354            && (TARGET_POWERPC64                                         \
355                || TARGET_MINIMAL_TOC                                    \
356                || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT          \
357                    && ! TARGET_NO_FP_IN_TOC)))))
358
359 /* This is the same as the dbxelf.h version, except that we need to
360    use the function code label, not the function descriptor.  */
361 #undef  ASM_OUTPUT_SOURCE_LINE
362 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE)                              \
363 do                                                                      \
364   {                                                                     \
365     static int sym_lineno = 1;                                          \
366     char temp[256];                                                     \
367     ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno);               \
368     fprintf (FILE, "\t.stabn 68,0,%d,", LINE);                          \
369     assemble_name (FILE, temp);                                         \
370     fputs ("-.", FILE);                                                 \
371     assemble_name (FILE,                                                \
372                    XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
373     putc ('\n', FILE);                                                  \
374     (*targetm.asm_out.internal_label) (FILE, "LM", sym_lineno);         \
375     sym_lineno += 1;                                                    \
376   }                                                                     \
377 while (0)
378
379 /* Similarly, we want the function code label here.  */
380 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
381   do                                                                    \
382     {                                                                   \
383       const char *flab;                                                 \
384       fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC);                  \
385       assemble_name (FILE, NAME);                                       \
386       putc ('-', FILE);                                                 \
387       if (current_function_func_begin_label != NULL_TREE)               \
388         flab = IDENTIFIER_POINTER (current_function_func_begin_label);  \
389       else                                                              \
390         {                                                               \
391           putc ('.', FILE);                                             \
392           flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);  \
393         }                                                               \
394       assemble_name (FILE, flab);                                       \
395       putc ('\n', FILE);                                                \
396     }                                                                   \
397   while (0)
398
399 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
400 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
401
402 /* Another case where we want the dot name.  */
403 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL)                             \
404   do                                                                    \
405     {                                                                   \
406       fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);            \
407       assemble_name (FILE, LSCOPE);                                     \
408       fputs ("-.", FILE);                                               \
409       assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0));        \
410       putc ('\n', FILE);                                                \
411     }                                                                   \
412   while (0)
413
414 /* Override sysv4.h as these are ABI_V4 only.  */
415 #undef  ASM_OUTPUT_REG_PUSH
416 #undef  ASM_OUTPUT_REG_POP
417
418 /* Select a format to encode pointers in exception handling data.  CODE
419    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
420    true if the symbol may be affected by dynamic relocations.  */
421 #undef  ASM_PREFERRED_EH_DATA_FORMAT
422 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
423   (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_udata8)