]> gcc.gnu.org Git - gcc.git/blob - gcc/common/config/rs6000/rs6000-common.c
target-def.h (TARGET_HAVE_NAMED_SECTIONS): Move to common/common-target-def.h.
[gcc.git] / gcc / common / config / rs6000 / rs6000-common.c
1 /* Common hooks for IBM RS/6000.
2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 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 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "diagnostic-core.h"
26 #include "tm.h"
27 #include "common/common-target.h"
28 #include "common/common-target-def.h"
29 #include "opts.h"
30 #include "flags.h"
31
32 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
33 static const struct default_options rs6000_option_optimization_table[] =
34 {
35 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
36 { OPT_LEVELS_NONE, 0, NULL, 0 }
37 };
38
39 /* Implement TARGET_OPTION_INIT_STRUCT. */
40
41 static void
42 rs6000_option_init_struct (struct gcc_options *opts)
43 {
44 if (DEFAULT_ABI == ABI_DARWIN)
45 /* The Darwin libraries never set errno, so we might as well
46 avoid calling them when that's the only reason we would. */
47 opts->x_flag_errno_math = 0;
48
49 /* Enable section anchors by default. */
50 if (!TARGET_MACHO)
51 opts->x_flag_section_anchors = 1;
52 }
53
54 /* If not otherwise specified by a target, make 'long double' equivalent to
55 'double'. */
56
57 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
58 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
59 #endif
60
61 /* Implement TARGET_HANDLE_OPTION. */
62
63 static bool
64 rs6000_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
65 const struct cl_decoded_option *decoded,
66 location_t loc)
67 {
68 enum fpu_type_t fpu_type = FPU_NONE;
69 char *p, *q;
70 size_t code = decoded->opt_index;
71 const char *arg = decoded->arg;
72 int value = decoded->value;
73
74 switch (code)
75 {
76 case OPT_mno_power:
77 opts->x_target_flags &= ~(MASK_POWER | MASK_POWER2
78 | MASK_MULTIPLE | MASK_STRING);
79 opts_set->x_target_flags |= (MASK_POWER | MASK_POWER2
80 | MASK_MULTIPLE | MASK_STRING);
81 break;
82 case OPT_mno_powerpc:
83 opts->x_target_flags &= ~(MASK_POWERPC | MASK_PPC_GPOPT
84 | MASK_PPC_GFXOPT | MASK_POWERPC64);
85 opts_set->x_target_flags |= (MASK_POWERPC | MASK_PPC_GPOPT
86 | MASK_PPC_GFXOPT | MASK_POWERPC64);
87 break;
88 case OPT_mfull_toc:
89 opts->x_target_flags &= ~MASK_MINIMAL_TOC;
90 opts->x_TARGET_NO_FP_IN_TOC = 0;
91 opts->x_TARGET_NO_SUM_IN_TOC = 0;
92 opts_set->x_target_flags |= MASK_MINIMAL_TOC;
93 #ifdef TARGET_USES_SYSV4_OPT
94 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
95 just the same as -mminimal-toc. */
96 opts->x_target_flags |= MASK_MINIMAL_TOC;
97 opts_set->x_target_flags |= MASK_MINIMAL_TOC;
98 #endif
99 break;
100
101 #ifdef TARGET_USES_SYSV4_OPT
102 case OPT_mtoc:
103 /* Make -mtoc behave like -mminimal-toc. */
104 opts->x_target_flags |= MASK_MINIMAL_TOC;
105 opts_set->x_target_flags |= MASK_MINIMAL_TOC;
106 break;
107 #endif
108
109 #ifdef TARGET_USES_AIX64_OPT
110 case OPT_maix64:
111 #else
112 case OPT_m64:
113 #endif
114 opts->x_target_flags |= MASK_POWERPC64 | MASK_POWERPC;
115 opts->x_target_flags |= ~opts_set->x_target_flags & MASK_PPC_GFXOPT;
116 opts_set->x_target_flags |= MASK_POWERPC64 | MASK_POWERPC;
117 break;
118
119 #ifdef TARGET_USES_AIX64_OPT
120 case OPT_maix32:
121 #else
122 case OPT_m32:
123 #endif
124 opts->x_target_flags &= ~MASK_POWERPC64;
125 opts_set->x_target_flags |= MASK_POWERPC64;
126 break;
127
128 case OPT_mminimal_toc:
129 if (value == 1)
130 {
131 opts->x_TARGET_NO_FP_IN_TOC = 0;
132 opts->x_TARGET_NO_SUM_IN_TOC = 0;
133 }
134 break;
135
136 case OPT_mpower:
137 if (value == 1)
138 {
139 opts->x_target_flags |= (MASK_MULTIPLE | MASK_STRING);
140 opts_set->x_target_flags |= (MASK_MULTIPLE | MASK_STRING);
141 }
142 break;
143
144 case OPT_mpower2:
145 if (value == 1)
146 {
147 opts->x_target_flags |= (MASK_POWER | MASK_MULTIPLE | MASK_STRING);
148 opts_set->x_target_flags |= (MASK_POWER
149 | MASK_MULTIPLE
150 | MASK_STRING);
151 }
152 break;
153
154 case OPT_mpowerpc_gpopt:
155 case OPT_mpowerpc_gfxopt:
156 if (value == 1)
157 {
158 opts->x_target_flags |= MASK_POWERPC;
159 opts_set->x_target_flags |= MASK_POWERPC;
160 }
161 break;
162
163 case OPT_mdebug_:
164 p = ASTRDUP (arg);
165 opts->x_rs6000_debug = 0;
166
167 while ((q = strtok (p, ",")) != NULL)
168 {
169 unsigned mask = 0;
170 bool invert;
171
172 p = NULL;
173 if (*q == '!')
174 {
175 invert = true;
176 q++;
177 }
178 else
179 invert = false;
180
181 if (! strcmp (q, "all"))
182 mask = MASK_DEBUG_ALL;
183 else if (! strcmp (q, "stack"))
184 mask = MASK_DEBUG_STACK;
185 else if (! strcmp (q, "arg"))
186 mask = MASK_DEBUG_ARG;
187 else if (! strcmp (q, "reg"))
188 mask = MASK_DEBUG_REG;
189 else if (! strcmp (q, "addr"))
190 mask = MASK_DEBUG_ADDR;
191 else if (! strcmp (q, "cost"))
192 mask = MASK_DEBUG_COST;
193 else if (! strcmp (q, "target"))
194 mask = MASK_DEBUG_TARGET;
195 else
196 error_at (loc, "unknown -mdebug-%s switch", q);
197
198 if (invert)
199 opts->x_rs6000_debug &= ~mask;
200 else
201 opts->x_rs6000_debug |= mask;
202 }
203 break;
204
205 #ifdef TARGET_USES_SYSV4_OPT
206 case OPT_mrelocatable:
207 if (value == 1)
208 {
209 opts->x_target_flags |= MASK_MINIMAL_TOC;
210 opts_set->x_target_flags |= MASK_MINIMAL_TOC;
211 opts->x_TARGET_NO_FP_IN_TOC = 1;
212 }
213 break;
214
215 case OPT_mrelocatable_lib:
216 if (value == 1)
217 {
218 opts->x_target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
219 opts_set->x_target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC;
220 opts->x_TARGET_NO_FP_IN_TOC = 1;
221 }
222 else
223 {
224 opts->x_target_flags &= ~MASK_RELOCATABLE;
225 opts_set->x_target_flags |= MASK_RELOCATABLE;
226 }
227 break;
228 #endif
229
230 case OPT_mabi_altivec:
231 /* Enabling the AltiVec ABI turns off the SPE ABI. */
232 opts->x_rs6000_spe_abi = 0;
233 break;
234
235 case OPT_mabi_spe:
236 opts->x_rs6000_altivec_abi = 0;
237 break;
238
239 case OPT_mlong_double_:
240 if (value != 64 && value != 128)
241 {
242 error_at (loc, "unknown switch -mlong-double-%s", arg);
243 opts->x_rs6000_long_double_type_size
244 = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
245 return false;
246 }
247 break;
248
249 case OPT_msingle_float:
250 if (!TARGET_SINGLE_FPU)
251 warning_at (loc, 0,
252 "-msingle-float option equivalent to -mhard-float");
253 /* -msingle-float implies -mno-double-float and TARGET_HARD_FLOAT. */
254 opts->x_rs6000_double_float = 0;
255 opts->x_target_flags &= ~MASK_SOFT_FLOAT;
256 opts_set->x_target_flags |= MASK_SOFT_FLOAT;
257 break;
258
259 case OPT_mdouble_float:
260 /* -mdouble-float implies -msingle-float and TARGET_HARD_FLOAT. */
261 opts->x_rs6000_single_float = 1;
262 opts->x_target_flags &= ~MASK_SOFT_FLOAT;
263 opts_set->x_target_flags |= MASK_SOFT_FLOAT;
264 break;
265
266 case OPT_msimple_fpu:
267 if (!TARGET_SINGLE_FPU)
268 warning_at (loc, 0, "-msimple-fpu option ignored");
269 break;
270
271 case OPT_mhard_float:
272 /* -mhard_float implies -msingle-float and -mdouble-float. */
273 opts->x_rs6000_single_float = opts->x_rs6000_double_float = 1;
274 break;
275
276 case OPT_msoft_float:
277 /* -msoft_float implies -mnosingle-float and -mnodouble-float. */
278 opts->x_rs6000_single_float = opts->x_rs6000_double_float = 0;
279 break;
280
281 case OPT_mfpu_:
282 fpu_type = (enum fpu_type_t) value;
283 if (fpu_type != FPU_NONE)
284 {
285 /* If -mfpu is not none, then turn off SOFT_FLOAT, turn on
286 HARD_FLOAT. */
287 opts->x_target_flags &= ~MASK_SOFT_FLOAT;
288 opts_set->x_target_flags |= MASK_SOFT_FLOAT;
289 opts->x_rs6000_xilinx_fpu = 1;
290 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_SF_FULL)
291 opts->x_rs6000_single_float = 1;
292 if (fpu_type == FPU_DF_LITE || fpu_type == FPU_DF_FULL)
293 opts->x_rs6000_single_float = opts->x_rs6000_double_float = 1;
294 if (fpu_type == FPU_SF_LITE || fpu_type == FPU_DF_LITE)
295 opts->x_rs6000_simple_fpu = 1;
296 }
297 else
298 {
299 /* -mfpu=none is equivalent to -msoft-float. */
300 opts->x_target_flags |= MASK_SOFT_FLOAT;
301 opts_set->x_target_flags |= MASK_SOFT_FLOAT;
302 opts->x_rs6000_single_float = opts->x_rs6000_double_float = 0;
303 }
304 break;
305
306 case OPT_mrecip:
307 opts->x_rs6000_recip_name = (value) ? "default" : "none";
308 break;
309 }
310 return true;
311 }
312
313 #undef TARGET_HANDLE_OPTION
314 #define TARGET_HANDLE_OPTION rs6000_handle_option
315
316 #undef TARGET_OPTION_INIT_STRUCT
317 #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
318
319 #undef TARGET_OPTION_OPTIMIZATION_TABLE
320 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
321
322 #undef TARGET_DEFAULT_TARGET_FLAGS
323 #define TARGET_DEFAULT_TARGET_FLAGS \
324 (TARGET_DEFAULT)
325
326 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
This page took 0.051787 seconds and 5 git commands to generate.