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