150276Speter/* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
2262629Sdelphij   Copyright (C) 1993-2015 Free Software Foundation, Inc.
350276Speter
450276SpeterThis file is part of GCC.
550276Speter
650276SpeterGCC is free software; you can redistribute it and/or modify
750276Speterit under the terms of the GNU General Public License as published by
850276Speterthe Free Software Foundation; either version 3, or (at your option)
950276Speterany later version.
1050276Speter
1150276SpeterGCC is distributed in the hope that it will be useful,
1250276Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of
1350276SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1450276SpeterGNU General Public License for more details.
1550276Speter
1650276SpeterYou should have received a copy of the GNU General Public License
1750276Speteralong with GCC; see the file COPYING3.  If not see
1850276Speter<http://www.gnu.org/licenses/>.  */
1950276Speter
2050276Speter
2150276Speter/* Define default target values.  */
2250276Speter
2350276Speter#define TARGET_OS_CPP_BUILTINS()			\
2450276Speter  do							\
2550276Speter    {							\
2650276Speter      NETBSD_OS_CPP_BUILTINS_ELF();			\
2750276Speter      builtin_define ("__NO_LEADING_UNDERSCORES__");	\
2850276Speter      builtin_define ("__GP_SUPPORT__");		\
2950276Speter      if (TARGET_LONG64)				\
30166124Srafan	builtin_define ("__LONG64");			\
3150276Speter							\
3250276Speter      if (TARGET_ABICALLS)				\
3350276Speter	builtin_define ("__ABICALLS__");		\
3450276Speter							\
35262629Sdelphij      if (mips_abi == ABI_32)				\
3650276Speter	builtin_define ("__mips_o32");			\
3750276Speter      else if (mips_abi == ABI_EABI)			\
3850276Speter	builtin_define ("__mips_eabi");			\
3950276Speter      else if (mips_abi == ABI_N32)			\
4050276Speter	builtin_define ("__mips_n32");			\
4150276Speter      else if (mips_abi == ABI_64)			\
4250276Speter	builtin_define ("__mips_n64");			\
4350276Speter      else if (mips_abi == ABI_O64)			\
4450276Speter	builtin_define ("__mips_o64");			\
4550276Speter    }							\
4650276Speter  while (0)
4750276Speter
4850276Speter/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
49166124Srafan   Specifically, they define too many namespace-invasive macros.  Override
5050276Speter   them here.  Note this is structured for easy comparison to the version
5176726Speter   in mips.h.
52166124Srafan
5350276Speter   FIXME: This probably isn't the best solution.  But in the absence
5450276Speter   of something better, it will have to do, for now.  */
5550276Speter
56262629Sdelphij#undef TARGET_CPU_CPP_BUILTINS
57166124Srafan#define TARGET_CPU_CPP_BUILTINS()				\
5850276Speter  do								\
59174993Srafan    {								\
60166124Srafan      builtin_assert ("cpu=mips");				\
6150276Speter      builtin_define ("__mips__");				\
6250276Speter      builtin_define ("_mips");					\
63262629Sdelphij								\
6450276Speter      /* No _R3000 or _R4000.  */				\
6550276Speter      if (TARGET_64BIT)						\
66166124Srafan	builtin_define ("__mips64");				\
6750276Speter								\
68166124Srafan      if (TARGET_FLOAT64)					\
6950276Speter	builtin_define ("__mips_fpr=64");			\
70166124Srafan      else							\
71166124Srafan	builtin_define ("__mips_fpr=32");			\
7250276Speter								\
7350276Speter      if (TARGET_MIPS16)					\
7450276Speter	builtin_define ("__mips16");				\
7550276Speter								\
7650276Speter      MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);	\
77166124Srafan      MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);	\
7850276Speter								\
7950276Speter      if (ISA_MIPS1)						\
8050276Speter	builtin_define ("__mips=1");				\
8150276Speter      else if (ISA_MIPS2)					\
82166124Srafan	builtin_define ("__mips=2");				\
8350276Speter      else if (ISA_MIPS3)					\
84166124Srafan	builtin_define ("__mips=3");				\
8550276Speter      else if (ISA_MIPS4)					\
8650276Speter	builtin_define ("__mips=4");				\
8750276Speter      else if (mips_isa >= 32 && mips_isa < 64)			\
88	builtin_define ("__mips=32");				\
89      else if (mips_isa >= 64)					\
90	builtin_define ("__mips=64");				\
91      if (mips_isa_rev > 0)					\
92        builtin_define_with_int_value ("__mips_isa_rev",	\
93                                       mips_isa_rev);		\
94								\
95      if (TARGET_HARD_FLOAT)					\
96	builtin_define ("__mips_hard_float");			\
97      else if (TARGET_SOFT_FLOAT)				\
98	builtin_define ("__mips_soft_float");			\
99								\
100      if (TARGET_SINGLE_FLOAT)					\
101	builtin_define ("__mips_single_float");			\
102								\
103      if (TARGET_BIG_ENDIAN)					\
104	builtin_define ("__MIPSEB__");				\
105      else							\
106	builtin_define ("__MIPSEL__");				\
107								\
108      /* No language dialect defines.  */			\
109								\
110      /* ABIs handled in TARGET_OS_CPP_BUILTINS.  */		\
111    }								\
112  while (0)
113
114
115/* Extra specs we need.  */
116#undef SUBTARGET_EXTRA_SPECS
117#define SUBTARGET_EXTRA_SPECS						\
118  { "netbsd_cpp_spec",		NETBSD_CPP_SPEC },			\
119  { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },			\
120  { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
121
122/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
123
124#undef SUBTARGET_CPP_SPEC
125#define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
126
127/* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
128   This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
129   the MIPS target.  */
130
131#undef LINK_SPEC
132#define LINK_SPEC \
133  "%{EL:-m elf32lmip} \
134   %{EB:-m elf32bmip} \
135   %(endian_spec) \
136   %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} \
137   %{mips32r6} %{mips64} %{mips64r6} \
138   %(netbsd_link_spec)"
139
140#define NETBSD_ENTRY_POINT "__start"
141
142#undef SUBTARGET_ASM_SPEC
143#define SUBTARGET_ASM_SPEC \
144  "%{!mno-abicalls: \
145     %{!fno-PIC:%{!fno-pic:-KPIC}}}"
146
147
148/* -G is incompatible with -KPIC which is the default, so only allow objects
149   in the small data section if the user explicitly asks for it.  */
150
151#undef MIPS_DEFAULT_GVALUE
152#define MIPS_DEFAULT_GVALUE 0
153
154
155#undef ASM_FINAL_SPEC
156#undef SET_ASM_OP
157
158
159/* NetBSD hasn't historically provided _flush_cache(), but rather
160   _cacheflush(), which takes the same arguments as the former.  */
161#undef CACHE_FLUSH_FUNC
162#define CACHE_FLUSH_FUNC "_cacheflush"
163
164
165/* Make gcc agree with <machine/ansi.h> */
166
167#undef WCHAR_TYPE
168#define WCHAR_TYPE "int"
169
170#undef WCHAR_TYPE_SIZE
171#define WCHAR_TYPE_SIZE 32
172
173#undef WINT_TYPE
174#define WINT_TYPE "int"
175