]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/common/config/rs6000/rs6000-common.c
Remove gcc/params.* files.
[thirdparty/gcc.git] / gcc / common / config / rs6000 / rs6000-common.c
1 /* Common hooks for IBM RS/6000.
2 Copyright (C) 1991-2019 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 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"
29
30 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
31 static const struct default_options rs6000_option_optimization_table[] =
32 {
33 /* Split multi-word types early. */
34 { OPT_LEVELS_ALL, OPT_fsplit_wide_types_early, NULL, 1 },
35 /* Enable -fsched-pressure for first pass instruction scheduling. */
36 { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 },
37 /* Enable -munroll-only-small-loops with -funroll-loops to unroll small
38 loops at -O2 and above by default. */
39 { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_funroll_loops, NULL, 1 },
40 { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_munroll_only_small_loops, NULL, 1 },
41 /* -fweb and -frename-registers are useless in general for rs6000,
42 turn them off. */
43 { OPT_LEVELS_ALL, OPT_fweb, NULL, 0 },
44 { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 },
45 { OPT_LEVELS_NONE, 0, NULL, 0 }
46 };
47
48 /* Implement TARGET_OPTION_INIT_STRUCT. */
49
50 static void
51 rs6000_option_init_struct (struct gcc_options *opts)
52 {
53 if (DEFAULT_ABI == ABI_DARWIN)
54 /* The Darwin libraries never set errno, so we might as well
55 avoid calling them when that's the only reason we would. */
56 opts->x_flag_errno_math = 0;
57
58 /* Enable section anchors by default. */
59 if (!TARGET_MACHO)
60 opts->x_flag_section_anchors = 1;
61
62 /* By default, always emit DWARF-2 unwind info. This allows debugging
63 without maintaining a stack frame back-chain. It also allows the
64 debugger to find out where on-entry register values are stored at any
65 point in a function, without having to analyze the executable code (which
66 isn't even possible to do in the general case). */
67 #ifdef OBJECT_FORMAT_ELF
68 opts->x_flag_asynchronous_unwind_tables = 1;
69 #endif
70 }
71
72 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */
73
74 static void
75 rs6000_option_default_params (void)
76 {
77 /* Double growth factor to counter reduced min jump length. */
78 param_max_grow_copy_bb_insns = 16;
79 }
80
81 /* If not otherwise specified by a target, make 'long double' equivalent to
82 'double'. */
83
84 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
85 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
86 #endif
87
88 /* Implement TARGET_HANDLE_OPTION. */
89
90 static bool
91 rs6000_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
92 const struct cl_decoded_option *decoded,
93 location_t loc)
94 {
95 char *p, *q;
96 size_t code = decoded->opt_index;
97 const char *arg = decoded->arg;
98 int value = decoded->value;
99
100 switch (code)
101 {
102 case OPT_mfull_toc:
103 opts->x_rs6000_isa_flags &= ~OPTION_MASK_MINIMAL_TOC;
104 opts->x_TARGET_NO_FP_IN_TOC = 0;
105 opts->x_TARGET_NO_SUM_IN_TOC = 0;
106 opts_set->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
107 #ifdef TARGET_USES_SYSV4_OPT
108 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
109 just the same as -mminimal-toc. */
110 opts->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
111 opts_set->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
112 #endif
113 break;
114
115 #ifdef TARGET_USES_SYSV4_OPT
116 case OPT_mtoc:
117 /* Make -mtoc behave like -mminimal-toc. */
118 opts->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
119 opts_set->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
120 break;
121 #endif
122
123 #ifdef TARGET_USES_AIX64_OPT
124 case OPT_maix64:
125 #else
126 case OPT_m64:
127 #endif
128 opts->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64;
129 opts->x_rs6000_isa_flags |= (~opts_set->x_rs6000_isa_flags
130 & OPTION_MASK_PPC_GFXOPT);
131 opts_set->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64;
132 break;
133
134 #ifdef TARGET_USES_AIX64_OPT
135 case OPT_maix32:
136 #else
137 case OPT_m32:
138 #endif
139 opts->x_rs6000_isa_flags &= ~OPTION_MASK_POWERPC64;
140 opts_set->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64;
141 break;
142
143 case OPT_mminimal_toc:
144 if (value == 1)
145 {
146 opts->x_TARGET_NO_FP_IN_TOC = 0;
147 opts->x_TARGET_NO_SUM_IN_TOC = 0;
148 }
149 break;
150
151 case OPT_mpowerpc_gpopt:
152 case OPT_mpowerpc_gfxopt:
153 break;
154
155 case OPT_mdebug_:
156 p = ASTRDUP (arg);
157 opts->x_rs6000_debug = 0;
158
159 while ((q = strtok (p, ",")) != NULL)
160 {
161 unsigned mask = 0;
162 bool invert;
163
164 p = NULL;
165 if (*q == '!')
166 {
167 invert = true;
168 q++;
169 }
170 else
171 invert = false;
172
173 if (! strcmp (q, "all"))
174 mask = MASK_DEBUG_ALL;
175 else if (! strcmp (q, "stack"))
176 mask = MASK_DEBUG_STACK;
177 else if (! strcmp (q, "arg"))
178 mask = MASK_DEBUG_ARG;
179 else if (! strcmp (q, "reg"))
180 mask = MASK_DEBUG_REG;
181 else if (! strcmp (q, "addr"))
182 mask = MASK_DEBUG_ADDR;
183 else if (! strcmp (q, "cost"))
184 mask = MASK_DEBUG_COST;
185 else if (! strcmp (q, "target"))
186 mask = MASK_DEBUG_TARGET;
187 else if (! strcmp (q, "builtin"))
188 mask = MASK_DEBUG_BUILTIN;
189 else
190 error_at (loc, "unknown %<-mdebug-%s%> switch", q);
191
192 if (invert)
193 opts->x_rs6000_debug &= ~mask;
194 else
195 opts->x_rs6000_debug |= mask;
196 }
197 break;
198
199 #ifdef TARGET_USES_SYSV4_OPT
200 case OPT_mrelocatable:
201 if (value == 1)
202 {
203 opts->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
204 opts_set->x_rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;
205 opts->x_TARGET_NO_FP_IN_TOC = 1;
206 }
207 break;
208
209 case OPT_mrelocatable_lib:
210 if (value == 1)
211 {
212 opts->x_rs6000_isa_flags |= (OPTION_MASK_RELOCATABLE
213 | OPTION_MASK_MINIMAL_TOC);
214 opts_set->x_rs6000_isa_flags |= (OPTION_MASK_RELOCATABLE
215 | OPTION_MASK_MINIMAL_TOC);
216 opts->x_TARGET_NO_FP_IN_TOC = 1;
217 }
218 else
219 {
220 opts->x_rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE;
221 opts_set->x_rs6000_isa_flags |= OPTION_MASK_RELOCATABLE;
222 }
223 break;
224 #endif
225
226 case OPT_mlong_double_:
227 if (value != 64 && value != 128)
228 {
229 error_at (loc, "unknown switch %<-mlong-double-%s%>", arg);
230 opts->x_rs6000_long_double_type_size
231 = RS6000_DEFAULT_LONG_DOUBLE_SIZE;
232 return false;
233 }
234 break;
235
236 case OPT_mrecip:
237 opts->x_rs6000_recip_name = (value) ? "default" : "none";
238 break;
239 }
240 return true;
241 }
242
243 /* -fsplit-stack uses a field in the TCB, available with glibc-2.19.
244 We also allow 2.18 because alignment padding guarantees that the
245 space is available there too. */
246
247 static bool
248 rs6000_supports_split_stack (bool report,
249 struct gcc_options *opts ATTRIBUTE_UNUSED)
250 {
251 #ifndef TARGET_GLIBC_MAJOR
252 #define TARGET_GLIBC_MAJOR 0
253 #endif
254 #ifndef TARGET_GLIBC_MINOR
255 #define TARGET_GLIBC_MINOR 0
256 #endif
257 /* Note: Can't test DEFAULT_ABI here, it isn't set until later. */
258 if (TARGET_GLIBC_MAJOR * 1000 + TARGET_GLIBC_MINOR >= 2018
259 && TARGET_64BIT
260 && TARGET_ELF)
261 return true;
262
263 if (report)
264 error ("%<-fsplit-stack%> currently only supported on PowerPC64 GNU/Linux with glibc-2.18 or later");
265 return false;
266 }
267
268 #undef TARGET_HANDLE_OPTION
269 #define TARGET_HANDLE_OPTION rs6000_handle_option
270
271 #undef TARGET_OPTION_INIT_STRUCT
272 #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
273
274 #undef TARGET_OPTION_DEFAULT_PARAMS
275 #define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params
276
277 #undef TARGET_OPTION_OPTIMIZATION_TABLE
278 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
279
280 #undef TARGET_SUPPORTS_SPLIT_STACK
281 #define TARGET_SUPPORTS_SPLIT_STACK rs6000_supports_split_stack
282
283 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;