Reverting merge from trunk
[official-gcc.git] / gcc / common / config / nds32 / nds32-common.c
blobf82f725af14edcb268d9e301dcb7704233ba01fb
1 /* Common hooks of Andes NDS32 cpu for GNU compiler
2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 Contributed by Andes Technology Corporation.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "diagnostic-core.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"
31 /* ------------------------------------------------------------------------ */
33 /* Implement TARGET_HANDLE_OPTION. */
34 static bool
35 nds32_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED,
36 struct gcc_options *opts_set ATTRIBUTE_UNUSED,
37 const struct cl_decoded_option *decoded,
38 location_t loc)
40 size_t code = decoded->opt_index;
41 int value = decoded->value;
43 switch (code)
45 case OPT_misr_vector_size_:
46 /* Check the valid vector size: 4 or 16. */
47 if (value != 4 && value != 16)
49 error_at (loc, "for the option -misr-vector-size=X, the valid X "
50 "must be: 4 or 16");
51 return false;
54 return true;
56 case OPT_mcache_block_size_:
57 /* Check valid value: 4 8 16 32 64 128 256 512. */
58 if (exact_log2 (value) < 2 || exact_log2 (value) > 9)
60 error_at (loc, "for the option -mcache-block-size=X, the valid X "
61 "must be: 4, 8, 16, 32, 64, 128, 256, or 512");
62 return false;
65 return true;
67 default:
68 return true;
72 /* ------------------------------------------------------------------------ */
74 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
75 static const struct default_options nds32_option_optimization_table[] =
77 /* Enable -fomit-frame-pointer by default at -O1 or higher. */
78 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
79 /* Enable -mv3push by default at -Os, but it is useless under V2 ISA. */
80 { OPT_LEVELS_SIZE, OPT_mv3push, NULL, 1 },
82 { OPT_LEVELS_NONE, 0, NULL, 0 }
85 /* ------------------------------------------------------------------------ */
87 /* Run-time Target Specification. */
89 /* Default enable
90 TARGET_GP_DIRECT: Generate gp-imply instruction.
91 TARGET_16_BIT : Generate 16/32 bit mixed length instruction.
92 TARGET_PERF_EXT : Generate performance extention instrcution.
93 TARGET_CMOV : Generate conditional move instruction. */
94 #undef TARGET_DEFAULT_TARGET_FLAGS
95 #define TARGET_DEFAULT_TARGET_FLAGS \
96 (MASK_GP_DIRECT \
97 | MASK_16_BIT \
98 | MASK_PERF_EXT \
99 | MASK_CMOV)
101 #undef TARGET_HANDLE_OPTION
102 #define TARGET_HANDLE_OPTION nds32_handle_option
104 #undef TARGET_OPTION_OPTIMIZATION_TABLE
105 #define TARGET_OPTION_OPTIMIZATION_TABLE nds32_option_optimization_table
108 /* Defining the Output Assembler Language. */
110 #undef TARGET_EXCEPT_UNWIND_INFO
111 #define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
113 /* ------------------------------------------------------------------------ */
115 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
117 /* ------------------------------------------------------------------------ */