annotate gcc/common/config/rs6000/rs6000-common.c @ 145:1830386684a0

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