1 /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
3 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2010
4 Free Software Foundation, Inc.
5 Contributed by Matthew Green (mrg@eterna.com.au).
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 #define TARGET_OS_CPP_BUILTINS() \
26 NETBSD_OS_CPP_BUILTINS_ELF(); \
29 builtin_define ("__sparc64__"); \
30 builtin_define ("__sparc_v9__"); \
31 builtin_define ("__sparcv9"); \
34 builtin_define ("__sparc"); \
35 builtin_define ("__sparc__"); \
39 /* CPP defines used by all NetBSD targets. */
40 #undef CPP_SUBTARGET_SPEC
41 #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
43 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h. */
45 #define SIZE_TYPE "long unsigned int"
48 #define PTRDIFF_TYPE "long int"
50 /* This is the char to use for continuation (in case we need to turn
51 continuation back on). */
52 #undef DBX_CONTIN_CHAR
53 #define DBX_CONTIN_CHAR '?'
55 #undef LOCAL_LABEL_PREFIX
56 #define LOCAL_LABEL_PREFIX "."
58 /* This is how to store into the string LABEL
59 the symbol_ref name of an internal numbered label where
60 PREFIX is the class of label and NUM is the number within the class.
61 This is suitable for output with `assemble_name'. */
63 #undef ASM_GENERATE_INTERNAL_LABEL
64 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
65 sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
67 #undef USER_LABEL_PREFIX
68 #define USER_LABEL_PREFIX ""
71 #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} \
72 %{mlittle-endian:-EL} \
73 %(asm_cpu) %(asm_arch) %(asm_relax)"
75 #undef STDC_0_IN_SYSTEM_HEADERS
77 /* Attempt to enable execute permissions on the stack. */
78 #define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
81 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
83 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
84 description, allowing one to build 32-bit or 64-bit applications
85 on either. We define the sparc & sparc64 versions of things,
86 occasionally a neutral version (should be the same as "netbsd-elf.h")
87 and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
88 we choose the correct version. */
90 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
91 definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
92 not have a default place to find these libraries.. */
94 /* Name the port(s). */
95 #define TARGET_NAME64 "NetBSD/sparc64 ELF"
96 #define TARGET_NAME32 "NetBSD/sparc ELF"
98 /* TARGET_CPU_DEFAULT is set in Makefile.in. We test for 64-bit default
101 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
102 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
103 /* A 64 bit v9 compiler with stack-bias,
104 in a Medium/Low code model environment. */
106 #undef TARGET_DEFAULT
107 #define TARGET_DEFAULT \
108 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
109 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
111 #undef SPARC_DEFAULT_CMODEL
112 #define SPARC_DEFAULT_CMODEL CM_MEDANY
116 /* CC1_SPEC for NetBSD/sparc. */
118 "%{sun4:} %{target:} \
119 %{mcypress:-mcpu=cypress} \
120 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
121 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
122 %{m32:%{m64:%emay not use both -m32 and -m64}} \
124 -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
131 %{!msupersparc:-mcpu=ultrasparc}}}}}}} \
132 %{!mno-vis:%{!mcpu=v9:-mvis}} \
133 %{p:-mcmodel=medlow} \
134 %{pg:-mcmodel=medlow}}"
137 "%{sun4:} %{target:} \
138 %{mcypress:-mcpu=cypress} \
139 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
140 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
141 %{m32:%{m64:%emay not use both -m32 and -m64}} \
143 -mptr32 -mno-stack-bias \
144 %{!mlong-double-128:-mlong-double-64} \
151 %{!msupersparc:-mcpu=cypress}}}}}}}} \
153 %{p:-mcmodel=medlow} \
154 %{pg:-mcmodel=medlow}}"
156 /* Make sure we use the right output format. Pick a default and then
157 make sure -m32/-m64 switch to the right one. */
159 #define LINK_ARCH32_SPEC "-m elf32_sparc"
161 #define LINK_ARCH64_SPEC "-m elf64_sparc"
163 #define LINK_ARCH_SPEC \
164 "%{m32:%(link_arch32)} \
165 %{m64:%(link_arch64)} \
166 %{!m32:%{!m64:%(link_arch_default)}}"
171 %{!mno-relax:%{!r:-relax}} \
174 #define NETBSD_ENTRY_POINT "__start"
177 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
179 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
182 /* What extra spec entries do we need? */
183 #undef SUBTARGET_EXTRA_SPECS
184 #define SUBTARGET_EXTRA_SPECS \
185 { "link_arch32", LINK_ARCH32_SPEC }, \
186 { "link_arch64", LINK_ARCH64_SPEC }, \
187 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
188 { "link_arch", LINK_ARCH_SPEC }, \
189 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \
190 { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \
191 { "netbsd_entry_point", NETBSD_ENTRY_POINT },
194 /* Build a compiler that supports -m32 and -m64? */
198 #undef LONG_DOUBLE_TYPE_SIZE
199 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
201 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
202 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
204 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
209 #define CC1_SPEC CC1_SPEC32
211 #define CC1_SPEC CC1_SPEC64
215 #define MULTILIB_DEFAULTS { "m32" }
217 #define MULTILIB_DEFAULTS { "m64" }
222 #define TARGET_NAME (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
224 #else /* SPARC_BI_ARCH */
226 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
227 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
229 #undef LONG_DOUBLE_TYPE_SIZE
230 #define LONG_DOUBLE_TYPE_SIZE 128
232 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
233 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
236 #define CC1_SPEC CC1_SPEC64
239 #define TARGET_NAME TARGET_NAME64
241 #else /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
242 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
244 /* A 32-bit only compiler. NetBSD don't support 128 bit `long double'
245 for 32-bit code, unlike Solaris. */
247 #undef LONG_DOUBLE_TYPE_SIZE
248 #define LONG_DOUBLE_TYPE_SIZE 64
250 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
251 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
254 #define CC1_SPEC CC1_SPEC32
257 #define TARGET_NAME TARGET_NAME32
259 #endif /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
260 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
262 #endif /* SPARC_BI_ARCH */
264 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
265 #undef CTORS_SECTION_ASM_OP
266 #undef DTORS_SECTION_ASM_OP