OSDN Git Service

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