netbsd.h revision 169690
1167802Sjkim/* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
2167802Sjkim   Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004
3238381Sjkim   Free Software Foundation, Inc.
4167802Sjkim
5167802SjkimThis file is part of GCC.
6167802Sjkim
7217365SjkimGCC is free software; you can redistribute it and/or modify
8298714Sjkimit under the terms of the GNU General Public License as published by
9167802Sjkimthe Free Software Foundation; either version 2, or (at your option)
10167802Sjkimany later version.
11217365Sjkim
12217365SjkimGCC is distributed in the hope that it will be useful,
13217365Sjkimbut WITHOUT ANY WARRANTY; without even the implied warranty of
14217365SjkimMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15217365SjkimGNU General Public License for more details.
16217365Sjkim
17217365SjkimYou should have received a copy of the GNU General Public License
18217365Sjkimalong with GCC; see the file COPYING.  If not, write to
19217365Sjkimthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20217365SjkimBoston, MA 02110-1301, USA.  */
21217365Sjkim
22217365Sjkim
23217365Sjkim/* Define default target values.  */
24217365Sjkim
25167802Sjkim#undef MACHINE_TYPE
26217365Sjkim#if TARGET_ENDIAN_DEFAULT != 0
27217365Sjkim#define MACHINE_TYPE "NetBSD/mipseb ELF"
28217365Sjkim#else
29167802Sjkim#define MACHINE_TYPE "NetBSD/mipsel ELF"
30217365Sjkim#endif
31217365Sjkim
32217365Sjkim#define TARGET_OS_CPP_BUILTINS()			\
33217365Sjkim  do							\
34217365Sjkim    {							\
35217365Sjkim      NETBSD_OS_CPP_BUILTINS_ELF();			\
36217365Sjkim      builtin_define ("__NO_LEADING_UNDERSCORES__");	\
37217365Sjkim      builtin_define ("__GP_SUPPORT__");		\
38217365Sjkim      if (TARGET_LONG64)				\
39217365Sjkim	builtin_define ("__LONG64");			\
40217365Sjkim							\
41217365Sjkim      if (TARGET_ABICALLS)				\
42217365Sjkim	builtin_define ("__ABICALLS__");		\
43167802Sjkim							\
44193341Sjkim      if (mips_abi == ABI_EABI)				\
45193341Sjkim	builtin_define ("__mips_eabi");			\
46228110Sjkim      else if (mips_abi == ABI_N32)			\
47167802Sjkim	builtin_define ("__mips_n32");			\
48167802Sjkim      else if (mips_abi == ABI_64)			\
49167802Sjkim	builtin_define ("__mips_n64");			\
50167802Sjkim      else if (mips_abi == ABI_O64)			\
51167802Sjkim	builtin_define ("__mips_o64");			\
52167802Sjkim    }							\
53272444Sjkim  while (0)
54167802Sjkim
55167802Sjkim/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
56167802Sjkim   Specifically, they define too many namespace-invasive macros.  Override
57238381Sjkim   them here.  Note this is structured for easy comparison to the version
58167802Sjkim   in mips.h.
59167802Sjkim
60167802Sjkim   FIXME: This probably isn't the best solution.  But in the absence
61167802Sjkim   of something better, it will have to do, for now.  */
62167802Sjkim
63167802Sjkim#undef TARGET_CPU_CPP_BUILTINS
64167802Sjkim#define TARGET_CPU_CPP_BUILTINS()				\
65167802Sjkim  do								\
66167802Sjkim    {								\
67167802Sjkim      builtin_assert ("cpu=mips");				\
68167802Sjkim      builtin_define ("__mips__");				\
69167802Sjkim      builtin_define ("_mips");					\
70167802Sjkim								\
71167802Sjkim      /* No _R3000 or _R4000.  */				\
72167802Sjkim      if (TARGET_64BIT)						\
73167802Sjkim	builtin_define ("__mips64");				\
74167802Sjkim								\
75167802Sjkim      if (TARGET_FLOAT64)					\
76167802Sjkim	builtin_define ("__mips_fpr=64");			\
77167802Sjkim      else							\
78167802Sjkim	builtin_define ("__mips_fpr=32");			\
79167802Sjkim								\
80167802Sjkim      if (TARGET_MIPS16)					\
81167802Sjkim	builtin_define ("__mips16");				\
82167802Sjkim								\
83167802Sjkim      MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);	\
84167802Sjkim      MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);	\
85167802Sjkim								\
86167802Sjkim      if (ISA_MIPS1)						\
87167802Sjkim	builtin_define ("__mips=1");				\
88167802Sjkim      else if (ISA_MIPS2)					\
89167802Sjkim	builtin_define ("__mips=2");				\
90167802Sjkim      else if (ISA_MIPS3)					\
91167802Sjkim	builtin_define ("__mips=3");				\
92167802Sjkim      else if (ISA_MIPS4)					\
93167802Sjkim	builtin_define ("__mips=4");				\
94167802Sjkim      else if (ISA_MIPS32)					\
95167802Sjkim	{							\
96167802Sjkim	  builtin_define ("__mips=32");				\
97167802Sjkim	  builtin_define ("__mips_isa_rev=1");			\
98167802Sjkim	}							\
99167802Sjkim      else if (ISA_MIPS32R2)					\
100272444Sjkim	{							\
101272444Sjkim	  builtin_define ("__mips=32");				\
102272444Sjkim	  builtin_define ("__mips_isa_rev=2");			\
103167802Sjkim	}							\
104167802Sjkim      else if (ISA_MIPS64)					\
105167802Sjkim	{							\
106167802Sjkim	  builtin_define ("__mips=64");				\
107167802Sjkim	  builtin_define ("__mips_isa_rev=1");			\
108167802Sjkim	}							\
109167802Sjkim								\
110167802Sjkim      if (TARGET_HARD_FLOAT)					\
111167802Sjkim	builtin_define ("__mips_hard_float");			\
112167802Sjkim      else if (TARGET_SOFT_FLOAT)				\
113167802Sjkim	builtin_define ("__mips_soft_float");			\
114167802Sjkim								\
115167802Sjkim      if (TARGET_SINGLE_FLOAT)					\
116167802Sjkim	builtin_define ("__mips_single_float");			\
117167802Sjkim								\
118167802Sjkim      if (TARGET_BIG_ENDIAN)					\
119167802Sjkim	builtin_define ("__MIPSEB__");				\
120167802Sjkim      else							\
121167802Sjkim	builtin_define ("__MIPSEL__");				\
122167802Sjkim								\
123167802Sjkim      /* No language dialect defines.  */			\
124167802Sjkim								\
125167802Sjkim      /* ABIs handled in TARGET_OS_CPP_BUILTINS.  */		\
126167802Sjkim    }								\
127167802Sjkim  while (0)
128167802Sjkim
129167802Sjkim
130167802Sjkim/* Clean up after the generic MIPS/ELF configuration.  */
131167802Sjkim#undef MD_EXEC_PREFIX
132167802Sjkim#undef MD_STARTFILE_PREFIX
133167802Sjkim
134167802Sjkim/* Extra specs we need.  */
135167802Sjkim#undef SUBTARGET_EXTRA_SPECS
136167802Sjkim#define SUBTARGET_EXTRA_SPECS						\
137167802Sjkim  { "netbsd_cpp_spec",		NETBSD_CPP_SPEC },			\
138167802Sjkim  { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },			\
139167802Sjkim  { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
140167802Sjkim
141167802Sjkim/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
142167802Sjkim
143167802Sjkim#undef SUBTARGET_CPP_SPEC
144167802Sjkim#define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
145167802Sjkim
146167802Sjkim/* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
147167802Sjkim   This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
148167802Sjkim   the MIPS target.  */
149167802Sjkim
150243347Sjkim#undef LINK_SPEC
151243347Sjkim#define LINK_SPEC \
152243347Sjkim  "%{EL:-m elf32lmip} \
153167802Sjkim   %{EB:-m elf32bmip} \
154167802Sjkim   %(endian_spec) \
155167802Sjkim   %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} %{mips64} \
156167802Sjkim   %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
157167802Sjkim   %(netbsd_link_spec)"
158167802Sjkim
159167802Sjkim#define NETBSD_ENTRY_POINT "__start"
160167802Sjkim
161167802Sjkim#undef SUBTARGET_ASM_SPEC
162167802Sjkim#define SUBTARGET_ASM_SPEC \
163167802Sjkim  "%{!mno-abicalls: \
164167802Sjkim     %{!fno-PIC:%{!fno-pic:-KPIC}}}"
165167802Sjkim
166167802Sjkim
167167802Sjkim/* -G is incompatible with -KPIC which is the default, so only allow objects
168167802Sjkim   in the small data section if the user explicitly asks for it.  */
169167802Sjkim
170167802Sjkim#undef MIPS_DEFAULT_GVALUE
171167802Sjkim#define MIPS_DEFAULT_GVALUE 0
172167802Sjkim
173167802Sjkim
174167802Sjkim/* This defines which switch letters take arguments.  -G is a MIPS
175167802Sjkim   special.  */
176167802Sjkim
177167802Sjkim#undef SWITCH_TAKES_ARG
178167802Sjkim#define SWITCH_TAKES_ARG(CHAR)						\
179167802Sjkim  (DEFAULT_SWITCH_TAKES_ARG (CHAR)					\
180167802Sjkim   || (CHAR) == 'R'							\
181167802Sjkim   || (CHAR) == 'G')
182167802Sjkim
183228110Sjkim
184228110Sjkim#undef ASM_FINAL_SPEC
185228110Sjkim#undef SET_ASM_OP
186228110Sjkim
187228110Sjkim
188228110Sjkim/* NetBSD hasn't historically provided _flush_cache(), but rather
189228110Sjkim   _cacheflush(), which takes the same arguments as the former.  */
190228110Sjkim#undef CACHE_FLUSH_FUNC
191228110Sjkim#define CACHE_FLUSH_FUNC "_cacheflush"
192228110Sjkim
193228110Sjkim
194228110Sjkim/* Make gcc agree with <machine/ansi.h> */
195228110Sjkim
196228110Sjkim#undef WCHAR_TYPE
197228110Sjkim#define WCHAR_TYPE "int"
198228110Sjkim
199228110Sjkim#undef WCHAR_TYPE_SIZE
200228110Sjkim#define WCHAR_TYPE_SIZE 32
201228110Sjkim
202228110Sjkim#undef WINT_TYPE
203228110Sjkim#define WINT_TYPE "int"
204228110Sjkim