]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/common/config/sh/sh-common.cc
Update copyright years.
[thirdparty/gcc.git] / gcc / common / config / sh / sh-common.cc
1 /* Common hooks for Renesas / SuperH SH.
2 Copyright (C) 1993-2024 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
29 /* Set default optimization options. */
30 static const struct default_options sh_option_optimization_table[] =
31 {
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 }
36 };
37
38 /* Implement TARGET_HANDLE_OPTION. */
39
40 static bool
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)
45 {
46 size_t code = decoded->opt_index;
47
48 switch (code)
49 {
50 case OPT_m1:
51 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH1;
52 return true;
53
54 case OPT_m2:
55 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2;
56 return true;
57
58 case OPT_m2a:
59 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A;
60 return true;
61
62 case OPT_m2a_nofpu:
63 opts->x_target_flags
64 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_NOFPU;
65 return true;
66
67 case OPT_m2a_single:
68 opts->x_target_flags
69 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE;
70 return true;
71
72 case OPT_m2a_single_only:
73 opts->x_target_flags
74 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE_ONLY;
75 return true;
76
77 case OPT_m2e:
78 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2E;
79 return true;
80
81 case OPT_m3:
82 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3;
83 return true;
84
85 case OPT_m3e:
86 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3E;
87 return true;
88
89 case OPT_m4:
90 case OPT_m4_100:
91 case OPT_m4_200:
92 case OPT_m4_300:
93 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4;
94 return true;
95
96 case OPT_m4_nofpu:
97 case OPT_m4_100_nofpu:
98 case OPT_m4_200_nofpu:
99 case OPT_m4_300_nofpu:
100 case OPT_m4_340:
101 case OPT_m4_400:
102 case OPT_m4_500:
103 opts->x_target_flags
104 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_NOFPU;
105 return true;
106
107 case OPT_m4_single:
108 case OPT_m4_100_single:
109 case OPT_m4_200_single:
110 case OPT_m4_300_single:
111 opts->x_target_flags
112 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE;
113 return true;
114
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:
119 opts->x_target_flags
120 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE_ONLY;
121 return true;
122
123 case OPT_m4a:
124 opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A;
125 return true;
126
127 case OPT_m4a_nofpu:
128 case OPT_m4al:
129 opts->x_target_flags
130 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_NOFPU;
131 return true;
132
133 case OPT_m4a_single:
134 opts->x_target_flags
135 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE;
136 return true;
137
138 case OPT_m4a_single_only:
139 opts->x_target_flags
140 = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE_ONLY;
141 return true;
142
143 default:
144 return true;
145 }
146 }
147
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
154
155 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;