1 /* Common hooks for IBM RS/6000.
2 Copyright (C) 1991-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
22 #include "coretypes.h"
23 #include "diagnostic-core.h"
25 #include "common/common-target.h"
26 #include "common/common-target-def.h"
31 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
32 static const struct default_options rs6000_option_optimization_table
[] =
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 }
39 /* Implement TARGET_OPTION_INIT_STRUCT. */
42 rs6000_option_init_struct (struct gcc_options
*opts
)
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;
49 /* Enable section anchors by default. */
51 opts
->x_flag_section_anchors
= 1;
54 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */
57 rs6000_option_default_params (void)
59 /* Double growth factor to counter reduced min jump length. */
60 set_default_param_value (PARAM_MAX_GROW_COPY_BB_INSNS
, 16);
63 /* If not otherwise specified by a target, make 'long double' equivalent to
66 #ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE
67 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
70 /* Implement TARGET_HANDLE_OPTION. */
73 rs6000_handle_option (struct gcc_options
*opts
, struct gcc_options
*opts_set
,
74 const struct cl_decoded_option
*decoded
,
77 enum fpu_type_t fpu_type
= FPU_NONE
;
79 size_t code
= decoded
->opt_index
;
80 const char *arg
= decoded
->arg
;
81 int value
= decoded
->value
;
86 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_MINIMAL_TOC
;
87 opts
->x_TARGET_NO_FP_IN_TOC
= 0;
88 opts
->x_TARGET_NO_SUM_IN_TOC
= 0;
89 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
90 #ifdef TARGET_USES_SYSV4_OPT
91 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be
92 just the same as -mminimal-toc. */
93 opts
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
94 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
98 #ifdef TARGET_USES_SYSV4_OPT
100 /* Make -mtoc behave like -mminimal-toc. */
101 opts
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
102 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
106 #ifdef TARGET_USES_AIX64_OPT
111 opts
->x_rs6000_isa_flags
|= OPTION_MASK_POWERPC64
;
112 opts
->x_rs6000_isa_flags
|= (~opts_set
->x_rs6000_isa_flags
113 & OPTION_MASK_PPC_GFXOPT
);
114 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_POWERPC64
;
117 #ifdef TARGET_USES_AIX64_OPT
122 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_POWERPC64
;
123 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_POWERPC64
;
126 case OPT_mminimal_toc
:
129 opts
->x_TARGET_NO_FP_IN_TOC
= 0;
130 opts
->x_TARGET_NO_SUM_IN_TOC
= 0;
134 case OPT_mpowerpc_gpopt
:
135 case OPT_mpowerpc_gfxopt
:
140 opts
->x_rs6000_debug
= 0;
142 while ((q
= strtok (p
, ",")) != NULL
)
156 if (! strcmp (q
, "all"))
157 mask
= MASK_DEBUG_ALL
;
158 else if (! strcmp (q
, "stack"))
159 mask
= MASK_DEBUG_STACK
;
160 else if (! strcmp (q
, "arg"))
161 mask
= MASK_DEBUG_ARG
;
162 else if (! strcmp (q
, "reg"))
163 mask
= MASK_DEBUG_REG
;
164 else if (! strcmp (q
, "addr"))
165 mask
= MASK_DEBUG_ADDR
;
166 else if (! strcmp (q
, "cost"))
167 mask
= MASK_DEBUG_COST
;
168 else if (! strcmp (q
, "target"))
169 mask
= MASK_DEBUG_TARGET
;
170 else if (! strcmp (q
, "builtin"))
171 mask
= MASK_DEBUG_BUILTIN
;
173 error_at (loc
, "unknown -mdebug-%s switch", q
);
176 opts
->x_rs6000_debug
&= ~mask
;
178 opts
->x_rs6000_debug
|= mask
;
182 #ifdef TARGET_USES_SYSV4_OPT
183 case OPT_mrelocatable
:
186 opts
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
187 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_MINIMAL_TOC
;
188 opts
->x_TARGET_NO_FP_IN_TOC
= 1;
192 case OPT_mrelocatable_lib
:
195 opts
->x_rs6000_isa_flags
|= (OPTION_MASK_RELOCATABLE
196 | OPTION_MASK_MINIMAL_TOC
);
197 opts_set
->x_rs6000_isa_flags
|= (OPTION_MASK_RELOCATABLE
198 | OPTION_MASK_MINIMAL_TOC
);
199 opts
->x_TARGET_NO_FP_IN_TOC
= 1;
203 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_RELOCATABLE
;
204 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_RELOCATABLE
;
209 case OPT_mlong_double_
:
210 if (value
!= 64 && value
!= 128)
212 error_at (loc
, "unknown switch -mlong-double-%s", arg
);
213 opts
->x_rs6000_long_double_type_size
214 = RS6000_DEFAULT_LONG_DOUBLE_SIZE
;
219 case OPT_msingle_float
:
220 if (!TARGET_SINGLE_FPU
)
222 "-msingle-float option equivalent to -mhard-float");
223 /* -msingle-float implies -mno-double-float and TARGET_HARD_FLOAT. */
224 opts
->x_rs6000_double_float
= 0;
225 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_SOFT_FLOAT
;
226 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_SOFT_FLOAT
;
229 case OPT_mdouble_float
:
230 /* -mdouble-float implies -msingle-float and TARGET_HARD_FLOAT. */
231 opts
->x_rs6000_single_float
= 1;
232 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_SOFT_FLOAT
;
233 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_SOFT_FLOAT
;
236 case OPT_msimple_fpu
:
237 if (!TARGET_SINGLE_FPU
)
238 warning_at (loc
, 0, "-msimple-fpu option ignored");
241 case OPT_mhard_float
:
242 /* -mhard_float implies -msingle-float and -mdouble-float. */
243 opts
->x_rs6000_single_float
= opts
->x_rs6000_double_float
= 1;
246 case OPT_msoft_float
:
247 /* -msoft_float implies -mnosingle-float and -mnodouble-float. */
248 opts
->x_rs6000_single_float
= opts
->x_rs6000_double_float
= 0;
252 fpu_type
= (enum fpu_type_t
) value
;
253 if (fpu_type
!= FPU_NONE
)
255 /* If -mfpu is not none, then turn off SOFT_FLOAT, turn on
257 opts
->x_rs6000_isa_flags
&= ~OPTION_MASK_SOFT_FLOAT
;
258 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_SOFT_FLOAT
;
259 opts
->x_rs6000_xilinx_fpu
= 1;
260 if (fpu_type
== FPU_SF_LITE
|| fpu_type
== FPU_SF_FULL
)
261 opts
->x_rs6000_single_float
= 1;
262 if (fpu_type
== FPU_DF_LITE
|| fpu_type
== FPU_DF_FULL
)
263 opts
->x_rs6000_single_float
= opts
->x_rs6000_double_float
= 1;
264 if (fpu_type
== FPU_SF_LITE
|| fpu_type
== FPU_DF_LITE
)
265 opts
->x_rs6000_simple_fpu
= 1;
269 /* -mfpu=none is equivalent to -msoft-float. */
270 opts
->x_rs6000_isa_flags
|= OPTION_MASK_SOFT_FLOAT
;
271 opts_set
->x_rs6000_isa_flags
|= OPTION_MASK_SOFT_FLOAT
;
272 opts
->x_rs6000_single_float
= opts
->x_rs6000_double_float
= 0;
277 opts
->x_rs6000_recip_name
= (value
) ? "default" : "none";
283 /* -fsplit-stack uses a field in the TCB, available with glibc-2.19.
284 We also allow 2.18 because alignment padding guarantees that the
285 space is available there too. */
288 rs6000_supports_split_stack (bool report
,
289 struct gcc_options
*opts ATTRIBUTE_UNUSED
)
291 #ifndef TARGET_GLIBC_MAJOR
292 #define TARGET_GLIBC_MAJOR 0
294 #ifndef TARGET_GLIBC_MINOR
295 #define TARGET_GLIBC_MINOR 0
297 /* Note: Can't test DEFAULT_ABI here, it isn't set until later. */
298 if (TARGET_GLIBC_MAJOR
* 1000 + TARGET_GLIBC_MINOR
>= 2018
304 error ("%<-fsplit-stack%> currently only supported on PowerPC64 GNU/Linux with glibc-2.18 or later");
308 #undef TARGET_HANDLE_OPTION
309 #define TARGET_HANDLE_OPTION rs6000_handle_option
311 #undef TARGET_OPTION_INIT_STRUCT
312 #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
314 #undef TARGET_OPTION_DEFAULT_PARAMS
315 #define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params
317 #undef TARGET_OPTION_OPTIMIZATION_TABLE
318 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
320 #undef TARGET_SUPPORTS_SPLIT_STACK
321 #define TARGET_SUPPORTS_SPLIT_STACK rs6000_supports_split_stack
323 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;