gcc/ChangeLog:
[official-gcc.git] / gcc / config / sparc / netbsd-elf.h
blob3cfd0fc1ebbb0b8bcf24c68b90f4e2e8607f8aba
1 /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
2 and NetBSD/sparc64.
3 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 Contributed by Matthew Green (mrg@eterna.com.au).
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 2, 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 COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #define TARGET_OS_CPP_BUILTINS() \
24 do \
25 { \
26 NETBSD_OS_CPP_BUILTINS_ELF(); \
27 if (TARGET_ARCH64) \
28 { \
29 builtin_define ("__sparc64__"); \
30 builtin_define ("__sparc_v9__"); \
31 builtin_define ("__sparcv9"); \
32 } \
33 else \
34 builtin_define ("__sparc"); \
35 builtin_define ("__sparc__"); \
36 } \
37 while (0)
39 /* Make sure these are undefined. */
40 #undef MD_EXEC_PREFIX
41 #undef MD_STARTFILE_PREFIX
43 /* CPP defines used by all NetBSD targets. */
44 #undef CPP_SUBTARGET_SPEC
45 #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
47 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h. */
48 #undef SIZE_TYPE
49 #define SIZE_TYPE "long unsigned int"
51 #undef PTRDIFF_TYPE
52 #define PTRDIFF_TYPE "long int"
54 #undef PREFERRED_DEBUGGING_TYPE
55 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
57 /* This is the char to use for continuation (in case we need to turn
58 continuation back on). */
59 #undef DBX_CONTIN_CHAR
60 #define DBX_CONTIN_CHAR '?'
62 #undef LOCAL_LABEL_PREFIX
63 #define LOCAL_LABEL_PREFIX "."
65 /* This is how to output a reference to an internal numbered label where
66 PREFIX is the class of label and NUM is the number within the class. */
68 #undef ASM_OUTPUT_INTERNAL_LABELREF
69 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
70 fprintf (FILE, ".L%s%d", PREFIX, NUM)
72 /* This is how to store into the string LABEL
73 the symbol_ref name of an internal numbered label where
74 PREFIX is the class of label and NUM is the number within the class.
75 This is suitable for output with `assemble_name'. */
77 #undef ASM_GENERATE_INTERNAL_LABEL
78 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
79 sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
81 #undef USER_LABEL_PREFIX
82 #define USER_LABEL_PREFIX ""
84 #undef ASM_SPEC
85 #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %{V} %{v:%{!V:-V}} \
86 %{mlittle-endian:-EL} \
87 %(asm_cpu) %(asm_arch) %(asm_relax)"
89 #undef STDC_0_IN_SYSTEM_HEADERS
91 /* Attempt to enable execute permissions on the stack. */
92 #define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
94 #undef TARGET_VERSION
95 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
97 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
98 description, allowing one to build 32 bit or 64 bit applications
99 on either. We define the sparc & sparc64 versions of things,
100 occasionally a neutral version (should be the same as "netbsd-elf.h")
101 and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
102 we choose the correct version. */
104 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
105 definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
106 not have a default place to find these libraries.. */
108 /* Name the port(s). */
109 #define TARGET_NAME64 "NetBSD/sparc64 ELF"
110 #define TARGET_NAME32 "NetBSD/sparc ELF"
112 /* TARGET_CPU_DEFAULT is set in Makefile.in. We test for 64-bit default
113 platform here. */
115 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
116 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
117 /* A 64 bit v9 compiler with stack-bias,
118 in a Medium/Low code model environment. */
120 #undef TARGET_DEFAULT
121 #define TARGET_DEFAULT \
122 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
123 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
125 #undef SPARC_DEFAULT_CMODEL
126 #define SPARC_DEFAULT_CMODEL CM_MEDANY
128 #endif
130 /* CC1_SPEC for NetBSD/sparc. */
131 #define CC1_SPEC32 \
132 "%{sun4:} %{target:} \
133 %{mcypress:-mcpu=cypress} \
134 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
135 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
136 %{m32:%{m64:%emay not use both -m32 and -m64}} \
137 %{m64: \
138 -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
139 %{!mcpu*: \
140 %{!mcypress: \
141 %{!msparclite: \
142 %{!mf930: \
143 %{!mf934: \
144 %{!mv8*: \
145 %{!msupersparc:-mcpu=ultrasparc}}}}}}} \
146 %{!mno-vis:%{!mcpu=v9:-mvis}} \
147 %{p:-mcmodel=medlow} \
148 %{pg:-mcmodel=medlow}}"
150 #define CC1_SPEC64 \
151 "%{sun4:} %{target:} \
152 %{mcypress:-mcpu=cypress} \
153 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
154 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
155 %{m32:%{m64:%emay not use both -m32 and -m64}} \
156 %{m32: \
157 -mptr32 -mno-stack-bias \
158 %{!mlong-double-128:-mlong-double-64} \
159 %{!mcpu*: \
160 %{!mcypress: \
161 %{!msparclite: \
162 %{!mf930: \
163 %{!mf934: \
164 %{!mv8*: \
165 %{!msupersparc:-mcpu=cypress}}}}}}}} \
166 %{!m32: \
167 %{p:-mcmodel=medlow} \
168 %{pg:-mcmodel=medlow}}"
170 /* Make sure we use the right output format. Pick a default and then
171 make sure -m32/-m64 switch to the right one. */
173 #define LINK_ARCH32_SPEC "-m elf32_sparc"
175 #define LINK_ARCH64_SPEC "-m elf64_sparc"
177 #define LINK_ARCH_SPEC \
178 "%{m32:%(link_arch32)} \
179 %{m64:%(link_arch64)} \
180 %{!m32:%{!m64:%(link_arch_default)}}"
182 #undef LINK_SPEC
183 #define LINK_SPEC \
184 "%(link_arch) \
185 %{!mno-relax:%{!r:-relax}} \
186 %(netbsd_link_spec)"
188 #define NETBSD_ENTRY_POINT "__start"
190 #if DEFAULT_ARCH32_P
191 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
192 #else
193 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
194 #endif
196 /* What extra spec entries do we need? */
197 #undef SUBTARGET_EXTRA_SPECS
198 #define SUBTARGET_EXTRA_SPECS \
199 { "link_arch32", LINK_ARCH32_SPEC }, \
200 { "link_arch64", LINK_ARCH64_SPEC }, \
201 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
202 { "link_arch", LINK_ARCH_SPEC }, \
203 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \
204 { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \
205 { "netbsd_entry_point", NETBSD_ENTRY_POINT },
208 /* What extra switches do we need? */
209 #undef SUBTARGET_SWITCHES
210 #define SUBTARGET_SWITCHES \
211 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
212 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
215 /* Build a compiler that supports -m32 and -m64? */
217 #ifdef SPARC_BI_ARCH
219 #undef LONG_DOUBLE_TYPE_SIZE
220 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
222 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
223 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
224 #else
225 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
226 #endif
228 #undef CC1_SPEC
229 #if DEFAULT_ARCH32_P
230 #define CC1_SPEC CC1_SPEC32
231 #else
232 #define CC1_SPEC CC1_SPEC64
233 #endif
235 #if DEFAULT_ARCH32_P
236 #define MULTILIB_DEFAULTS { "m32" }
237 #else
238 #define MULTILIB_DEFAULTS { "m64" }
239 #endif
241 /* Name the port. */
242 #undef TARGET_NAME
243 #define TARGET_NAME (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
245 #else /* SPARC_BI_ARCH */
247 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
248 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
250 #undef LONG_DOUBLE_TYPE_SIZE
251 #define LONG_DOUBLE_TYPE_SIZE 128
253 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
254 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
256 #undef CC1_SPEC
257 #define CC1_SPEC CC1_SPEC64
259 #undef TARGET_NAME
260 #define TARGET_NAME TARGET_NAME64
262 #else /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
263 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
265 /* A 32-bit only compiler. NetBSD don't support 128 bit `long double'
266 for 32-bit code, unlike Solaris. */
268 #undef LONG_DOUBLE_TYPE_SIZE
269 #define LONG_DOUBLE_TYPE_SIZE 64
271 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
272 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
274 #undef CC1_SPEC
275 #define CC1_SPEC CC1_SPEC32
277 #undef TARGET_NAME
278 #define TARGET_NAME TARGET_NAME32
280 #endif /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
281 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
283 #endif /* SPARC_BI_ARCH */
285 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
286 #undef CTORS_SECTION_ASM_OP
287 #undef DTORS_SECTION_ASM_OP