1 /* Common hooks for Renesas / SuperH SH.
2 Copyright (C) 1993-2023 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"
29 /* Set default optimization options. */
30 static const struct default_options sh_option_optimization_table
[] =
32 { OPT_LEVELS_SIZE
, OPT_mdiv_
, SH_DIV_STR_FOR_SIZE
, 1 },
33 { OPT_LEVELS_0_ONLY
, OPT_mdiv_
, "", 1 },
34 { OPT_LEVELS_ALL
, OPT__param_simultaneous_prefetches_
, NULL
, 2 },
35 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
38 /* Implement TARGET_HANDLE_OPTION. */
41 sh_handle_option (struct gcc_options
*opts
,
42 struct gcc_options
*opts_set ATTRIBUTE_UNUSED
,
43 const struct cl_decoded_option
*decoded
,
44 location_t loc ATTRIBUTE_UNUSED
)
46 size_t code
= decoded
->opt_index
;
51 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH1
;
55 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2
;
59 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A
;
64 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_NOFPU
;
69 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE
;
72 case OPT_m2a_single_only
:
74 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE_ONLY
;
78 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2E
;
82 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3
;
86 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3E
;
93 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4
;
97 case OPT_m4_100_nofpu
:
98 case OPT_m4_200_nofpu
:
99 case OPT_m4_300_nofpu
:
104 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_NOFPU
;
108 case OPT_m4_100_single
:
109 case OPT_m4_200_single
:
110 case OPT_m4_300_single
:
112 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE
;
115 case OPT_m4_single_only
:
116 case OPT_m4_100_single_only
:
117 case OPT_m4_200_single_only
:
118 case OPT_m4_300_single_only
:
120 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE_ONLY
;
124 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A
;
130 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_NOFPU
;
135 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE
;
138 case OPT_m4a_single_only
:
140 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE_ONLY
;
148 #undef TARGET_OPTION_OPTIMIZATION_TABLE
149 #define TARGET_OPTION_OPTIMIZATION_TABLE sh_option_optimization_table
150 #undef TARGET_DEFAULT_TARGET_FLAGS
151 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
152 #undef TARGET_HANDLE_OPTION
153 #define TARGET_HANDLE_OPTION sh_handle_option
155 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;