1cddc6afb96b9ea3f3b397db35fc94fa8f609fd6
[platform/upstream/gcc48.git] / gcc / config / sparc / netbsd-elf.h
1 /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
2    and NetBSD/sparc64.
3    Copyright (C) 2002-2013 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 /* CPP defines used by all NetBSD targets.  */
39 #undef CPP_SUBTARGET_SPEC
40 #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
41
42 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
43 #undef SIZE_TYPE
44 #define SIZE_TYPE "long unsigned int"
45
46 #undef PTRDIFF_TYPE
47 #define PTRDIFF_TYPE "long int"
48
49 /* This is the char to use for continuation (in case we need to turn
50    continuation back on).  */
51 #undef DBX_CONTIN_CHAR
52 #define DBX_CONTIN_CHAR '?'
53
54 #undef  LOCAL_LABEL_PREFIX
55 #define LOCAL_LABEL_PREFIX  "."
56
57 /* This is how to store into the string LABEL
58    the symbol_ref name of an internal numbered label where
59    PREFIX is the class of label and NUM is the number within the class.
60    This is suitable for output with `assemble_name'.  */
61
62 #undef  ASM_GENERATE_INTERNAL_LABEL
63 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
64   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
65
66 #undef USER_LABEL_PREFIX
67 #define USER_LABEL_PREFIX ""
68
69 #undef ASM_SPEC
70 #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} \
71 %(asm_cpu) %(asm_arch) %(asm_relax)"
72
73 #undef STDC_0_IN_SYSTEM_HEADERS
74
75 #define HAVE_ENABLE_EXECUTE_STACK
76
77 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
78    description, allowing one to build 32-bit or 64-bit applications
79    on either.  We define the sparc & sparc64 versions of things,
80    occasionally a neutral version (should be the same as "netbsd-elf.h")
81    and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
82    we choose the correct version.  */
83
84 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
85    definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
86    not have a default place to find these libraries..  */
87
88 /* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
89    platform here.  */
90
91 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
92  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
93 /* A 64 bit v9 compiler with stack-bias,
94    in a Medium/Low code model environment.  */
95
96 #undef TARGET_DEFAULT
97 #define TARGET_DEFAULT \
98   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
99    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
100
101 #undef SPARC_DEFAULT_CMODEL
102 #define SPARC_DEFAULT_CMODEL CM_MEDANY
103
104 #endif
105
106 /* CC1_SPEC for NetBSD/sparc.  */
107 #define CC1_SPEC32 \
108  "%{m32:%{m64:%emay not use both -m32 and -m64}} \
109   %{m64: \
110     -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
111     %{!mcpu*:%{!mv8plus:-mcpu=ultrasparc}} \
112     %{!mno-vis:%{!mcpu=v9:-mvis}} \
113     %{p:-mcmodel=medlow} \
114     %{pg:-mcmodel=medlow}}"
115
116 #define CC1_SPEC64 \
117  "%{m32:%{m64:%emay not use both -m32 and -m64}} \
118   %{m32: \
119     -mptr32 -mno-stack-bias \
120     %{!mlong-double-128:-mlong-double-64} \
121     %{!mcpu*:%{!mv8plus:-mcpu=cypress}}} \
122   %{!m32: \
123     %{p:-mcmodel=medlow} \
124     %{pg:-mcmodel=medlow}}"
125
126 /* Make sure we use the right output format.  Pick a default and then
127    make sure -m32/-m64 switch to the right one.  */
128
129 #define LINK_ARCH32_SPEC "-m elf32_sparc"
130
131 #define LINK_ARCH64_SPEC "-m elf64_sparc"
132
133 #define LINK_ARCH_SPEC \
134  "%{m32:%(link_arch32)} \
135   %{m64:%(link_arch64)} \
136   %{!m32:%{!m64:%(link_arch_default)}}"
137
138 #undef LINK_SPEC
139 #define LINK_SPEC \
140  "%(link_arch) \
141   %{!mno-relax:%{!r:-relax}} \
142   %(netbsd_link_spec)"
143
144 #define NETBSD_ENTRY_POINT "__start"
145
146 #if DEFAULT_ARCH32_P
147 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
148 #else
149 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
150 #endif
151
152 /* What extra spec entries do we need?  */
153 #undef SUBTARGET_EXTRA_SPECS
154 #define SUBTARGET_EXTRA_SPECS \
155   { "link_arch32",              LINK_ARCH32_SPEC }, \
156   { "link_arch64",              LINK_ARCH64_SPEC }, \
157   { "link_arch_default",        LINK_ARCH_DEFAULT_SPEC }, \
158   { "link_arch",                LINK_ARCH_SPEC }, \
159   { "netbsd_cpp_spec",          NETBSD_CPP_SPEC }, \
160   { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF }, \
161   { "netbsd_entry_point",       NETBSD_ENTRY_POINT },
162
163
164 /* Build a compiler that supports -m32 and -m64?  */
165
166 #ifdef SPARC_BI_ARCH
167
168 #undef LONG_DOUBLE_TYPE_SIZE
169 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
170
171 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
172 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
173 #else
174 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
175 #endif
176
177 #undef  CC1_SPEC
178 #if DEFAULT_ARCH32_P
179 #define CC1_SPEC CC1_SPEC32
180 #else
181 #define CC1_SPEC CC1_SPEC64
182 #endif
183
184 #if DEFAULT_ARCH32_P
185 #define MULTILIB_DEFAULTS { "m32" }
186 #else
187 #define MULTILIB_DEFAULTS { "m64" }
188 #endif
189
190 #else   /* SPARC_BI_ARCH */
191
192 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
193  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
194
195 #undef LONG_DOUBLE_TYPE_SIZE
196 #define LONG_DOUBLE_TYPE_SIZE 128
197
198 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
199 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
200
201 #undef  CC1_SPEC
202 #define CC1_SPEC CC1_SPEC64
203
204 #else   /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
205         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
206
207 /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
208    for 32-bit code, unlike Solaris.  */
209
210 #undef LONG_DOUBLE_TYPE_SIZE
211 #define LONG_DOUBLE_TYPE_SIZE 64
212
213 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
214 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
215
216 #undef  CC1_SPEC
217 #define CC1_SPEC CC1_SPEC32
218
219 #endif  /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
220         || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
221
222 #endif  /* SPARC_BI_ARCH */
223
224 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
225 #undef CTORS_SECTION_ASM_OP
226 #undef DTORS_SECTION_ASM_OP