1 /* Common hooks for Renesas / SuperH SH. 2 Copyright (C) 1993-2015 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 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) 9 any later version. 10 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. 15 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/>. */ 19 20 #include "config.h" 21 #include "system.h" 22 #include "coretypes.h" 23 #include "tm.h" 24 #include "common/common-target.h" 25 #include "common/common-target-def.h" 26 #include "opts.h" 27 #include "flags.h" 28 #include "params.h" 29 30 /* Set default optimization options. */ 31 static const struct default_options sh_option_optimization_table[] = 32 { 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 } 44 }; 45 46 /* Implement TARGET_HANDLE_OPTION. */ 47 48 static bool 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) 53 { 54 size_t code = decoded->opt_index; 55 56 switch (code) 57 { 58 case OPT_m1: 59 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH1; 60 return true; 61 62 case OPT_m2: 63 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2; 64 return true; 65 66 case OPT_m2a: 67 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A; 68 return true; 69 70 case OPT_m2a_nofpu: 71 opts->x_target_flags 72 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_NOFPU; 73 return true; 74 75 case OPT_m2a_single: 76 opts->x_target_flags 77 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE; 78 return true; 79 80 case OPT_m2a_single_only: 81 opts->x_target_flags 82 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE_ONLY; 83 return true; 84 85 case OPT_m2e: 86 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2E; 87 return true; 88 89 case OPT_m3: 90 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3; 91 return true; 92 93 case OPT_m3e: 94 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3E; 95 return true; 96 97 case OPT_m4: 98 case OPT_m4_100: 99 case OPT_m4_200: 100 case OPT_m4_300: 101 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4; 102 return true; 103 104 case OPT_m4_nofpu: 105 case OPT_m4_100_nofpu: 106 case OPT_m4_200_nofpu: 107 case OPT_m4_300_nofpu: 108 case OPT_m4_340: 109 case OPT_m4_400: 110 case OPT_m4_500: 111 opts->x_target_flags 112 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_NOFPU; 113 return true; 114 115 case OPT_m4_single: 116 case OPT_m4_100_single: 117 case OPT_m4_200_single: 118 case OPT_m4_300_single: 119 opts->x_target_flags 120 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE; 121 return true; 122 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: 127 opts->x_target_flags 128 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE_ONLY; 129 return true; 130 131 case OPT_m4a: 132 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A; 133 return true; 134 135 case OPT_m4a_nofpu: 136 case OPT_m4al: 137 opts->x_target_flags 138 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_NOFPU; 139 return true; 140 141 case OPT_m4a_single: 142 opts->x_target_flags 143 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE; 144 return true; 145 146 case OPT_m4a_single_only: 147 opts->x_target_flags 148 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE_ONLY; 149 return true; 150 151 case OPT_m5_32media: 152 opts->x_target_flags 153 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_32MEDIA; 154 return true; 155 156 case OPT_m5_32media_nofpu: 157 opts->x_target_flags 158 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_32MEDIA_NOFPU; 159 return true; 160 161 case OPT_m5_64media: 162 opts->x_target_flags 163 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_64MEDIA; 164 return true; 165 166 case OPT_m5_64media_nofpu: 167 opts->x_target_flags 168 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_64MEDIA_NOFPU; 169 return true; 170 171 case OPT_m5_compact: 172 opts->x_target_flags 173 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_COMPACT; 174 return true; 175 176 case OPT_m5_compact_nofpu: 177 opts->x_target_flags 178 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_COMPACT_NOFPU; 179 return true; 180 181 default: 182 return true; 183 } 184 } 185 186 /* Implement TARGET_OPTION_DEFAULT_PARAMS. */ 187 static void 188 sh_option_default_params (void) 189 { 190 set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 2); 191 } 192 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 201 202 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; 203