Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / config / mips / netbsd.h
1 /* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
2    Copyright (C) 1993-2013 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 ("__ABICALLS__");                \
34                                                         \
35       if (mips_abi == ABI_EABI)                         \
36         builtin_define ("__mips_eabi");                 \
37       else if (mips_abi == ABI_N32)                     \
38         builtin_define ("__mips_n32");                  \
39       else if (mips_abi == ABI_64)                      \
40         builtin_define ("__mips_n64");                  \
41       else if (mips_abi == ABI_O64)                     \
42         builtin_define ("__mips_o64");                  \
43     }                                                   \
44   while (0)
45
46 /* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
47    Specifically, they define too many namespace-invasive macros.  Override
48    them here.  Note this is structured for easy comparison to the version
49    in mips.h.
50
51    FIXME: This probably isn't the best solution.  But in the absence
52    of something better, it will have to do, for now.  */
53
54 #undef TARGET_CPU_CPP_BUILTINS
55 #define TARGET_CPU_CPP_BUILTINS()                               \
56   do                                                            \
57     {                                                           \
58       builtin_assert ("cpu=mips");                              \
59       builtin_define ("__mips__");                              \
60       builtin_define ("_mips");                                 \
61                                                                 \
62       /* No _R3000 or _R4000.  */                               \
63       if (TARGET_64BIT)                                         \
64         builtin_define ("__mips64");                            \
65                                                                 \
66       if (TARGET_FLOAT64)                                       \
67         builtin_define ("__mips_fpr=64");                       \
68       else                                                      \
69         builtin_define ("__mips_fpr=32");                       \
70                                                                 \
71       if (TARGET_MIPS16)                                        \
72         builtin_define ("__mips16");                            \
73                                                                 \
74       MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);    \
75       MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);    \
76                                                                 \
77       if (ISA_MIPS1)                                            \
78         builtin_define ("__mips=1");                            \
79       else if (ISA_MIPS2)                                       \
80         builtin_define ("__mips=2");                            \
81       else if (ISA_MIPS3)                                       \
82         builtin_define ("__mips=3");                            \
83       else if (ISA_MIPS4)                                       \
84         builtin_define ("__mips=4");                            \
85       else if (ISA_MIPS32)                                      \
86         {                                                       \
87           builtin_define ("__mips=32");                         \
88           builtin_define ("__mips_isa_rev=1");                  \
89         }                                                       \
90       else if (ISA_MIPS32R2)                                    \
91         {                                                       \
92           builtin_define ("__mips=32");                         \
93           builtin_define ("__mips_isa_rev=2");                  \
94         }                                                       \
95       else if (ISA_MIPS64)                                      \
96         {                                                       \
97           builtin_define ("__mips=64");                         \
98           builtin_define ("__mips_isa_rev=1");                  \
99         }                                                       \
100                                                                 \
101       if (TARGET_HARD_FLOAT)                                    \
102         builtin_define ("__mips_hard_float");                   \
103       else if (TARGET_SOFT_FLOAT)                               \
104         builtin_define ("__mips_soft_float");                   \
105                                                                 \
106       if (TARGET_SINGLE_FLOAT)                                  \
107         builtin_define ("__mips_single_float");                 \
108                                                                 \
109       if (TARGET_BIG_ENDIAN)                                    \
110         builtin_define ("__MIPSEB__");                          \
111       else                                                      \
112         builtin_define ("__MIPSEL__");                          \
113                                                                 \
114       /* No language dialect defines.  */                       \
115                                                                 \
116       /* ABIs handled in TARGET_OS_CPP_BUILTINS.  */            \
117     }                                                           \
118   while (0)
119
120
121 /* Extra specs we need.  */
122 #undef SUBTARGET_EXTRA_SPECS
123 #define SUBTARGET_EXTRA_SPECS                                           \
124   { "netbsd_cpp_spec",          NETBSD_CPP_SPEC },                      \
125   { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF },                 \
126   { "netbsd_entry_point",       NETBSD_ENTRY_POINT },
127
128 /* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
129
130 #undef SUBTARGET_CPP_SPEC
131 #define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
132
133 /* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
134    This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
135    the MIPS target.  */
136
137 #undef LINK_SPEC
138 #define LINK_SPEC \
139   "%{EL:-m elf32lmip} \
140    %{EB:-m elf32bmip} \
141    %(endian_spec) \
142    %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} %{mips64} \
143    %(netbsd_link_spec)"
144
145 #define NETBSD_ENTRY_POINT "__start"
146
147 #undef SUBTARGET_ASM_SPEC
148 #define SUBTARGET_ASM_SPEC \
149   "%{!mno-abicalls: \
150      %{!fno-PIC:%{!fno-pic:-KPIC}}}"
151
152
153 /* -G is incompatible with -KPIC which is the default, so only allow objects
154    in the small data section if the user explicitly asks for it.  */
155
156 #undef MIPS_DEFAULT_GVALUE
157 #define MIPS_DEFAULT_GVALUE 0
158
159
160 #undef ASM_FINAL_SPEC
161 #undef SET_ASM_OP
162
163
164 /* NetBSD hasn't historically provided _flush_cache(), but rather
165    _cacheflush(), which takes the same arguments as the former.  */
166 #undef CACHE_FLUSH_FUNC
167 #define CACHE_FLUSH_FUNC "_cacheflush"
168
169
170 /* Make gcc agree with <machine/ansi.h> */
171
172 #undef WCHAR_TYPE
173 #define WCHAR_TYPE "int"
174
175 #undef WCHAR_TYPE_SIZE
176 #define WCHAR_TYPE_SIZE 32
177
178 #undef WINT_TYPE
179 #define WINT_TYPE "int"