1 /* Common hooks for Renesas / SuperH SH.
2 Copyright (C) 1993-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public 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"
24 #include "common/common-target.h"
25 #include "common/common-target-def.h"
30 /* Set default optimization options. */
31 static const struct default_options sh_option_optimization_table
[] =
33 { OPT_LEVELS_1_PLUS
, OPT_fomit_frame_pointer
, NULL
, 1 },
34 { OPT_LEVELS_1_PLUS_SPEED_ONLY
, OPT_mdiv_
, "inv:minlat", 1 },
35 { OPT_LEVELS_SIZE
, OPT_mdiv_
, SH_DIV_STR_FOR_SIZE
, 1 },
36 { OPT_LEVELS_0_ONLY
, OPT_mdiv_
, "", 1 },
37 /* We can't meaningfully test TARGET_SHMEDIA here, because -m
38 options haven't been parsed yet, hence we'd read only the
39 default. sh_target_reg_class will return NO_REGS if this is
40 not SHMEDIA, so it's OK to always set
41 flag_branch_target_load_optimize. */
42 { OPT_LEVELS_2_PLUS
, OPT_fbranch_target_load_optimize
, NULL
, 1 },
43 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
46 /* Implement TARGET_HANDLE_OPTION. */
49 sh_handle_option (struct gcc_options
*opts
,
50 struct gcc_options
*opts_set ATTRIBUTE_UNUSED
,
51 const struct cl_decoded_option
*decoded
,
52 location_t loc ATTRIBUTE_UNUSED
)
54 size_t code
= decoded
->opt_index
;
59 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH1
;
63 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2
;
67 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A
;
72 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_NOFPU
;
77 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE
;
80 case OPT_m2a_single_only
:
82 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE_ONLY
;
86 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2E
;
90 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3
;
94 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3E
;
101 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4
;
105 case OPT_m4_100_nofpu
:
106 case OPT_m4_200_nofpu
:
107 case OPT_m4_300_nofpu
:
112 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_NOFPU
;
116 case OPT_m4_100_single
:
117 case OPT_m4_200_single
:
118 case OPT_m4_300_single
:
120 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE
;
123 case OPT_m4_single_only
:
124 case OPT_m4_100_single_only
:
125 case OPT_m4_200_single_only
:
126 case OPT_m4_300_single_only
:
128 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE_ONLY
;
132 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A
;
138 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_NOFPU
;
143 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE
;
146 case OPT_m4a_single_only
:
148 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE_ONLY
;
153 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_32MEDIA
;
156 case OPT_m5_32media_nofpu
:
158 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_32MEDIA_NOFPU
;
163 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_64MEDIA
;
166 case OPT_m5_64media_nofpu
:
168 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_64MEDIA_NOFPU
;
173 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_COMPACT
;
176 case OPT_m5_compact_nofpu
:
178 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_COMPACT_NOFPU
;
186 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */
188 sh_option_default_params (void)
190 set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES
, 2);
193 #undef TARGET_OPTION_OPTIMIZATION_TABLE
194 #define TARGET_OPTION_OPTIMIZATION_TABLE sh_option_optimization_table
195 #undef TARGET_OPTION_DEFAULT_PARAMS
196 #define TARGET_OPTION_DEFAULT_PARAMS sh_option_default_params
197 #undef TARGET_DEFAULT_TARGET_FLAGS
198 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
199 #undef TARGET_HANDLE_OPTION
200 #define TARGET_HANDLE_OPTION sh_handle_option
202 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;