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, 2008,
3 2009, 2010, 2011 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)
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() \
25 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
27 builtin_define ("_LONGLONG"); \
29 && TARGET_LONG_DOUBLE_128) \
30 builtin_define ("__LONG_DOUBLE_128__"); \
34 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
35 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
36 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
37 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara \
38 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara2 \
39 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara3 \
40 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara4
41 /* A 64 bit v9 compiler with stack-bias,
42 in a Medium/Low code model environment. */
45 #define TARGET_DEFAULT \
46 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
47 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
50 /* This must be v9a not just v9 because by default we enable
52 #undef ASM_CPU64_DEFAULT_SPEC
53 #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
55 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
56 the GNU/Linux magical crtend.o file (see crtstuff.c) which
57 provides part of the support for getting C++ file-scope static
58 object constructed before entering `main', followed by a normal
59 GNU/Linux "finalizer" file, `crtn.o'. */
62 #define ENDFILE_SPEC \
63 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
64 %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
66 /* The default code model. */
67 #undef SPARC_DEFAULT_CMODEL
68 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
71 #define WCHAR_TYPE "int"
73 #undef WCHAR_TYPE_SIZE
74 #define WCHAR_TYPE_SIZE 32
76 /* Define for support of TFmode long double.
77 SPARC ABI says that long double is 4 words. */
78 #undef LONG_DOUBLE_TYPE_SIZE
79 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
81 /* Define this to set long double type size to use in libgcc2.c, which can
82 not depend on target_flags. */
83 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
84 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
86 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
89 #undef CPP_SUBTARGET_SPEC
90 #define CPP_SUBTARGET_SPEC "\
91 %{posix:-D_POSIX_SOURCE} \
92 %{pthread:-D_REENTRANT} \
95 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
96 for the special GCC options -static and -shared, which allow us to
97 link things in one of these three modes by applying the appropriate
98 combinations of options at link-time.
100 When the -shared link option is used a final link is not being
103 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
104 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
108 #undef SUBTARGET_EXTRA_SPECS
109 #define SUBTARGET_EXTRA_SPECS \
110 { "link_arch32", LINK_ARCH32_SPEC }, \
111 { "link_arch64", LINK_ARCH64_SPEC }, \
112 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
113 { "link_arch", LINK_ARCH_SPEC },
115 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,%R/usr/lib %{shared:-shared} \
118 %{rdynamic:-export-dynamic} \
119 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
123 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
126 %{rdynamic:-export-dynamic} \
127 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
131 #define LINK_ARCH_SPEC "\
132 %{m32:%(link_arch32)} \
133 %{m64:%(link_arch64)} \
134 %{!m32:%{!m64:%(link_arch_default)}} \
137 #define LINK_ARCH_DEFAULT_SPEC \
138 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
143 %{mlittle-endian:-EL} \
144 %{!mno-relax:%{!r:-relax}} \
147 /* -mcpu=native handling only makes sense with compiler running on
149 #if defined(__sparc__)
150 extern const char *host_detect_local_cpu (int argc
, const char **argv
);
151 # define EXTRA_SPEC_FUNCTIONS \
152 { "local_cpu_detect", host_detect_local_cpu },
154 # define MCPU_MTUNE_NATIVE_SPECS \
155 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
156 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
158 # define MCPU_MTUNE_NATIVE_SPECS ""
161 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
165 #define CC1_SPEC "%{profile:-p} \
166 %{m32:%{m64:%emay not use both -m32 and -m64}} \
167 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
168 %{!mcpu*:-mcpu=ultrasparc} \
169 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
172 #define CC1_SPEC "%{profile:-p} \
173 %{m32:%{m64:%emay not use both -m32 and -m64}} \
174 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
175 %{!mcpu*:-mcpu=cypress}} \
176 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
177 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
181 /* Support for a compile-time default CPU, et cetera. The rules are:
182 --with-cpu is ignored if -mcpu is specified.
183 --with-tune is ignored if -mtune is specified.
184 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
186 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
187 here, otherwise say -mcpu=v7 would be passed even when -m64.
188 CC1_SPEC above takes care of this instead. */
189 #undef OPTION_DEFAULT_SPECS
191 #define OPTION_DEFAULT_SPECS \
192 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
193 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
194 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
196 #define OPTION_DEFAULT_SPECS \
197 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
198 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
199 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
203 #define MULTILIB_DEFAULTS { "m32" }
205 #define MULTILIB_DEFAULTS { "m64" }
208 #else /* !SPARC_BI_ARCH */
211 #define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
214 %{rdynamic:-export-dynamic} \
215 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
217 %{mlittle-endian:-EL} \
218 %{!mno-relax:%{!r:-relax}} \
221 #endif /* !SPARC_BI_ARCH */
223 /* It's safe to pass -s always, even if -g is not used. */
227 %{fpic|fPIC|fpie|fPIE:-K PIC} \
228 %{!.c:%{findirect-dispatch:-K PIC}} \
229 %{mlittle-endian:-EL} \
230 %(asm_cpu) %(asm_arch) %(asm_relax)"
232 #undef ASM_OUTPUT_ALIGNED_LOCAL
233 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
235 fputs ("\t.local\t", (FILE)); \
236 assemble_name ((FILE), (NAME)); \
237 putc ('\n', (FILE)); \
238 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
242 #define COMMON_ASM_OP "\t.common\t"
244 #undef LOCAL_LABEL_PREFIX
245 #define LOCAL_LABEL_PREFIX "."
247 /* This is how to store into the string LABEL
248 the symbol_ref name of an internal numbered label where
249 PREFIX is the class of label and NUM is the number within the class.
250 This is suitable for output with `assemble_name'. */
252 #undef ASM_GENERATE_INTERNAL_LABEL
253 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
254 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
258 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
259 Obviously the Dwarf2 folks haven't tried to actually build systems
260 with their spec. On a 64-bit system, only 64-bit relocs become
261 RELATIVE relocations. */
263 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
265 #undef DITF_CONVERSION_LIBFUNCS
266 #define DITF_CONVERSION_LIBFUNCS 1
269 #undef TARGET_SUN_TLS
270 #undef TARGET_GNU_TLS
271 #define TARGET_SUN_TLS 0
272 #define TARGET_GNU_TLS 1
275 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
276 #undef CTORS_SECTION_ASM_OP
277 #undef DTORS_SECTION_ASM_OP
279 /* Static stack checking is supported by means of probes. */
280 #define STACK_CHECK_STATIC_BUILTIN 1
282 /* Linux currently uses RMO in uniprocessor mode, which is equivalent to
283 TMO, and TMO in multiprocessor mode. But they reserve the right to
284 change their minds. */
285 #undef SPARC_RELAXED_ORDERING
286 #define SPARC_RELAXED_ORDERING true
288 #undef NEED_INDICATE_EXEC_STACK
289 #define NEED_INDICATE_EXEC_STACK 1
291 #ifdef TARGET_LIBC_PROVIDES_SSP
292 /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
293 sparc64 glibc provides it at [%g7 + 0x28]. */
294 #define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
297 /* Define if long doubles should be mangled as 'g'. */
298 #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
300 /* We use glibc _mcount for profiling. */
301 #undef NO_PROFILE_COUNTERS
302 #define NO_PROFILE_COUNTERS 1