1 /* Common hooks for Renesas / SuperH SH.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
26 #include "common/common-target.h"
27 #include "common/common-target-def.h"
31 /* Set default optimization options. */
32 static const struct default_options sh_option_optimization_table
[] =
34 { OPT_LEVELS_1_PLUS
, OPT_fomit_frame_pointer
, NULL
, 1 },
35 { OPT_LEVELS_1_PLUS_SPEED_ONLY
, OPT_mdiv_
, "inv:minlat", 1 },
36 { OPT_LEVELS_SIZE
, OPT_mdiv_
, SH_DIV_STR_FOR_SIZE
, 1 },
37 { OPT_LEVELS_0_ONLY
, OPT_mdiv_
, "", 1 },
38 { OPT_LEVELS_SIZE
, OPT_mcbranchdi
, NULL
, 0 },
39 /* We can't meaningfully test TARGET_SHMEDIA here, because -m
40 options haven't been parsed yet, hence we'd read only the
41 default. sh_target_reg_class will return NO_REGS if this is
42 not SHMEDIA, so it's OK to always set
43 flag_branch_target_load_optimize. */
44 { OPT_LEVELS_2_PLUS
, OPT_fbranch_target_load_optimize
, NULL
, 1 },
45 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
48 /* Implement TARGET_HANDLE_OPTION. */
51 sh_handle_option (struct gcc_options
*opts
,
52 struct gcc_options
*opts_set ATTRIBUTE_UNUSED
,
53 const struct cl_decoded_option
*decoded
,
54 location_t loc ATTRIBUTE_UNUSED
)
56 size_t code
= decoded
->opt_index
;
61 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH1
;
65 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2
;
69 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A
;
74 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_NOFPU
;
79 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE
;
82 case OPT_m2a_single_only
:
84 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2A_SINGLE_ONLY
;
88 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH2E
;
92 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3
;
96 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH3E
;
103 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4
;
107 case OPT_m4_100_nofpu
:
108 case OPT_m4_200_nofpu
:
109 case OPT_m4_300_nofpu
:
114 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_NOFPU
;
118 case OPT_m4_100_single
:
119 case OPT_m4_200_single
:
120 case OPT_m4_300_single
:
122 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE
;
125 case OPT_m4_single_only
:
126 case OPT_m4_100_single_only
:
127 case OPT_m4_200_single_only
:
128 case OPT_m4_300_single_only
:
130 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4_SINGLE_ONLY
;
134 opts
->x_target_flags
= (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A
;
140 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_NOFPU
;
145 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE
;
148 case OPT_m4a_single_only
:
150 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH4A_SINGLE_ONLY
;
155 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_32MEDIA
;
158 case OPT_m5_32media_nofpu
:
160 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_32MEDIA_NOFPU
;
165 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_64MEDIA
;
168 case OPT_m5_64media_nofpu
:
170 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_64MEDIA_NOFPU
;
175 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_COMPACT
;
178 case OPT_m5_compact_nofpu
:
180 = (opts
->x_target_flags
& ~MASK_ARCH
) | SELECT_SH5_COMPACT_NOFPU
;
188 /* Implement TARGET_OPTION_INIT_STRUCT. */
190 sh_option_init_struct (struct gcc_options
*opts
)
192 /* We can't meaningfully test TARGET_SH2E / TARGET_IEEE
193 here, so leave it to TARGET_OPTION_OVERRIDE to set
194 flag_finite_math_only. We set it to 2 here so we know if the user
195 explicitly requested this to be on or off. */
196 opts
->x_flag_finite_math_only
= 2;
199 #undef TARGET_OPTION_OPTIMIZATION_TABLE
200 #define TARGET_OPTION_OPTIMIZATION_TABLE sh_option_optimization_table
201 #undef TARGET_OPTION_INIT_STRUCT
202 #define TARGET_OPTION_INIT_STRUCT sh_option_init_struct
203 #undef TARGET_DEFAULT_TARGET_FLAGS
204 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
205 #undef TARGET_HANDLE_OPTION
206 #define TARGET_HANDLE_OPTION sh_handle_option
208 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;