xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/mips/netbsd.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1 /* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
2    Copyright (C) 1993-2020 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10 
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 
21 /* Define default target values.  */
22 
23 #define TARGET_OS_CPP_BUILTINS()			\
24   do							\
25     {							\
26       NETBSD_OS_CPP_BUILTINS_ELF();			\
27       builtin_define ("__NO_LEADING_UNDERSCORES__");	\
28       builtin_define ("__GP_SUPPORT__");		\
29       if (TARGET_LONG64)				\
30 	builtin_define ("__LONG64");			\
31 							\
32       if (TARGET_ABICALLS)				\
33 	builtin_define ("__mips_abicalls");		\
34 							\
35     if (mips_abi == ABI_N32)				\
36       {							\
37 	builtin_define ("__mips_n32");			\
38         builtin_define ("_ABIN32=2");			\
39         builtin_define ("_MIPS_SIM=_ABIN32");		\
40         builtin_define ("_MIPS_SZLONG=32");		\
41         builtin_define ("_MIPS_SZPTR=32");		\
42       }							\
43       else if (mips_abi == ABI_64)			\
44       {							\
45 	builtin_define ("__mips_n64");			\
46         builtin_define ("_ABI64=3");			\
47         builtin_define ("_MIPS_SIM=_ABI64");		\
48         builtin_define ("_MIPS_SZLONG=64");		\
49         builtin_define ("_MIPS_SZPTR=64");		\
50       }							\
51       else if (mips_abi == ABI_O64)			\
52       {							\
53 	builtin_define ("__mips_o64");			\
54         builtin_define ("_ABIO64=4");			\
55         builtin_define ("_MIPS_SIM=_ABIO64");		\
56         builtin_define ("_MIPS_SZLONG=64");		\
57         builtin_define ("_MIPS_SZPTR=64");		\
58     }							\
59     else if (mips_abi == ABI_EABI)			\
60       {							\
61 	builtin_define ("__mips_eabi");			\
62         builtin_define ("_ABIEMB=5");			\
63         builtin_define ("_MIPS_SIM=_ABIEMB");		\
64 	if (TARGET_LONG64)				\
65           builtin_define ("_MIPS_SZLONG=64");		\
66 	else						\
67           builtin_define ("_MIPS_SZLONG=32");		\
68 	if (TARGET_64BIT)				\
69           builtin_define ("_MIPS_SZPTR=64");		\
70 	else						\
71           builtin_define ("_MIPS_SZPTR=32");		\
72       }							\
73     else						\
74       {							\
75 	builtin_define ("__mips_o32");			\
76 	builtin_define ("_ABIO32=1");			\
77 	builtin_define ("_MIPS_SIM=_ABIO32");		\
78         builtin_define ("_MIPS_SZLONG=32");		\
79         builtin_define ("_MIPS_SZPTR=32");		\
80       }							\
81     if (TARGET_FLOAT64)					\
82       builtin_define ("_MIPS_FPSET=32");		\
83     else						\
84       builtin_define ("_MIPS_FPSET=16");		\
85     							\
86     builtin_define ("_MIPS_SZINT=32");			\
87   } while (0)
88 
89 /* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
90    Specifically, they define too many namespace-invasive macros.  Override
91    them here.  Note this is structured for easy comparison to the version
92    in mips.h.
93 
94    FIXME: This probably isn't the best solution.  But in the absence
95    of something better, it will have to do, for now.  */
96 
97 #undef TARGET_CPU_CPP_BUILTINS
98 #define TARGET_CPU_CPP_BUILTINS()				\
99   do								\
100     {								\
101       builtin_assert ("cpu=mips");				\
102       builtin_define ("__mips__");				\
103       builtin_define ("_mips");					\
104 								\
105       /* No _R3000 or _R4000.  */				\
106       if (TARGET_64BIT)						\
107 	builtin_define ("__mips64");				\
108 								\
109       if (TARGET_FLOAT64)					\
110 	builtin_define ("__mips_fpr=64");			\
111       else							\
112 	builtin_define ("__mips_fpr=32");			\
113 								\
114       if (TARGET_MIPS16)					\
115 	builtin_define ("__mips16");				\
116 								\
117       MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);	\
118       MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);	\
119 								\
120       if (ISA_MIPS1)						\
121 	builtin_define ("__mips=1");				\
122       else if (ISA_MIPS2)					\
123 	builtin_define ("__mips=2");				\
124       else if (ISA_MIPS3)					\
125 	builtin_define ("__mips=3");				\
126       else if (ISA_MIPS4)					\
127 	builtin_define ("__mips=4");				\
128       else if (mips_isa >= 32 && mips_isa < 64)			\
129 	builtin_define ("__mips=32");				\
130       else if (mips_isa >= 64)					\
131 	builtin_define ("__mips=64");				\
132       if (mips_isa_rev > 0)					\
133         builtin_define_with_int_value ("__mips_isa_rev",	\
134                                        mips_isa_rev);		\
135 								\
136       if (TARGET_HARD_FLOAT)					\
137 	builtin_define ("__mips_hard_float");			\
138       else if (TARGET_SOFT_FLOAT)				\
139 	builtin_define ("__mips_soft_float");			\
140 								\
141       if (TARGET_SINGLE_FLOAT)					\
142 	builtin_define ("__mips_single_float");			\
143 								\
144       if (TARGET_BIG_ENDIAN)					\
145 	builtin_define ("__MIPSEB__");				\
146       else							\
147 	builtin_define ("__MIPSEL__");				\
148 								\
149       if (TARGET_OCTEON)					\
150 	builtin_define ("__OCTEON__");				\
151 								\
152       if (ISA_HAS_POP)						\
153 	builtin_define ("__mips_popcount");			\
154       /* No language dialect defines.  */			\
155 								\
156       /* ABIs handled in TARGET_OS_CPP_BUILTINS.  */		\
157     }								\
158   while (0)
159 
160 
161 /* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
162 
163 #undef SUBTARGET_CPP_SPEC
164 #define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
165 
166 /* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
167    This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
168    the MIPS target.  */
169 
170 #undef LINK_SPEC
171 #define LINK_SPEC \
172   "%{EL:-m elf32ltsmip} \
173    %{EB:-m elf32btsmip} \
174    %(endian_spec) \
175    %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} \
176    %{mips32r6} %{mips64} %{mips64r2} %{mips64r6} \
177    %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
178    %(netbsd_link_spec)"
179 
180 #define NETBSD_ENTRY_POINT "__start"
181 
182 #undef SUBTARGET_ASM_SPEC
183 #define SUBTARGET_ASM_SPEC \
184   "%{!mno-abicalls: \
185      %{!fno-PIC:%{!fno-pic:-KPIC}}}"
186 
187 
188 /* -G is incompatible with -KPIC which is the default, so only allow objects
189    in the small data section if the user explicitly asks for it.  */
190 
191 #undef MIPS_DEFAULT_GVALUE
192 #define MIPS_DEFAULT_GVALUE 0
193 
194 
195 #undef ASM_FINAL_SPEC
196 #undef SET_ASM_OP
197 
198 
199 /* NetBSD hasn't historically provided _flush_cache(), but rather
200    _cacheflush(), which takes the same arguments as the former.  */
201 #undef CACHE_FLUSH_FUNC
202 #define CACHE_FLUSH_FUNC "_cacheflush"
203 
204 
205 /* Make gcc agree with <machine/ansi.h> */
206 
207 #undef SIZE_TYPE
208 #define SIZE_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \
209 		   ? "long unsigned int" : "unsigned int")
210 
211 #undef PTRDIFF_TYPE
212 #define PTRDIFF_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \
213 		      ? "long int" : "int")
214 
215 #undef INTPTR_TYPE
216 #define INTPTR_TYPE PTRDIFF_TYPE
217 
218 #undef UINTPTR_TYPE
219 #define UINTPTR_TYPE SIZE_TYPE
220 
221 #undef WCHAR_TYPE
222 #define WCHAR_TYPE "int"
223 
224 #undef WCHAR_TYPE_SIZE
225 #define WCHAR_TYPE_SIZE 32
226 
227 #undef WINT_TYPE
228 #define WINT_TYPE "int"
229 
230 #undef TARGET_WRITABLE_EH_FRAME
231 #define TARGET_WRITABLE_EH_FRAME 0
232 
233 #define	MIPS_USE_GCC_DEFAULT_OUTPUT_SOURCE_FILENAME
234