]> gcc.gnu.org Git - gcc.git/blob - gcc/common/config/sh/sh-common.c
target-def.h (TARGET_HAVE_NAMED_SECTIONS): Move to common/common-target-def.h.
[gcc.git] / gcc / common / config / sh / sh-common.c
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.
5
6 This file is part of GCC.
7
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)
11 any later version.
12
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.
17
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/>. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "common/common-target.h"
27 #include "common/common-target-def.h"
28 #include "opts.h"
29 #include "flags.h"
30
31 /* Set default optimization options. */
32 static const struct default_options sh_option_optimization_table[] =
33 {
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 }
46 };
47
48 /* Implement TARGET_HANDLE_OPTION. */
49
50 static bool
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)
55 {
56 size_t code = decoded->opt_index;
57
58 switch (code)
59 {
60 case OPT_m1:
61 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH1;
62 return true;
63
64 case OPT_m2:
65 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2;
66 return true;
67
68 case OPT_m2a:
69 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A;
70 return true;
71
72 case OPT_m2a_nofpu:
73 opts->x_target_flags
74 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_NOFPU;
75 return true;
76
77 case OPT_m2a_single:
78 opts->x_target_flags
79 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE;
80 return true;
81
82 case OPT_m2a_single_only:
83 opts->x_target_flags
84 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE_ONLY;
85 return true;
86
87 case OPT_m2e:
88 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2E;
89 return true;
90
91 case OPT_m3:
92 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3;
93 return true;
94
95 case OPT_m3e:
96 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3E;
97 return true;
98
99 case OPT_m4:
100 case OPT_m4_100:
101 case OPT_m4_200:
102 case OPT_m4_300:
103 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4;
104 return true;
105
106 case OPT_m4_nofpu:
107 case OPT_m4_100_nofpu:
108 case OPT_m4_200_nofpu:
109 case OPT_m4_300_nofpu:
110 case OPT_m4_340:
111 case OPT_m4_400:
112 case OPT_m4_500:
113 opts->x_target_flags
114 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_NOFPU;
115 return true;
116
117 case OPT_m4_single:
118 case OPT_m4_100_single:
119 case OPT_m4_200_single:
120 case OPT_m4_300_single:
121 opts->x_target_flags
122 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE;
123 return true;
124
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:
129 opts->x_target_flags
130 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE_ONLY;
131 return true;
132
133 case OPT_m4a:
134 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A;
135 return true;
136
137 case OPT_m4a_nofpu:
138 case OPT_m4al:
139 opts->x_target_flags
140 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_NOFPU;
141 return true;
142
143 case OPT_m4a_single:
144 opts->x_target_flags
145 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE;
146 return true;
147
148 case OPT_m4a_single_only:
149 opts->x_target_flags
150 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE_ONLY;
151 return true;
152
153 case OPT_m5_32media:
154 opts->x_target_flags
155 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_32MEDIA;
156 return true;
157
158 case OPT_m5_32media_nofpu:
159 opts->x_target_flags
160 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_32MEDIA_NOFPU;
161 return true;
162
163 case OPT_m5_64media:
164 opts->x_target_flags
165 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_64MEDIA;
166 return true;
167
168 case OPT_m5_64media_nofpu:
169 opts->x_target_flags
170 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_64MEDIA_NOFPU;
171 return true;
172
173 case OPT_m5_compact:
174 opts->x_target_flags
175 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_COMPACT;
176 return true;
177
178 case OPT_m5_compact_nofpu:
179 opts->x_target_flags
180 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH5_COMPACT_NOFPU;
181 return true;
182
183 default:
184 return true;
185 }
186 }
187
188 /* Implement TARGET_OPTION_INIT_STRUCT. */
189 static void
190 sh_option_init_struct (struct gcc_options *opts)
191 {
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;
197 }
198
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
207
208 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
This page took 0.042124 seconds and 5 git commands to generate.