OSDN Git Service

2002-04-12 Eric Norum <eric.norum@usask.ca>
[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 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 /* Make sure these are undefined.  */
24 #undef MD_EXEC_PREFIX
25 #undef MD_STARTFILE_PREFIX
26
27 #undef CPP_PREDEFINES
28 #define CPP_PREDEFINES "-D__sparc__ -D__NetBSD__ -D__ELF__ \
29 -Asystem=unix -Asystem=NetBSD"
30
31 /* CPP defines used for 64 bit code.  */
32 #undef CPP_SUBTARGET_SPEC64
33 #define CPP_SUBTARGET_SPEC64 \
34   "-D__sparc64__ -D__arch64__ -D__sparc_v9__ %{posix:-D_POSIX_SOURCE}"
35
36 /* CPP defines used for 32 bit code.  */
37 #undef CPP_SUBTARGET_SPEC32
38 #define CPP_SUBTARGET_SPEC32 "-D__sparc %{posix:-D_POSIX_SOURCE}"
39
40 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
41 #undef SIZE_TYPE
42 #define SIZE_TYPE "long unsigned int"
43
44 #undef PTRDIFF_TYPE
45 #define PTRDIFF_TYPE "long int"
46
47 #undef PREFERRED_DEBUGGING_TYPE
48 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
49
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 '?'
54
55 #undef DBX_REGISTER_NUMBER
56 #define DBX_REGISTER_NUMBER(REGNO) \
57   (TARGET_FLAT && REGNO == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO)
58
59 #undef  LOCAL_LABEL_PREFIX
60 #define LOCAL_LABEL_PREFIX  "."
61
62 /* This is how to output a definition of an internal numbered label where
63    PREFIX is the class of label and NUM is the number within the class.  */
64
65 #undef  ASM_OUTPUT_INTERNAL_LABEL
66 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
67   fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
68
69 /* This is how to output a reference to an internal numbered label where
70    PREFIX is the class of label and NUM is the number within the class.  */
71
72 #undef  ASM_OUTPUT_INTERNAL_LABELREF
73 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
74   fprintf (FILE, ".L%s%d", PREFIX, NUM)
75
76 /* This is how to store into the string LABEL
77    the symbol_ref name of an internal numbered label where
78    PREFIX is the class of label and NUM is the number within the class.
79    This is suitable for output with `assemble_name'.  */
80
81 #undef  ASM_GENERATE_INTERNAL_LABEL
82 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
83   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
84
85 #undef USER_LABEL_PREFIX
86 #define USER_LABEL_PREFIX ""
87
88 #undef ASM_SPEC
89 #define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} %{V} %{v:%{!V:-V}} \
90 %{mlittle-endian:-EL} \
91 %(asm_cpu) %(asm_arch) %(asm_relax)"
92
93 #undef STDC_0_IN_SYSTEM_HEADERS
94
95 #undef TARGET_VERSION
96 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
97
98 /*
99  * Clean up afterwards generic SPARC ELF configuration.
100  */
101
102 #undef TRANSFER_FROM_TRAMPOLINE
103 #define TRANSFER_FROM_TRAMPOLINE
104
105 /* FIXME: Aren't these supposed to be available for SPARC ELF?  */
106 #undef MULDI3_LIBCALL
107 #undef DIVDI3_LIBCALL
108 #undef UDIVDI3_LIBCALL
109 #undef MODDI3_LIBCALL
110 #undef UMODDI3_LIBCALL
111 #undef INIT_SUBTARGET_OPTABS  
112 #define INIT_SUBTARGET_OPTABS  
113
114 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
115    description, allowing one to build 32 bit or 64 bit applications
116    on either.  We define the sparc & sparc64 versions of things,
117    occasionally a neutral version (should be the same as "netbsd-elf.h")
118    and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
119    we choose the correct version.  */
120
121 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
122    definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
123    not have a default place to find these libraries..  */
124
125 /* Name the port(s).  */
126 #define TARGET_NAME64     "NetBSD/sparc64 ELF"
127 #define TARGET_NAME32     "NetBSD/sparc ELF"
128
129 /* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
130    platform here.  */
131
132 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
133  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
134 /* A 64 bit v9 compiler with stack-bias,
135    in a Medium/Low code model environment.  */
136
137 #undef TARGET_DEFAULT
138 #define TARGET_DEFAULT \
139   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
140    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
141
142 #undef SPARC_DEFAULT_CMODEL
143 #define SPARC_DEFAULT_CMODEL CM_MEDANY
144
145 #endif
146
147 /* CC1_SPEC for NetBSD/sparc.  */
148 #define CC1_SPEC32 \
149  "%{sun4:} %{target:} \
150   %{mcypress:-mcpu=cypress} \
151   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
152   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
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: \
172     -mptr32 -mno-stack-bias \
173     %{!mlong-double-128:-mlong-double-64} \
174     %{!mcpu*: \
175       %{!mcypress: \
176         %{!msparclite: \
177           %{!mf930: \
178             %{!mf934: \
179               %{!mv8*: \
180                 %{!msupersparc:-mcpu=cypress}}}}}}}} \
181   %{!m32: \
182     %{p:-mcmodel=medlow} \
183     %{pg:-mcmodel=medlow}}"
184
185 /* Make sure we use the right output format.  Pick a default and then
186    make sure -m32/-m64 switch to the right one.  */
187
188 #define LINK_ARCH32_SPEC \
189  "%-m elf32_sparc \
190   %{assert*} %{R*} %{V} %{v:%{!V:-V}} \
191   %{shared:-shared} \
192   %{!shared: \
193     -dp \
194     %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
195     %{!static: \
196       -dy %{rdynamic:-export-dynamic} \
197       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
198     %{static:-static}}"
199
200 #define LINK_ARCH64_SPEC \
201  "%-m elf64_sparc \
202   %{assert*} %{R*} %{V} %{v:%{!V:-V}} \
203   %{shared:-shared} \
204   %{!shared: \
205     -dp \
206     %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
207     %{!static: \
208       -dy %{rdynamic:-export-dynamic} \
209       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
210     %{static:-static}}"
211
212 #define LINK_ARCH_SPEC "\
213 %{m32:%(link_arch32)} \
214 %{m64:%(link_arch64)} \
215 %{!m32:%{!m64:%(link_arch_default)}} \
216 "
217
218 #if DEFAULT_ARCH32_P
219 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
220 #else
221 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
222 #endif
223
224 /* What extra spec entries do we need?  */
225 #undef SUBTARGET_EXTRA_SPECS
226 #define SUBTARGET_EXTRA_SPECS \
227   { "link_arch32",              LINK_ARCH32_SPEC }, \
228   { "link_arch64",              LINK_ARCH64_SPEC }, \
229   { "link_arch_default",        LINK_ARCH_DEFAULT_SPEC }, \
230   { "link_arch",                LINK_ARCH_SPEC }, \
231   { "cpp_subtarget_spec32",     CPP_SUBTARGET_SPEC32 }, \
232   { "cpp_subtarget_spec64",     CPP_SUBTARGET_SPEC64 },
233
234
235 /* What extra switches do we need?  */
236 #undef  SUBTARGET_SWITCHES
237 #define SUBTARGET_SWITCHES \
238   {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
239   {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
240
241
242 /* Build a compiler that supports -m32 and -m64?  */
243
244 #ifdef SPARC_BI_ARCH
245
246 #undef LONG_DOUBLE_TYPE_SIZE
247 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
248
249 #undef MAX_LONG_DOUBLE_TYPE_SIZE
250 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
251
252 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
253 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
254 #else
255 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
256 #endif
257
258 #undef  CC1_SPEC
259 #if DEFAULT_ARCH32_P
260 #define CC1_SPEC CC1_SPEC32
261 #else
262 #define CC1_SPEC CC1_SPEC64
263 #endif
264
265 #if DEFAULT_ARCH32_P
266 #define MULTILIB_DEFAULTS { "m32" }
267 #else
268 #define MULTILIB_DEFAULTS { "m64" }
269 #endif
270
271 #undef CPP_SUBTARGET_SPEC
272 #if DEFAULT_ARCH32_P
273 #define CPP_SUBTARGET_SPEC \
274   "%{m64:%(cpp_subtarget_spec64)}%{!m64:%(cpp_subtarget_spec32)}"
275 #else
276 #define CPP_SUBTARGET_SPEC \
277   "%{!m32:%(cpp_subtarget_spec64)}%{m32:%(cpp_subtarget_spec32)}"
278 #endif
279
280 /* Restore this from sparc/sparc.h, netbsd.h changes it.  */
281 #undef CPP_SPEC
282 #define CPP_SPEC "%(cpp_cpu) %(cpp_arch) %(cpp_endian) %(cpp_subtarget)"
283
284 /* Name the port. */
285 #undef TARGET_NAME
286 #define TARGET_NAME     (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
287
288 #else   /* SPARC_BI_ARCH */
289
290 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
291  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
292
293 #undef LONG_DOUBLE_TYPE_SIZE
294 #define LONG_DOUBLE_TYPE_SIZE 128
295
296 #undef MAX_LONG_DOUBLE_TYPE_SIZE
297 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
298
299 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
300 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
301
302 #undef  CC1_SPEC
303 #define CC1_SPEC CC1_SPEC64
304
305 #undef CPP_SUBTARGET_SPEC
306 #define CPP_SUBTARGET_SPEC CPP_SUBTARGET_SPEC64
307
308 #undef TARGET_NAME
309 #define TARGET_NAME     TARGET_NAME64
310
311 #else   /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
312         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
313
314 /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
315    for 32-bit code, unlike Solaris.  */
316
317 #undef LONG_DOUBLE_TYPE_SIZE
318 #define LONG_DOUBLE_TYPE_SIZE 64
319
320 #undef MAX_LONG_DOUBLE_TYPE_SIZE
321 #define MAX_LONG_DOUBLE_TYPE_SIZE 64
322
323 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
324 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
325
326 #undef CPP_SUBTARGET_SPEC
327 #define CPP_SUBTARGET_SPEC CPP_SUBTARGET_SPEC32
328
329 #undef  CC1_SPEC
330 #define CC1_SPEC CC1_SPEC32
331
332 #undef TARGET_NAME
333 #define TARGET_NAME     TARGET_NAME32
334
335 #endif  /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
336         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
337
338 #endif  /* SPARC_BI_ARCH */
339
340 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
341 #undef CTORS_SECTION_ASM_OP
342 #undef DTORS_SECTION_ASM_OP