xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/sparc/netbsd-elf.h (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1 /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
2    and NetBSD/sparc64.
3    Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
4    Contributed by Matthew Green (mrg@eterna.com.au).
5 
6 This file is part of GCC.
7 
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 3, or (at your option)
11 any later version.
12 
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.
17 
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21 
22 #define TARGET_OS_CPP_BUILTINS()			\
23   do							\
24     {							\
25       NETBSD_OS_CPP_BUILTINS_ELF();			\
26       if (TARGET_ARCH64)				\
27 	{						\
28 	  builtin_define ("__sparc64__");		\
29 	  builtin_define ("__sparc_v9__");		\
30 	  builtin_define ("__sparcv9");			\
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 /* This is the char to use for continuation (in case we need to turn
54    continuation back on).  */
55 #undef DBX_CONTIN_CHAR
56 #define DBX_CONTIN_CHAR '?'
57 
58 #undef  LOCAL_LABEL_PREFIX
59 #define LOCAL_LABEL_PREFIX  "."
60 
61 /* This is how to store into the string LABEL
62    the symbol_ref name of an internal numbered label where
63    PREFIX is the class of label and NUM is the number within the class.
64    This is suitable for output with `assemble_name'.  */
65 
66 #undef  ASM_GENERATE_INTERNAL_LABEL
67 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
68   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
69 
70 #undef USER_LABEL_PREFIX
71 #define USER_LABEL_PREFIX ""
72 
73 #undef ASM_SPEC
74 #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %{V} %{v:%{!V:-V}} \
75 %{mlittle-endian:-EL} \
76 %(asm_cpu) %(asm_arch) %(asm_relax)"
77 
78 #undef STDC_0_IN_SYSTEM_HEADERS
79 
80 /* Attempt to enable execute permissions on the stack.  */
81 #define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
82 
83 #undef TARGET_VERSION
84 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
85 
86 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
87    description, allowing one to build 32-bit or 64-bit applications
88    on either.  We define the sparc & sparc64 versions of things,
89    occasionally a neutral version (should be the same as "netbsd-elf.h")
90    and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
91    we choose the correct version.  */
92 
93 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
94    definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
95    not have a default place to find these libraries..  */
96 
97 /* Name the port(s).  */
98 #define TARGET_NAME64     "NetBSD/sparc64 ELF"
99 #define TARGET_NAME32     "NetBSD/sparc ELF"
100 
101 /* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
102    platform here.  */
103 
104 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
105  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
106 /* A 64 bit v9 compiler with stack-bias,
107    in a Medium/Low code model environment.  */
108 
109 #undef TARGET_DEFAULT
110 #define TARGET_DEFAULT \
111   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
112    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
113 
114 #undef SPARC_DEFAULT_CMODEL
115 #define SPARC_DEFAULT_CMODEL CM_MEDMID
116 
117 #endif
118 
119 /* CC1_SPEC for NetBSD/sparc.  */
120 #define CC1_SPEC32 \
121  "%{sun4:} %{target:} \
122   %{mcypress:-mcpu=cypress} \
123   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
124   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
125   %{m32:%{m64:%emay not use both -m32 and -m64}} \
126   %{m64: \
127     -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
128     %{!mcpu*: \
129       %{!mcypress: \
130         %{!msparclite: \
131 	  %{!mf930: \
132 	    %{!mf934: \
133 	      %{!mv8*: \
134 	        %{!msupersparc:-mcpu=ultrasparc}}}}}}} \
135     %{!mno-vis:%{!mcpu=v9:-mvis}} \
136     %{p:-mcmodel=medlow} \
137     %{pg:-mcmodel=medlow}} " \
138   NETBSD_CC1_AND_CC1PLUS_SPEC
139 
140 #define CC1_SPEC64 \
141  "%{sun4:} %{target:} \
142   %{mcypress:-mcpu=cypress} \
143   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
144   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
145   %{m32:%{m64:%emay not use both -m32 and -m64}} \
146   %{m32: \
147     -mptr32 -mno-stack-bias \
148     %{!mlong-double-128:-mlong-double-64} \
149     %{!mcpu*: \
150       %{!mcypress: \
151 	%{!msparclite: \
152 	  %{!mf930: \
153 	    %{!mf934: \
154 	      %{!mv8*: \
155 		%{!msupersparc:-mcpu=cypress}}}}}}}} \
156   %{!m32: \
157       %{p:-mcmodel=medlow} \
158       %{pg:-mcmodel=medlow}} " \
159   NETBSD_CC1_AND_CC1PLUS_SPEC
160 
161 #if defined(SPARC_BI_ARCH) || defined(__arch64__)
162 /* add code model specific object to the link line for 64bit */
163 #define	LINK_SPEC_CODE_MODEL64	\
164 	"%{!shared:"	\
165 	    "%{!mcmodel=*:%:if-exists(%R/usr/lib/sparc_mcmedmid.o)}"	\
166 	    "%{mcmodel=medlow:%:if-exists(%R/usr/lib/sparc_mcmedlow.o)}" \
167 	    "%{mcmodel=medmid:%:if-exists(%R/usr/lib/sparc_mcmedmid.o)}" \
168 	    "%{mcmodel=medany:%:if-exists(%R/usr/lib/sparc_mcmedany.o)}" \
169 	"}"
170 
171 #ifdef SPARC_BI_ARCH
172 #define LINK_SPEC_CODE_MODEL	"%{!m32:" LINK_SPEC_CODE_MODEL64 "}"
173 #else
174 #define	LINK_SPEC_CODE_MODEL	LINK_SPEC_CODE_MODEL64
175 #endif
176 #else
177 #define	LINK_SPEC_CODE_MODEL	""
178 #endif
179 
180 /* Make sure we use the right output format.  Pick a default and then
181    make sure -m32/-m64 switch to the right one.  */
182 
183 #define LINK_ARCH32_SPEC "-m elf32_sparc"
184 
185 #define LINK_ARCH64_SPEC "-m elf64_sparc"
186 
187 #define LINK_ARCH_SPEC \
188  "%{m32:%(link_arch32)} \
189   %{m64:%(link_arch64)} \
190   %{!m32:%{!m64:%(link_arch_default)}}"
191 
192 #undef LINK_SPEC
193 #define LINK_SPEC \
194  "%(link_arch) \
195   %{!mno-relax:%{!r:-relax}} \
196   %(netbsd_link_spec) " \
197   LINK_SPEC_CODE_MODEL
198 
199 #define NETBSD_ENTRY_POINT "__start"
200 
201 #if DEFAULT_ARCH32_P
202 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
203 #else
204 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
205 #endif
206 
207 /* What extra spec entries do we need?  */
208 #undef SUBTARGET_EXTRA_SPECS
209 #define SUBTARGET_EXTRA_SPECS \
210   { "link_arch32",		LINK_ARCH32_SPEC }, \
211   { "link_arch64",		LINK_ARCH64_SPEC }, \
212   { "link_arch_default",	LINK_ARCH_DEFAULT_SPEC }, \
213   { "link_arch",		LINK_ARCH_SPEC }, \
214   { "netbsd_cpp_spec",		NETBSD_CPP_SPEC }, \
215   { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF }, \
216   { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
217 
218 
219 /* Build a compiler that supports -m32 and -m64?  */
220 
221 #ifdef SPARC_BI_ARCH
222 
223 #undef LONG_DOUBLE_TYPE_SIZE
224 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
225 
226 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
227 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
228 #else
229 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
230 #endif
231 
232 #undef  CC1_SPEC
233 #if DEFAULT_ARCH32_P
234 #define CC1_SPEC CC1_SPEC32
235 #else
236 #define CC1_SPEC CC1_SPEC64
237 #endif
238 
239 #if DEFAULT_ARCH32_P
240 #define MULTILIB_DEFAULTS { "m32" }
241 #else
242 #define MULTILIB_DEFAULTS { "m64" }
243 #endif
244 
245 /* Name the port.  */
246 #undef TARGET_NAME
247 #define TARGET_NAME     (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
248 
249 #else	/* SPARC_BI_ARCH */
250 
251 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
252  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
253 
254 #undef LONG_DOUBLE_TYPE_SIZE
255 #define LONG_DOUBLE_TYPE_SIZE 128
256 
257 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
258 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
259 
260 #undef  CC1_SPEC
261 #define CC1_SPEC CC1_SPEC64
262 
263 #undef TARGET_NAME
264 #define TARGET_NAME     TARGET_NAME64
265 
266 #else	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
267 	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
268 
269 /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
270    for 32-bit code, unlike Solaris.  */
271 
272 #undef LONG_DOUBLE_TYPE_SIZE
273 #define LONG_DOUBLE_TYPE_SIZE 64
274 
275 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
276 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
277 
278 #undef  CC1_SPEC
279 #define CC1_SPEC CC1_SPEC32
280 
281 #undef TARGET_NAME
282 #define TARGET_NAME     TARGET_NAME32
283 
284 #endif	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
285 	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
286 
287 #endif	/* SPARC_BI_ARCH */
288 
289 #ifdef HAVE_AS_TLS
290 #undef TARGET_SUN_TLS
291 #undef TARGET_GNU_TLS
292 #define TARGET_SUN_TLS 0
293 #define TARGET_GNU_TLS 1
294 #endif
295 
296 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
297 #undef CTORS_SECTION_ASM_OP
298 #undef DTORS_SECTION_ASM_OP
299