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