f15807ff72df8663708a8dd1626ac8bf8e184a5f
1 /* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
2 Copyright 1992, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Ron Guilmette (rfg@netcom.com).
4 Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
6 This file is part of GNU CC.
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)
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.
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. */
23 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
24 #include "sparc/sysv4.h"
27 #define CPP_PREDEFINES \
28 "-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 \
29 -Asystem(unix) -Asystem(svr4)"
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} \
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. */
42 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
43 %{fpic:-K PIC} %{fPIC:-K PIC} \
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"
53 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
54 #undef ASM_CPU_DEFAULT_SPEC
55 #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa"
58 #define ASM_CPU_SPEC "\
59 %{mcpu=v8plus:-xarch=v8plus} \
60 %{mcpu=ultrasparc:-xarch=v8plusa} \
61 %{!mcpu*:%(asm_cpu_default)} \
64 /* However it appears that Solaris 2.0 uses the same reg numbering as
65 the old BSD-style system did. */
67 #undef DBX_REGISTER_NUMBER
69 #define DBX_REGISTER_NUMBER(REGNO) \
70 (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)
72 /* We use stabs-in-elf for debugging, because that is what the native
74 #undef PREFERRED_DEBUGGING_TYPE
75 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
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))
82 /* Use .uahalf/.uaword so packed structure members don't generate
83 assembler errors when using the native assembler. */
85 #define ASM_SHORT ".uahalf"
87 #define ASM_LONG ".uaword"
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. */
92 #undef ASM_OUTPUT_INTERNAL_LABEL
93 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
94 fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
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. */
99 #undef ASM_OUTPUT_INTERNAL_LABELREF
100 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
101 fprintf (FILE, ".L%s%d", PREFIX, NUM)
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'. */
108 #undef ASM_GENERATE_INTERNAL_LABEL
109 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
110 sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
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++ */
116 #undef STARTFILE_SPEC
117 #define STARTFILE_SPEC "%{!shared: \
121 %{pg:gcrt1.o%s gmon.o%s} \
124 %{ansi:values-Xc.o%s} \
126 %{traditional:values-Xt.o%s} \
127 %{!traditional:values-Xa.o%s}} \
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. */
136 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
139 %{pthreads:-lpthread} \
140 %{!pthreads:%{threads:-lthread}} \
144 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
146 /* This should be the same as in svr4.h, except with -R added. */
151 %{static:-dn -Bstatic} \
152 %{shared:-G -dy %{!mimpure-text:-z text}} \
153 %{symbolic:-Bsymbolic -G -dy -z text} \
158 %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
159 %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
160 %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
163 %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
164 %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
165 %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}} \
168 /* This defines which switch letters take arguments.
169 It is as in svr4.h but with -R added. */
171 #undef SWITCH_TAKES_ARG
172 #define SWITCH_TAKES_ARG(CHAR) \
173 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
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
185 /* But indicate that it isn't supported by the hardware. */
186 #define WIDEST_HARDWARE_FP_SIZE 64
188 #define STDC_0_IN_SYSTEM_HEADERS
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"
196 #undef INIT_SUBTARGET_OPTABS
197 #define INIT_SUBTARGET_OPTABS \
199 = init_one_libfunc (TARGET_ARCH64 ? "__ftol" : "__ftoll"); \
201 = init_one_libfunc (TARGET_ARCH64 ? "__ftoul" : "__ftoull"); \
203 = init_one_libfunc (TARGET_ARCH64 ? "__dtol" : "__dtoll"); \
205 = init_one_libfunc (TARGET_ARCH64 ? "__dtoul" : "__dtoull")
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
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_EPILOGUE + MASK_FPU + MASK_V8PLUS)
219 /* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
220 traps available which can get and set the condition codes
222 #undef MACHINE_STATE_SAVE
223 #define MACHINE_STATE_SAVE(ID) \
224 unsigned long int ms_flags, ms_saveret; \
225 asm volatile("ta 0x20\n\t" \
228 : "=r" (ms_flags), "=r" (ms_saveret));
230 #undef MACHINE_STATE_RESTORE
231 #define MACHINE_STATE_RESTORE(ID) \
232 asm volatile("mov %0, %%g1\n\t" \
236 : "r" (ms_flags), "r" (ms_saveret));
240 * Attempt to turn on access permissions for the stack.
242 * This code must be defined when compiling gcc but not when compiling
243 * libgcc2.a, unless we're generating code for 64 bits SPARC
245 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
246 * to run always. 2.6 can change the stack protection but has no way to
251 #define TRANSFER_FROM_TRAMPOLINE \
252 static int need_enable_exec_stack; \
254 static void check_enabling(void) __attribute__ ((constructor)); \
255 static void check_enabling(void) \
257 extern long sysconf(int); \
259 int prot = (int) sysconf(515 /*_SC_STACK_PROT */); \
261 need_enable_exec_stack = 1; \
265 __enable_execute_stack (addr) \
268 if (!need_enable_exec_stack) \
271 long size = getpagesize (); \
272 long mask = ~(size-1); \
273 char *page = (char *) (((long) addr) & mask); \
274 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
276 /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
277 if (mprotect (page, end - page, 7) < 0) \
278 perror ("mprotect of trampoline code"); \