1/* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
2   Copyright 1992, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3   Contributed by Ron Guilmette (rfg@netcom.com).
4   Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GNU CC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING.  If not, write to
20the Free Software Foundation, 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA.  */
22
23/* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
24#include "sparc/sysv4.h"
25
26#undef CPP_PREDEFINES
27#define CPP_PREDEFINES \
28"-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 \
29-Asystem(unix) -Asystem(svr4)"
30
31#undef CPP_SUBTARGET_SPEC
32#define CPP_SUBTARGET_SPEC "\
33%{pthreads:-D_REENTRANT -D_PTHREADS} \
34%{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
35%{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
36"
37
38/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
39   It's safe to pass -s always, even if -g is not used. */
40#undef ASM_SPEC
41#define ASM_SPEC "\
42%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
43%{fpic:-K PIC} %{fPIC:-K PIC} \
44%(asm_cpu) \
45"
46
47/* This is here rather than in sparc.h because it's not known what
48   other assemblers will accept.  */
49#if TARGET_CPU_DEFAULT == TARGET_CPU_v9
50#undef ASM_CPU_DEFAULT_SPEC
51#define ASM_CPU_DEFAULT_SPEC "-xarch=v8plus"
52#endif
53#if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
54#undef ASM_CPU_DEFAULT_SPEC
55#define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa"
56#endif
57#undef ASM_CPU_SPEC
58#define ASM_CPU_SPEC "\
59%{mcpu=v8plus:-xarch=v8plus} \
60%{mcpu=ultrasparc:-xarch=v8plusa} \
61%{!mcpu*:%(asm_cpu_default)} \
62"
63
64/* However it appears that Solaris 2.0 uses the same reg numbering as
65   the old BSD-style system did. */
66
67#undef DBX_REGISTER_NUMBER
68/* Same as sparc.h */
69#define DBX_REGISTER_NUMBER(REGNO) \
70  (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)
71
72/* We use stabs-in-elf for debugging, because that is what the native
73   toolchain uses.  */
74#undef PREFERRED_DEBUGGING_TYPE
75#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
76
77/* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
78#undef ASM_OUTPUT_SKIP
79#define ASM_OUTPUT_SKIP(FILE,SIZE)  \
80  fprintf (FILE, "\t.skip %u\n", (SIZE))
81
82/* Use .uahalf/.uaword so packed structure members don't generate
83   assembler errors when using the native assembler.  */
84#undef ASM_SHORT
85#define ASM_SHORT ".uahalf"
86#undef ASM_LONG
87#define ASM_LONG ".uaword"
88
89/* This is how to output a definition of an internal numbered label where
90   PREFIX is the class of label and NUM is the number within the class.  */
91
92#undef  ASM_OUTPUT_INTERNAL_LABEL
93#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)	\
94  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
95
96/* This is how to output a reference to an internal numbered label where
97   PREFIX is the class of label and NUM is the number within the class.  */
98
99#undef  ASM_OUTPUT_INTERNAL_LABELREF
100#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)	\
101  fprintf (FILE, ".L%s%d", PREFIX, NUM)
102
103/* This is how to store into the string LABEL
104   the symbol_ref name of an internal numbered label where
105   PREFIX is the class of label and NUM is the number within the class.
106   This is suitable for output with `assemble_name'.  */
107
108#undef  ASM_GENERATE_INTERNAL_LABEL
109#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
110  sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
111
112
113/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.
114   We don't use the standard LIB_SPEC only because we don't yet support c++ */
115
116#undef STARTFILE_SPEC
117#define STARTFILE_SPEC "%{!shared: \
118			 %{!symbolic: \
119			  %{p:mcrt1.o%s} \
120                          %{!p: \
121	                    %{pg:gcrt1.o%s gmon.o%s} \
122                            %{!pg:crt1.o%s}}}} \
123			crti.o%s \
124			%{ansi:values-Xc.o%s} \
125			%{!ansi: \
126			 %{traditional:values-Xt.o%s} \
127			 %{!traditional:values-Xa.o%s}} \
128			crtbegin.o%s"
129
130/* ??? Note: in order for -compat-bsd to work fully,
131   we must somehow arrange to fixincludes /usr/ucbinclude
132   and put the result in $(libsubdir)/ucbinclude.  */
133
134#undef LIB_SPEC
135#define LIB_SPEC \
136  "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
137   %{!shared:\
138     %{!symbolic:\
139       %{pthreads:-lpthread} \
140       %{!pthreads:%{threads:-lthread}} \
141       -lc}}"
142
143#undef  ENDFILE_SPEC
144#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
145
146/* This should be the same as in svr4.h, except with -R added.  */
147#undef LINK_SPEC
148#define LINK_SPEC \
149  "%{h*} %{v:-V} \
150   %{b} %{Wl,*:%*} \
151   %{static:-dn -Bstatic} \
152   %{shared:-G -dy %{!mimpure-text:-z text}} \
153   %{symbolic:-Bsymbolic -G -dy -z text} \
154   %{G:-G} \
155   %{YP,*} \
156   %{R*} \
157   %{compat-bsd: \
158     %{!YP,*:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
159       %{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
160       %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
161     -R /usr/ucblib} \
162   %{!compat-bsd: \
163     %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
164       %{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
165       %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}} \
166   %{Qy:} %{!Qn:-Qy}"
167
168/* This defines which switch letters take arguments.
169   It is as in svr4.h but with -R added.  */
170
171#undef SWITCH_TAKES_ARG
172#define SWITCH_TAKES_ARG(CHAR) \
173  (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
174   || (CHAR) == 'R' \
175   || (CHAR) == 'h' \
176   || (CHAR) == 'x' \
177   || (CHAR) == 'z')
178
179/* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h.
180   Instead, it is enabled here, because it does work under Solaris.  */
181/* Define for support of TFmode long double and REAL_ARITHMETIC.
182   Sparc ABI says that long double is 4 words.  */
183#define LONG_DOUBLE_TYPE_SIZE 128
184
185/* But indicate that it isn't supported by the hardware.  */
186#define WIDEST_HARDWARE_FP_SIZE 64
187
188#define STDC_0_IN_SYSTEM_HEADERS
189
190#define MULDI3_LIBCALL "__mul64"
191#define DIVDI3_LIBCALL "__div64"
192#define UDIVDI3_LIBCALL "__udiv64"
193#define MODDI3_LIBCALL "__rem64"
194#define UMODDI3_LIBCALL "__urem64"
195
196#undef INIT_SUBTARGET_OPTABS
197#define INIT_SUBTARGET_OPTABS	\
198  fixsfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
199	TARGET_ARCH64 ? "__ftol" : "__ftoll");	\
200  fixunssfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
201	TARGET_ARCH64 ? "__ftoul" : "__ftoull");	\
202  fixdfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
203	TARGET_ARCH64 ? "__dtol" : "__dtoll");	\
204  fixunsdfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
205	TARGET_ARCH64 ? "__dtoul" : "__dtoull")
206
207/* No weird SPARC variants on Solaris */
208#undef TARGET_LIVE_G0
209#define TARGET_LIVE_G0	0
210#undef TARGET_BROKEN_SAVERESTORE
211#define TARGET_BROKEN_SAVERESTORE 0
212
213/* Solaris allows 64 bit out and global registers in 32 bit mode.
214   sparc_override_options will disable V8+ if not generating V9 code.  */
215#undef TARGET_DEFAULT
216#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_V8PLUS)
217
218/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
219   traps available which can get and set the condition codes
220   reliably.  */
221#undef MACHINE_STATE_SAVE
222#define MACHINE_STATE_SAVE(ID)				\
223  unsigned long int ms_flags, ms_saveret;		\
224  asm volatile("ta	0x20\n\t"			\
225	       "mov	%%g1, %0\n\t"			\
226	       "mov	%%g2, %1\n\t"			\
227	       : "=r" (ms_flags), "=r" (ms_saveret));
228
229#undef MACHINE_STATE_RESTORE
230#define MACHINE_STATE_RESTORE(ID)			\
231  asm volatile("mov	%0, %%g1\n\t"			\
232	       "mov	%1, %%g2\n\t"			\
233	       "ta	0x21\n\t"			\
234	       : /* no outputs */			\
235	       : "r" (ms_flags), "r" (ms_saveret));
236
237