OSDN Git Service

* config.gcc (sparc-*-sysv4*): Add sparc/sysv4-only.h.
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / netbsd-elf.h
1 /* Definitions of target machine for GNU compiler, for ELF on NetBSD/sparc
2    and NetBSD/sparc64.
3    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
4    Contributed by Matthew Green (mrg@eterna.com.au).
5
6 This file is part of GNU CC.
7
8 GNU CC 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.
12
13 GNU CC 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.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
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         }                                               \
32       else                                              \
33         builtin_define ("__sparc");                     \
34       builtin_define ("__sparc__");                     \
35     }                                                   \
36   while (0)
37
38 /* Make sure these are undefined.  */
39 #undef MD_EXEC_PREFIX
40 #undef MD_STARTFILE_PREFIX
41
42 /* CPP defines used by all NetBSD targets.  */
43 #undef CPP_SUBTARGET_SPEC
44 #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
45
46 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
47 #undef SIZE_TYPE
48 #define SIZE_TYPE "long unsigned int"
49
50 #undef PTRDIFF_TYPE
51 #define PTRDIFF_TYPE "long int"
52
53 #undef PREFERRED_DEBUGGING_TYPE
54 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
55
56 /* This is the char to use for continuation (in case we need to turn
57    continuation back on).  */
58 #undef DBX_CONTIN_CHAR
59 #define DBX_CONTIN_CHAR '?'
60
61 #undef DBX_REGISTER_NUMBER
62 #define DBX_REGISTER_NUMBER(REGNO) \
63   (TARGET_FLAT && REGNO == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO)
64
65 #undef  LOCAL_LABEL_PREFIX
66 #define LOCAL_LABEL_PREFIX  "."
67
68 /* This is how to output a reference to an internal numbered label where
69    PREFIX is the class of label and NUM is the number within the class.  */
70
71 #undef  ASM_OUTPUT_INTERNAL_LABELREF
72 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
73   fprintf (FILE, ".L%s%d", PREFIX, NUM)
74
75 /* This is how to store into the string LABEL
76    the symbol_ref name of an internal numbered label where
77    PREFIX is the class of label and NUM is the number within the class.
78    This is suitable for output with `assemble_name'.  */
79
80 #undef  ASM_GENERATE_INTERNAL_LABEL
81 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
82   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
83
84 #undef USER_LABEL_PREFIX
85 #define USER_LABEL_PREFIX ""
86
87 #undef ASM_SPEC
88 #define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} %{V} %{v:%{!V:-V}} \
89 %{mlittle-endian:-EL} \
90 %(asm_cpu) %(asm_arch) %(asm_relax)"
91
92 #undef STDC_0_IN_SYSTEM_HEADERS
93
94 /* Attempt to enable execute permissions on the stack.  */
95 #define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
96
97 #undef TARGET_VERSION
98 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
99
100 /*
101  * Clean up afterwards generic SPARC ELF configuration.
102  */
103
104 /* FIXME: Aren't these supposed to be available for SPARC ELF?  */
105 #undef MULDI3_LIBCALL
106 #undef DIVDI3_LIBCALL
107 #undef UDIVDI3_LIBCALL
108 #undef MODDI3_LIBCALL
109 #undef UMODDI3_LIBCALL
110 #undef INIT_SUBTARGET_OPTABS  
111 #define INIT_SUBTARGET_OPTABS  
112
113 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
114    description, allowing one to build 32 bit or 64 bit applications
115    on either.  We define the sparc & sparc64 versions of things,
116    occasionally a neutral version (should be the same as "netbsd-elf.h")
117    and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
118    we choose the correct version.  */
119
120 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
121    definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
122    not have a default place to find these libraries..  */
123
124 /* Name the port(s).  */
125 #define TARGET_NAME64     "NetBSD/sparc64 ELF"
126 #define TARGET_NAME32     "NetBSD/sparc ELF"
127
128 /* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
129    platform here.  */
130
131 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
132  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
133 /* A 64 bit v9 compiler with stack-bias,
134    in a Medium/Low code model environment.  */
135
136 #undef TARGET_DEFAULT
137 #define TARGET_DEFAULT \
138   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
139    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
140
141 #undef SPARC_DEFAULT_CMODEL
142 #define SPARC_DEFAULT_CMODEL CM_MEDANY
143
144 #endif
145
146 /* CC1_SPEC for NetBSD/sparc.  */
147 #define CC1_SPEC32 \
148  "%{sun4:} %{target:} \
149   %{mcypress:-mcpu=cypress} \
150   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
151   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
152   %{m32:%{m64:%emay not use both -m32 and -m64}} \
153   %{m64: \
154     -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
155     %{!mcpu*: \
156       %{!mcypress: \
157         %{!msparclite: \
158           %{!mf930: \
159             %{!mf934: \
160               %{!mv8*: \
161                 %{!msupersparc:-mcpu=ultrasparc}}}}}}} \
162     %{!mno-vis:%{!mcpu=v9:-mvis}} \
163     %{p:-mcmodel=medlow} \
164     %{pg:-mcmodel=medlow}}"
165
166 #define CC1_SPEC64 \
167  "%{sun4:} %{target:} \
168   %{mcypress:-mcpu=cypress} \
169   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
170   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
171   %{m32:%{m64:%emay not use both -m32 and -m64}} \
172   %{m32: \
173     -mptr32 -mno-stack-bias \
174     %{!mlong-double-128:-mlong-double-64} \
175     %{!mcpu*: \
176       %{!mcypress: \
177         %{!msparclite: \
178           %{!mf930: \
179             %{!mf934: \
180               %{!mv8*: \
181                 %{!msupersparc:-mcpu=cypress}}}}}}}} \
182   %{!m32: \
183     %{p:-mcmodel=medlow} \
184     %{pg:-mcmodel=medlow}}"
185
186 /* Make sure we use the right output format.  Pick a default and then
187    make sure -m32/-m64 switch to the right one.  */
188
189 #define LINK_ARCH32_SPEC "-m elf32_sparc"
190
191 #define LINK_ARCH64_SPEC "-m elf64_sparc"
192
193 #define LINK_ARCH_SPEC \
194  "%{m32:%(link_arch32)} \
195   %{m64:%(link_arch64)} \
196   %{!m32:%{!m64:%(link_arch_default)}}"
197
198 #undef LINK_SPEC
199 #define LINK_SPEC \
200  "%(link_arch) \
201   %{!mno-relax:%{!r:-relax}} \
202   %(netbsd_link_spec)"
203
204 #define NETBSD_ENTRY_POINT "__start"
205
206 #if DEFAULT_ARCH32_P
207 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
208 #else
209 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
210 #endif
211
212 /* What extra spec entries do we need?  */
213 #undef SUBTARGET_EXTRA_SPECS
214 #define SUBTARGET_EXTRA_SPECS \
215   { "link_arch32",              LINK_ARCH32_SPEC }, \
216   { "link_arch64",              LINK_ARCH64_SPEC }, \
217   { "link_arch_default",        LINK_ARCH_DEFAULT_SPEC }, \
218   { "link_arch",                LINK_ARCH_SPEC }, \
219   { "netbsd_cpp_spec",          NETBSD_CPP_SPEC }, \
220   { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF }, \
221   { "netbsd_entry_point",       NETBSD_ENTRY_POINT },
222
223
224 /* What extra switches do we need?  */
225 #undef  SUBTARGET_SWITCHES
226 #define SUBTARGET_SWITCHES \
227   {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
228   {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
229
230
231 /* Build a compiler that supports -m32 and -m64?  */
232
233 #ifdef SPARC_BI_ARCH
234
235 #undef LONG_DOUBLE_TYPE_SIZE
236 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
237
238 #undef MAX_LONG_DOUBLE_TYPE_SIZE
239 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
240
241 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
242 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
243 #else
244 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
245 #endif
246
247 #undef  CC1_SPEC
248 #if DEFAULT_ARCH32_P
249 #define CC1_SPEC CC1_SPEC32
250 #else
251 #define CC1_SPEC CC1_SPEC64
252 #endif
253
254 #if DEFAULT_ARCH32_P
255 #define MULTILIB_DEFAULTS { "m32" }
256 #else
257 #define MULTILIB_DEFAULTS { "m64" }
258 #endif
259
260 /* Name the port. */
261 #undef TARGET_NAME
262 #define TARGET_NAME     (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
263
264 #else   /* SPARC_BI_ARCH */
265
266 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
267  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
268
269 #undef LONG_DOUBLE_TYPE_SIZE
270 #define LONG_DOUBLE_TYPE_SIZE 128
271
272 #undef MAX_LONG_DOUBLE_TYPE_SIZE
273 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
274
275 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
276 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
277
278 #undef  CC1_SPEC
279 #define CC1_SPEC CC1_SPEC64
280
281 #undef TARGET_NAME
282 #define TARGET_NAME     TARGET_NAME64
283
284 #else   /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
285         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
286
287 /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
288    for 32-bit code, unlike Solaris.  */
289
290 #undef LONG_DOUBLE_TYPE_SIZE
291 #define LONG_DOUBLE_TYPE_SIZE 64
292
293 #undef MAX_LONG_DOUBLE_TYPE_SIZE
294 #define MAX_LONG_DOUBLE_TYPE_SIZE 64
295
296 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
297 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
298
299 #undef  CC1_SPEC
300 #define CC1_SPEC CC1_SPEC32
301
302 #undef TARGET_NAME
303 #define TARGET_NAME     TARGET_NAME32
304
305 #endif  /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
306         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
307
308 #endif  /* SPARC_BI_ARCH */
309
310 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
311 #undef CTORS_SECTION_ASM_OP
312 #undef DTORS_SECTION_ASM_OP