]>
Commit | Line | Data |
---|---|---|
9304f876 | 1 | /* Common hooks of Andes NDS32 cpu for GNU compiler |
a5544970 | 2 | Copyright (C) 2012-2019 Free Software Foundation, Inc. |
9304f876 CJW |
3 | Contributed by Andes Technology Corporation. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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/>. */ | |
20 | ||
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" | |
30 | ||
31 | /* ------------------------------------------------------------------------ */ | |
32 | ||
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) | |
39 | { | |
40 | size_t code = decoded->opt_index; | |
41 | int value = decoded->value; | |
42 | ||
43 | switch (code) | |
44 | { | |
45 | case OPT_misr_vector_size_: | |
46 | /* Check the valid vector size: 4 or 16. */ | |
47 | if (value != 4 && value != 16) | |
48 | { | |
49 | error_at (loc, "for the option -misr-vector-size=X, the valid X " | |
50 | "must be: 4 or 16"); | |
51 | return false; | |
52 | } | |
53 | ||
54 | return true; | |
55 | ||
a4931745 CJW |
56 | case OPT_misr_secure_: |
57 | /* Check the valid security level: 0 1 2 3. */ | |
58 | if (value < 0 || value > 3) | |
59 | { | |
60 | error_at (loc, "for the option -misr-secure=X, the valid X " | |
61 | "must be: 0, 1, 2, or 3"); | |
62 | return false; | |
63 | } | |
64 | return true; | |
65 | ||
9304f876 CJW |
66 | case OPT_mcache_block_size_: |
67 | /* Check valid value: 4 8 16 32 64 128 256 512. */ | |
68 | if (exact_log2 (value) < 2 || exact_log2 (value) > 9) | |
69 | { | |
70 | error_at (loc, "for the option -mcache-block-size=X, the valid X " | |
71 | "must be: 4, 8, 16, 32, 64, 128, 256, or 512"); | |
72 | return false; | |
73 | } | |
74 | ||
75 | return true; | |
76 | ||
77 | default: | |
78 | return true; | |
79 | } | |
80 | } | |
81 | ||
82 | /* ------------------------------------------------------------------------ */ | |
83 | ||
84 | /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ | |
85 | static const struct default_options nds32_option_optimization_table[] = | |
86 | { | |
1cc59108 CJW |
87 | #if TARGET_LINUX_ABI == 0 |
88 | /* Disable -fdelete-null-pointer-checks by default in ELF toolchain. */ | |
89 | { OPT_LEVELS_ALL, OPT_fdelete_null_pointer_checks, | |
90 | NULL, 0 }, | |
91 | #endif | |
003a994b CJW |
92 | /* Enable -fsched-pressure by default at -O1 and above. */ |
93 | { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 }, | |
94 | /* Enable -fomit-frame-pointer by default at all optimization levels. */ | |
95 | { OPT_LEVELS_ALL, OPT_fomit_frame_pointer, NULL, 1 }, | |
58e29762 KLC |
96 | /* Enable -mrelax-hint by default at all optimization levels. */ |
97 | { OPT_LEVELS_ALL, OPT_mrelax_hint, NULL, 1 }, | |
68acadb1 CJW |
98 | /* Enalbe -malways-align by default at -O1 and above, but not -Os or -Og. */ |
99 | { OPT_LEVELS_1_PLUS_SPEED_ONLY, OPT_malways_align, NULL, 1 }, | |
9304f876 | 100 | /* Enable -mv3push by default at -Os, but it is useless under V2 ISA. */ |
003a994b | 101 | { OPT_LEVELS_SIZE, OPT_mv3push, NULL, 1 }, |
9304f876 | 102 | |
003a994b | 103 | { OPT_LEVELS_NONE, 0, NULL, 0 } |
9304f876 CJW |
104 | }; |
105 | ||
106 | /* ------------------------------------------------------------------------ */ | |
cf3cd43d CJW |
107 | |
108 | /* Implement TARGET_EXCEPT_UNWIND_INFO. */ | |
109 | static enum unwind_info_type | |
110 | nds32_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED) | |
111 | { | |
112 | if (TARGET_LINUX_ABI) | |
113 | return UI_DWARF2; | |
114 | ||
115 | return UI_SJLJ; | |
116 | } | |
117 | ||
118 | /* ------------------------------------------------------------------------ */ | |
119 | ||
9304f876 CJW |
120 | \f |
121 | /* Run-time Target Specification. */ | |
122 | ||
cc1719e8 MC |
123 | /* The default target flags consist of |
124 | TARGET_CPU_DEFAULT and other MASK_XXX flags. | |
125 | ||
126 | The value of TARGET_CPU_DEFAULT is set by | |
127 | the process of 'configure' and 'make' stage. | |
128 | Please check gcc/config.gcc for more implementation detail. | |
129 | ||
130 | Other MASK_XXX flags are set individually. | |
131 | By default we enable | |
aa4b851c CJW |
132 | TARGET_16_BIT : Generate 16/32 bit mixed length instruction. |
133 | TARGET_EXT_PERF : Generate performance extention instrcution. | |
134 | TARGET_EXT_PERF2 : Generate performance extention version 2 instrcution. | |
135 | TARGET_EXT_STRING : Generate string extention instrcution. | |
8c9babb8 | 136 | TARGET_HW_ABS : Generate hardware abs instruction. |
aa4b851c | 137 | TARGET_CMOV : Generate conditional move instruction. */ |
9304f876 CJW |
138 | #undef TARGET_DEFAULT_TARGET_FLAGS |
139 | #define TARGET_DEFAULT_TARGET_FLAGS \ | |
cc1719e8 | 140 | (TARGET_CPU_DEFAULT \ |
e2286268 MC |
141 | | TARGET_DEFAULT_FPU_ISA \ |
142 | | TARGET_DEFAULT_FPU_FMA \ | |
9304f876 | 143 | | MASK_16_BIT \ |
aa4b851c CJW |
144 | | MASK_EXT_PERF \ |
145 | | MASK_EXT_PERF2 \ | |
146 | | MASK_EXT_STRING \ | |
8c9babb8 | 147 | | MASK_HW_ABS \ |
9304f876 CJW |
148 | | MASK_CMOV) |
149 | ||
150 | #undef TARGET_HANDLE_OPTION | |
151 | #define TARGET_HANDLE_OPTION nds32_handle_option | |
152 | ||
153 | #undef TARGET_OPTION_OPTIMIZATION_TABLE | |
154 | #define TARGET_OPTION_OPTIMIZATION_TABLE nds32_option_optimization_table | |
155 | ||
156 | \f | |
157 | /* Defining the Output Assembler Language. */ | |
158 | ||
159 | #undef TARGET_EXCEPT_UNWIND_INFO | |
cf3cd43d | 160 | #define TARGET_EXCEPT_UNWIND_INFO nds32_except_unwind_info |
9304f876 CJW |
161 | |
162 | /* ------------------------------------------------------------------------ */ | |
163 | ||
164 | struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; | |
165 | ||
166 | /* ------------------------------------------------------------------------ */ |