1 /* Common hooks for Sunplus S+CORE.
2 Copyright (C) 2005-2013 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 it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 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 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
30 static const struct default_options score_option_optimization_table[] =
31 {
32 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
33 { OPT_LEVELS_NONE, 0, NULL, 0 }
34 };
35
36 #undef TARGET_DEFAULT_TARGET_FLAGS
37 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
38
39 #undef TARGET_HANDLE_OPTION
40 #define TARGET_HANDLE_OPTION score_handle_option
41
42 #undef TARGET_OPTION_OPTIMIZATION_TABLE
43 #define TARGET_OPTION_OPTIMIZATION_TABLE score_option_optimization_table
44
45 #define MASK_ALL_CPU_BITS (MASK_SCORE7 | MASK_SCORE7D)
46
47 /* Implement TARGET_HANDLE_OPTION. */
48 static bool
score_handle_option(struct gcc_options * opts,struct gcc_options * opts_set ATTRIBUTE_UNUSED,const struct cl_decoded_option * decoded,location_t loc ATTRIBUTE_UNUSED)49 score_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 int value = decoded->value;
56
57 switch (code)
58 {
59 case OPT_mscore7d:
60 opts->x_target_flags &= ~(MASK_ALL_CPU_BITS);
61 opts->x_target_flags |= MASK_SCORE7 | MASK_SCORE7D;
62 return true;
63
64 case OPT_march_:
65 opts->x_target_flags &= ~(MASK_ALL_CPU_BITS);
66 opts->x_target_flags |= value;
67 return true;
68
69 default:
70 return true;
71 }
72 }
73
74 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
75