Add AMD SSE5 support; Add iterator over function arguments; Add stdarg_p, prototype_p...
[official-gcc.git] / gcc / config / sparc / linux64.h
blob7bd49b560e75e010a8b9558351825f19e8bd5709
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 Contributed by David S. Miller (davem@caip.rutgers.edu)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 builtin_define_std ("unix"); \
26 builtin_define_std ("linux"); \
27 builtin_define ("_LONGLONG"); \
28 builtin_define ("__gnu_linux__"); \
29 builtin_assert ("system=linux"); \
30 builtin_assert ("system=unix"); \
31 builtin_assert ("system=posix"); \
32 if (TARGET_ARCH32 && TARGET_LONG_DOUBLE_128) \
33 builtin_define ("__LONG_DOUBLE_128__"); \
34 } \
35 while (0)
37 /* Don't assume anything about the header files. */
38 #define NO_IMPLICIT_EXTERN_C
40 #undef MD_EXEC_PREFIX
41 #undef MD_STARTFILE_PREFIX
43 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
44 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
45 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
46 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara
47 /* A 64 bit v9 compiler with stack-bias,
48 in a Medium/Low code model environment. */
50 #undef TARGET_DEFAULT
51 #define TARGET_DEFAULT \
52 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
53 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
54 #endif
56 #undef ASM_CPU_DEFAULT_SPEC
57 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
59 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
60 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
61 provides part of the support for getting C++ file-scope static
62 object constructed before entering `main'. */
64 #undef STARTFILE_SPEC
66 #ifdef HAVE_LD_PIE
67 #define STARTFILE_SPEC \
68 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
69 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
70 #else
71 #define STARTFILE_SPEC \
72 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
73 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
74 #endif
76 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
77 the GNU/Linux magical crtend.o file (see crtstuff.c) which
78 provides part of the support for getting C++ file-scope static
79 object constructed before entering `main', followed by a normal
80 GNU/Linux "finalizer" file, `crtn.o'. */
82 #undef ENDFILE_SPEC
84 #define ENDFILE_SPEC \
85 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
86 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
88 /* The GNU C++ standard library requires that these macros be defined. */
89 #undef CPLUSPLUS_CPP_SPEC
90 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
92 #undef TARGET_VERSION
93 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
95 /* The default code model. */
96 #undef SPARC_DEFAULT_CMODEL
97 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
99 #undef WCHAR_TYPE
100 #define WCHAR_TYPE "int"
102 #undef WCHAR_TYPE_SIZE
103 #define WCHAR_TYPE_SIZE 32
105 /* Define for support of TFmode long double.
106 SPARC ABI says that long double is 4 words. */
107 #undef LONG_DOUBLE_TYPE_SIZE
108 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
110 /* Define this to set long double type size to use in libgcc2.c, which can
111 not depend on target_flags. */
112 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
113 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
114 #else
115 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
116 #endif
118 #undef CPP_SUBTARGET_SPEC
119 #define CPP_SUBTARGET_SPEC "\
120 %{posix:-D_POSIX_SOURCE} \
121 %{pthread:-D_REENTRANT} \
124 #undef LIB_SPEC
125 #define LIB_SPEC \
126 "%{pthread:-lpthread} \
127 %{shared:-lc} \
128 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
130 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
131 for the special GCC options -static and -shared, which allow us to
132 link things in one of these three modes by applying the appropriate
133 combinations of options at link-time. We like to support here for
134 as many of the other GNU linker options as possible. But I don't
135 have the time to search for those flags. I am sure how to add
136 support for -soname shared_object_name. H.J.
138 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
139 -Wl,-V.
141 When the -shared link option is used a final link is not being
142 done. */
144 /* If ELF is the default format, we should not use /lib/elf. */
146 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
147 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
148 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
149 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
150 #if UCLIBC_DEFAULT
151 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
152 #else
153 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
154 #endif
155 #define LINUX_DYNAMIC_LINKER32 \
156 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
157 #define LINUX_DYNAMIC_LINKER64 \
158 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
160 #ifdef SPARC_BI_ARCH
162 #undef SUBTARGET_EXTRA_SPECS
163 #define SUBTARGET_EXTRA_SPECS \
164 { "link_arch32", LINK_ARCH32_SPEC }, \
165 { "link_arch64", LINK_ARCH64_SPEC }, \
166 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
167 { "link_arch", LINK_ARCH_SPEC },
169 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
170 %{!shared: \
171 %{!ibcs: \
172 %{!static: \
173 %{rdynamic:-export-dynamic} \
174 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \
175 %{static:-static}}} \
178 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
179 %{!shared: \
180 %{!ibcs: \
181 %{!static: \
182 %{rdynamic:-export-dynamic} \
183 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
184 %{static:-static}}} \
187 #define LINK_ARCH_SPEC "\
188 %{m32:%(link_arch32)} \
189 %{m64:%(link_arch64)} \
190 %{!m32:%{!m64:%(link_arch_default)}} \
193 #define LINK_ARCH_DEFAULT_SPEC \
194 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
196 #undef LINK_SPEC
197 #define LINK_SPEC "\
198 %(link_arch) \
199 %{mlittle-endian:-EL} \
200 %{!mno-relax:%{!r:-relax}} \
203 #undef CC1_SPEC
204 #if DEFAULT_ARCH32_P
205 #define CC1_SPEC "\
206 %{sun4:} %{target:} \
207 %{mcypress:-mcpu=cypress} \
208 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
209 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
210 %{m32:%{m64:%emay not use both -m32 and -m64}} \
211 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
212 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
213 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
215 #else
216 #define CC1_SPEC "\
217 %{sun4:} %{target:} \
218 %{mcypress:-mcpu=cypress} \
219 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
220 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
221 %{m32:%{m64:%emay not use both -m32 and -m64}} \
222 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
223 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
224 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
225 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
227 #endif
229 /* Support for a compile-time default CPU, et cetera. The rules are:
230 --with-cpu is ignored if -mcpu is specified.
231 --with-tune is ignored if -mtune is specified.
232 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
233 are specified.
234 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
235 here, otherwise say -mcpu=v7 would be passed even when -m64.
236 CC1_SPEC above takes care of this instead. */
237 #undef OPTION_DEFAULT_SPECS
238 #if DEFAULT_ARCH32_P
239 #define OPTION_DEFAULT_SPECS \
240 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
241 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
242 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
243 #else
244 #define OPTION_DEFAULT_SPECS \
245 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
246 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
247 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
248 #endif
250 #if DEFAULT_ARCH32_P
251 #define MULTILIB_DEFAULTS { "m32" }
252 #else
253 #define MULTILIB_DEFAULTS { "m64" }
254 #endif
256 #else /* !SPARC_BI_ARCH */
258 #undef LINK_SPEC
259 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
260 %{!shared: \
261 %{!ibcs: \
262 %{!static: \
263 %{rdynamic:-export-dynamic} \
264 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
265 %{static:-static}}} \
266 %{mlittle-endian:-EL} \
267 %{!mno-relax:%{!r:-relax}} \
270 #endif /* !SPARC_BI_ARCH */
272 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
273 It's safe to pass -s always, even if -g is not used. */
274 #undef ASM_SPEC
275 #define ASM_SPEC "\
276 %{V} \
277 %{v:%{!V:-V}} \
278 %{!Qn:-Qy} \
279 %{n} \
280 %{T} \
281 %{Ym,*} \
282 %{Wa,*:%*} \
283 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
284 %{mlittle-endian:-EL} \
285 %(asm_cpu) %(asm_arch) %(asm_relax)"
287 /* Same as sparc.h */
288 #undef DBX_REGISTER_NUMBER
289 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
291 #undef ASM_OUTPUT_ALIGNED_LOCAL
292 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
293 do { \
294 fputs ("\t.local\t", (FILE)); \
295 assemble_name ((FILE), (NAME)); \
296 putc ('\n', (FILE)); \
297 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
298 } while (0)
300 #undef COMMON_ASM_OP
301 #define COMMON_ASM_OP "\t.common\t"
303 #undef LOCAL_LABEL_PREFIX
304 #define LOCAL_LABEL_PREFIX "."
306 /* This is how to store into the string LABEL
307 the symbol_ref name of an internal numbered label where
308 PREFIX is the class of label and NUM is the number within the class.
309 This is suitable for output with `assemble_name'. */
311 #undef ASM_GENERATE_INTERNAL_LABEL
312 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
313 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
315 /* DWARF bits. */
317 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
318 Obviously the Dwarf2 folks haven't tried to actually build systems
319 with their spec. On a 64-bit system, only 64-bit relocs become
320 RELATIVE relocations. */
322 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
324 #undef DITF_CONVERSION_LIBFUNCS
325 #define DITF_CONVERSION_LIBFUNCS 1
327 #if defined(HAVE_LD_EH_FRAME_HDR)
328 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
329 #endif
331 #ifdef HAVE_AS_TLS
332 #undef TARGET_SUN_TLS
333 #undef TARGET_GNU_TLS
334 #define TARGET_SUN_TLS 0
335 #define TARGET_GNU_TLS 1
336 #endif
338 /* Don't be different from other Linux platforms in this regard. */
339 #define HANDLE_PRAGMA_PACK_PUSH_POP
341 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
342 #undef CTORS_SECTION_ASM_OP
343 #undef DTORS_SECTION_ASM_OP
345 /* Determine whether the entire c99 runtime is present in the
346 runtime library. */
347 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
349 /* Whether we have sincos that follows the GNU extension. */
350 #define TARGET_HAS_SINCOS (OPTION_GLIBC)
352 #define TARGET_POSIX_IO
354 #undef LINK_GCC_C_SEQUENCE_SPEC
355 #define LINK_GCC_C_SEQUENCE_SPEC \
356 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
358 /* Use --as-needed -lgcc_s for eh support. */
359 #ifdef HAVE_LD_AS_NEEDED
360 #define USE_LD_AS_NEEDED 1
361 #endif
363 #define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h"
365 /* Linux currently uses RMO in uniprocessor mode, which is equivalent to
366 TMO, and TMO in multiprocessor mode. But they reserve the right to
367 change their minds. */
368 #undef SPARC_RELAXED_ORDERING
369 #define SPARC_RELAXED_ORDERING true
371 #undef NEED_INDICATE_EXEC_STACK
372 #define NEED_INDICATE_EXEC_STACK 1
374 #ifdef TARGET_LIBC_PROVIDES_SSP
375 /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
376 sparc64 glibc provides it at [%g7 + 0x28]. */
377 #define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
378 #endif
380 /* Define if long doubles should be mangled as 'g'. */
381 #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING