1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
5 This file is part of GCC.
7 GCC 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 3, or (at your option)
12 GCC 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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define TARGET_OS_CPP_BUILTINS() \
24 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
26 builtin_define ("_LONGLONG"); \
28 && TARGET_LONG_DOUBLE_128) \
29 builtin_define ("__LONG_DOUBLE_128__"); \
33 /* On Linux, the combination sparc64-* --with-cpu=v8 is supported and
34 selects a 32-bit compiler. */
35 #if defined(TARGET_64BIT_DEFAULT) && TARGET_CPU_DEFAULT >= TARGET_CPU_v9
37 #define TARGET_DEFAULT \
38 (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_STACK_BIAS + \
39 MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
42 /* This must be v9a not just v9 because by default we enable
44 #undef ASM_CPU64_DEFAULT_SPEC
45 #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
47 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
48 the GNU/Linux magical crtend.o file (see crtstuff.c) which
49 provides part of the support for getting C++ file-scope static
50 object constructed before entering `main', followed by a normal
51 GNU/Linux "finalizer" file, `crtn.o'. */
54 #define ENDFILE_SPEC \
55 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
56 %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
58 /* The default code model. */
59 #undef SPARC_DEFAULT_CMODEL
60 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
63 #define WCHAR_TYPE "int"
65 #undef WCHAR_TYPE_SIZE
66 #define WCHAR_TYPE_SIZE 32
68 /* Define for support of TFmode long double.
69 SPARC ABI says that long double is 4 words. */
70 #undef LONG_DOUBLE_TYPE_SIZE
71 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
73 #undef CPP_SUBTARGET_SPEC
74 #define CPP_SUBTARGET_SPEC "\
75 %{posix:-D_POSIX_SOURCE} \
76 %{pthread:-D_REENTRANT} \
79 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
80 for the special GCC options -static and -shared, which allow us to
81 link things in one of these three modes by applying the appropriate
82 combinations of options at link-time.
84 When the -shared link option is used a final link is not being
87 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
88 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
92 #undef SUBTARGET_EXTRA_SPECS
93 #define SUBTARGET_EXTRA_SPECS \
94 { "link_arch32", LINK_ARCH32_SPEC }, \
95 { "link_arch64", LINK_ARCH64_SPEC }, \
96 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
97 { "link_arch", LINK_ARCH_SPEC },
99 #define LINK_ARCH32_SPEC "-m elf32_sparc %{shared:-shared} \
102 %{rdynamic:-export-dynamic} \
103 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
107 #define LINK_ARCH64_SPEC "-m elf64_sparc %{shared:-shared} \
110 %{rdynamic:-export-dynamic} \
111 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
115 #define LINK_ARCH_SPEC "\
116 %{m32:%(link_arch32)} \
117 %{m64:%(link_arch64)} \
118 %{!m32:%{!m64:%(link_arch_default)}} \
121 #define LINK_ARCH_DEFAULT_SPEC \
122 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
127 %{!mno-relax:%{!r:-relax}} \
130 /* -mcpu=native handling only makes sense with compiler running on
132 #if defined(__sparc__) && defined(__linux__)
133 extern const char *host_detect_local_cpu (int argc
, const char **argv
);
134 # define EXTRA_SPEC_FUNCTIONS \
135 { "local_cpu_detect", host_detect_local_cpu },
137 # define MCPU_MTUNE_NATIVE_SPECS \
138 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
139 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
141 # define MCPU_MTUNE_NATIVE_SPECS ""
144 #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
148 #define CC1_SPEC "%{profile:-p} \
149 %{m32:%{m64:%emay not use both -m32 and -m64}} \
150 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
151 %{!mcpu*:-mcpu=ultrasparc} \
152 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
155 #define CC1_SPEC "%{profile:-p} \
156 %{m32:%{m64:%emay not use both -m32 and -m64}} \
157 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
158 %{!mcpu*:-mcpu=cypress}} \
159 %{mv8plus:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
160 %{!mcpu*:-mcpu=v9}} \
161 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
162 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
166 /* Support for a compile-time default CPU, et cetera. The rules are:
167 --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
169 --with-tune is ignored if -mtune is specified; likewise --with-tune-32
171 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
173 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
174 here, otherwise say -mcpu=v7 would be passed even when -m64.
175 CC1_SPEC above takes care of this instead.
177 Note that the order of the cpu* and tune* options matters: the
178 config.gcc file always sets with_cpu to some value, even if the
179 user didn't use --with-cpu when invoking the configure script.
180 This value is based on the target name. Therefore we have to make
181 sure that --with-cpu-32 takes precedence to --with-cpu in < v9
182 systems, and that --with-cpu-64 takes precedence to --with-cpu in
183 >= v9 systems. As for the tune* options, in some platforms
184 config.gcc also sets a default value for it if the user didn't use
185 --with-tune when invoking the configure script. */
186 #undef OPTION_DEFAULT_SPECS
188 #define OPTION_DEFAULT_SPECS \
189 {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
190 {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
191 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
192 {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
193 {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
194 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
195 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
197 #define OPTION_DEFAULT_SPECS \
198 {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
199 {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
200 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
201 {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
202 {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
203 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
204 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
208 #define MULTILIB_DEFAULTS { "m32" }
210 #define MULTILIB_DEFAULTS { "m64" }
213 #else /* !SPARC_BI_ARCH */
216 #define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
219 %{rdynamic:-export-dynamic} \
220 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
222 %{!mno-relax:%{!r:-relax}} \
225 #endif /* !SPARC_BI_ARCH */
227 /* It's safe to pass -s always, even if -g is not used. */
231 %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
232 %{!.c:%{findirect-dispatch:-K PIC}} \
233 %(asm_cpu) %(asm_arch) %(asm_relax)"
235 #undef ASM_OUTPUT_ALIGNED_LOCAL
236 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
238 fputs ("\t.local\t", (FILE)); \
239 assemble_name ((FILE), (NAME)); \
240 putc ('\n', (FILE)); \
241 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
245 #define COMMON_ASM_OP "\t.common\t"
247 #undef LOCAL_LABEL_PREFIX
248 #define LOCAL_LABEL_PREFIX "."
252 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
253 Obviously the Dwarf2 folks haven't tried to actually build systems
254 with their spec. On a 64-bit system, only 64-bit relocs become
255 RELATIVE relocations. */
257 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
259 #undef DITF_CONVERSION_LIBFUNCS
260 #define DITF_CONVERSION_LIBFUNCS 1
263 #undef TARGET_SUN_TLS
264 #undef TARGET_GNU_TLS
265 #define TARGET_SUN_TLS 0
266 #define TARGET_GNU_TLS 1
269 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
270 #undef CTORS_SECTION_ASM_OP
271 #undef DTORS_SECTION_ASM_OP
273 /* Static stack checking is supported by means of probes. */
274 #define STACK_CHECK_STATIC_BUILTIN 1
276 #undef NEED_INDICATE_EXEC_STACK
277 #define NEED_INDICATE_EXEC_STACK 1
279 #ifdef TARGET_LIBC_PROVIDES_SSP
280 /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
281 sparc64 glibc provides it at [%g7 + 0x28]. */
282 #define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
285 /* Define if long doubles should be mangled as 'g'. */
286 #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
288 /* We use glibc _mcount for profiling. */
289 #undef NO_PROFILE_COUNTERS
290 #define NO_PROFILE_COUNTERS 1