annotate gcc/config/avr/avr-c.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1 /* Copyright (C) 2009-2018 Free Software Foundation, Inc.
111
kono
parents: 67
diff changeset
2 Contributed by Anatoly Sokolov (aesok@post.ru)
kono
parents: 67
diff changeset
3
kono
parents: 67
diff changeset
4 This file is part of GCC.
kono
parents: 67
diff changeset
5
kono
parents: 67
diff changeset
6 GCC is free software; you can redistribute it and/or modify
kono
parents: 67
diff changeset
7 it under the terms of the GNU General Public License as published by
kono
parents: 67
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
kono
parents: 67
diff changeset
9 any later version.
kono
parents: 67
diff changeset
10
kono
parents: 67
diff changeset
11 GCC is distributed in the hope that it will be useful,
kono
parents: 67
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents: 67
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents: 67
diff changeset
14 GNU General Public License for more details.
kono
parents: 67
diff changeset
15
kono
parents: 67
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents: 67
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents: 67
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents: 67
diff changeset
19
kono
parents: 67
diff changeset
20 /* Not included in avr.c since this requires C front end. */
kono
parents: 67
diff changeset
21
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
22 #define IN_TARGET_CODE 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23
111
kono
parents: 67
diff changeset
24 #include "config.h"
kono
parents: 67
diff changeset
25 #include "system.h"
kono
parents: 67
diff changeset
26 #include "coretypes.h"
kono
parents: 67
diff changeset
27 #include "target.h"
kono
parents: 67
diff changeset
28 #include "c-family/c-common.h"
kono
parents: 67
diff changeset
29 #include "stor-layout.h"
kono
parents: 67
diff changeset
30 #include "langhooks.h"
kono
parents: 67
diff changeset
31 #include "memmodel.h"
kono
parents: 67
diff changeset
32 #include "tm_p.h"
kono
parents: 67
diff changeset
33
kono
parents: 67
diff changeset
34 /* IDs for all the AVR builtins. */
kono
parents: 67
diff changeset
35
kono
parents: 67
diff changeset
36 enum avr_builtin_id
kono
parents: 67
diff changeset
37 {
kono
parents: 67
diff changeset
38 #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME) \
kono
parents: 67
diff changeset
39 AVR_BUILTIN_ ## NAME,
kono
parents: 67
diff changeset
40 #include "builtins.def"
kono
parents: 67
diff changeset
41 #undef DEF_BUILTIN
kono
parents: 67
diff changeset
42
kono
parents: 67
diff changeset
43 AVR_BUILTIN_COUNT
kono
parents: 67
diff changeset
44 };
kono
parents: 67
diff changeset
45
kono
parents: 67
diff changeset
46
kono
parents: 67
diff changeset
47 /* Implement `TARGET_RESOLVE_OVERLOADED_PLUGIN'. */
kono
parents: 67
diff changeset
48
kono
parents: 67
diff changeset
49 static tree
kono
parents: 67
diff changeset
50 avr_resolve_overloaded_builtin (unsigned int iloc, tree fndecl, void *vargs)
kono
parents: 67
diff changeset
51 {
kono
parents: 67
diff changeset
52 tree type0, type1, fold = NULL_TREE;
kono
parents: 67
diff changeset
53 enum avr_builtin_id id = AVR_BUILTIN_COUNT;
kono
parents: 67
diff changeset
54 location_t loc = (location_t) iloc;
kono
parents: 67
diff changeset
55 vec<tree, va_gc> &args = * (vec<tree, va_gc>*) vargs;
kono
parents: 67
diff changeset
56
kono
parents: 67
diff changeset
57 switch (DECL_FUNCTION_CODE (fndecl))
kono
parents: 67
diff changeset
58 {
kono
parents: 67
diff changeset
59 default:
kono
parents: 67
diff changeset
60 break;
kono
parents: 67
diff changeset
61
kono
parents: 67
diff changeset
62 case AVR_BUILTIN_ABSFX:
kono
parents: 67
diff changeset
63 if (args.length() != 1)
kono
parents: 67
diff changeset
64 {
kono
parents: 67
diff changeset
65 error_at (loc, "%qs expects 1 argument but %d given",
kono
parents: 67
diff changeset
66 "absfx", (int) args.length());
kono
parents: 67
diff changeset
67
kono
parents: 67
diff changeset
68 fold = error_mark_node;
kono
parents: 67
diff changeset
69 break;
kono
parents: 67
diff changeset
70 }
kono
parents: 67
diff changeset
71
kono
parents: 67
diff changeset
72 type0 = TREE_TYPE (args[0]);
kono
parents: 67
diff changeset
73
kono
parents: 67
diff changeset
74 if (!FIXED_POINT_TYPE_P (type0))
kono
parents: 67
diff changeset
75 {
kono
parents: 67
diff changeset
76 error_at (loc, "%qs expects a fixed-point value as argument",
kono
parents: 67
diff changeset
77 "absfx");
kono
parents: 67
diff changeset
78
kono
parents: 67
diff changeset
79 fold = error_mark_node;
kono
parents: 67
diff changeset
80 }
kono
parents: 67
diff changeset
81
kono
parents: 67
diff changeset
82 switch (TYPE_MODE (type0))
kono
parents: 67
diff changeset
83 {
kono
parents: 67
diff changeset
84 case E_QQmode: id = AVR_BUILTIN_ABSHR; break;
kono
parents: 67
diff changeset
85 case E_HQmode: id = AVR_BUILTIN_ABSR; break;
kono
parents: 67
diff changeset
86 case E_SQmode: id = AVR_BUILTIN_ABSLR; break;
kono
parents: 67
diff changeset
87 case E_DQmode: id = AVR_BUILTIN_ABSLLR; break;
kono
parents: 67
diff changeset
88
kono
parents: 67
diff changeset
89 case E_HAmode: id = AVR_BUILTIN_ABSHK; break;
kono
parents: 67
diff changeset
90 case E_SAmode: id = AVR_BUILTIN_ABSK; break;
kono
parents: 67
diff changeset
91 case E_DAmode: id = AVR_BUILTIN_ABSLK; break;
kono
parents: 67
diff changeset
92 case E_TAmode: id = AVR_BUILTIN_ABSLLK; break;
kono
parents: 67
diff changeset
93
kono
parents: 67
diff changeset
94 case E_UQQmode:
kono
parents: 67
diff changeset
95 case E_UHQmode:
kono
parents: 67
diff changeset
96 case E_USQmode:
kono
parents: 67
diff changeset
97 case E_UDQmode:
kono
parents: 67
diff changeset
98 case E_UHAmode:
kono
parents: 67
diff changeset
99 case E_USAmode:
kono
parents: 67
diff changeset
100 case E_UDAmode:
kono
parents: 67
diff changeset
101 case E_UTAmode:
kono
parents: 67
diff changeset
102 warning_at (loc, 0, "using %qs with unsigned type has no effect",
kono
parents: 67
diff changeset
103 "absfx");
kono
parents: 67
diff changeset
104 return args[0];
kono
parents: 67
diff changeset
105
kono
parents: 67
diff changeset
106 default:
kono
parents: 67
diff changeset
107 error_at (loc, "no matching fixed-point overload found for %qs",
kono
parents: 67
diff changeset
108 "absfx");
kono
parents: 67
diff changeset
109
kono
parents: 67
diff changeset
110 fold = error_mark_node;
kono
parents: 67
diff changeset
111 break;
kono
parents: 67
diff changeset
112 }
kono
parents: 67
diff changeset
113
kono
parents: 67
diff changeset
114 fold = targetm.builtin_decl (id, true);
kono
parents: 67
diff changeset
115
kono
parents: 67
diff changeset
116 if (fold != error_mark_node)
kono
parents: 67
diff changeset
117 fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
kono
parents: 67
diff changeset
118
kono
parents: 67
diff changeset
119 break; // absfx
kono
parents: 67
diff changeset
120
kono
parents: 67
diff changeset
121 case AVR_BUILTIN_ROUNDFX:
kono
parents: 67
diff changeset
122 if (args.length() != 2)
kono
parents: 67
diff changeset
123 {
kono
parents: 67
diff changeset
124 error_at (loc, "%qs expects 2 arguments but %d given",
kono
parents: 67
diff changeset
125 "roundfx", (int) args.length());
kono
parents: 67
diff changeset
126
kono
parents: 67
diff changeset
127 fold = error_mark_node;
kono
parents: 67
diff changeset
128 break;
kono
parents: 67
diff changeset
129 }
kono
parents: 67
diff changeset
130
kono
parents: 67
diff changeset
131 type0 = TREE_TYPE (args[0]);
kono
parents: 67
diff changeset
132 type1 = TREE_TYPE (args[1]);
kono
parents: 67
diff changeset
133
kono
parents: 67
diff changeset
134 if (!FIXED_POINT_TYPE_P (type0))
kono
parents: 67
diff changeset
135 {
kono
parents: 67
diff changeset
136 error_at (loc, "%qs expects a fixed-point value as first argument",
kono
parents: 67
diff changeset
137 "roundfx");
kono
parents: 67
diff changeset
138
kono
parents: 67
diff changeset
139 fold = error_mark_node;
kono
parents: 67
diff changeset
140 }
kono
parents: 67
diff changeset
141
kono
parents: 67
diff changeset
142 if (!INTEGRAL_TYPE_P (type1))
kono
parents: 67
diff changeset
143 {
kono
parents: 67
diff changeset
144 error_at (loc, "%qs expects an integer value as second argument",
kono
parents: 67
diff changeset
145 "roundfx");
kono
parents: 67
diff changeset
146
kono
parents: 67
diff changeset
147 fold = error_mark_node;
kono
parents: 67
diff changeset
148 }
kono
parents: 67
diff changeset
149
kono
parents: 67
diff changeset
150 switch (TYPE_MODE (type0))
kono
parents: 67
diff changeset
151 {
kono
parents: 67
diff changeset
152 case E_QQmode: id = AVR_BUILTIN_ROUNDHR; break;
kono
parents: 67
diff changeset
153 case E_HQmode: id = AVR_BUILTIN_ROUNDR; break;
kono
parents: 67
diff changeset
154 case E_SQmode: id = AVR_BUILTIN_ROUNDLR; break;
kono
parents: 67
diff changeset
155 case E_DQmode: id = AVR_BUILTIN_ROUNDLLR; break;
kono
parents: 67
diff changeset
156
kono
parents: 67
diff changeset
157 case E_UQQmode: id = AVR_BUILTIN_ROUNDUHR; break;
kono
parents: 67
diff changeset
158 case E_UHQmode: id = AVR_BUILTIN_ROUNDUR; break;
kono
parents: 67
diff changeset
159 case E_USQmode: id = AVR_BUILTIN_ROUNDULR; break;
kono
parents: 67
diff changeset
160 case E_UDQmode: id = AVR_BUILTIN_ROUNDULLR; break;
kono
parents: 67
diff changeset
161
kono
parents: 67
diff changeset
162 case E_HAmode: id = AVR_BUILTIN_ROUNDHK; break;
kono
parents: 67
diff changeset
163 case E_SAmode: id = AVR_BUILTIN_ROUNDK; break;
kono
parents: 67
diff changeset
164 case E_DAmode: id = AVR_BUILTIN_ROUNDLK; break;
kono
parents: 67
diff changeset
165 case E_TAmode: id = AVR_BUILTIN_ROUNDLLK; break;
kono
parents: 67
diff changeset
166
kono
parents: 67
diff changeset
167 case E_UHAmode: id = AVR_BUILTIN_ROUNDUHK; break;
kono
parents: 67
diff changeset
168 case E_USAmode: id = AVR_BUILTIN_ROUNDUK; break;
kono
parents: 67
diff changeset
169 case E_UDAmode: id = AVR_BUILTIN_ROUNDULK; break;
kono
parents: 67
diff changeset
170 case E_UTAmode: id = AVR_BUILTIN_ROUNDULLK; break;
kono
parents: 67
diff changeset
171
kono
parents: 67
diff changeset
172 default:
kono
parents: 67
diff changeset
173 error_at (loc, "no matching fixed-point overload found for %qs",
kono
parents: 67
diff changeset
174 "roundfx");
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 fold = error_mark_node;
kono
parents: 67
diff changeset
177 break;
kono
parents: 67
diff changeset
178 }
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 fold = targetm.builtin_decl (id, true);
kono
parents: 67
diff changeset
181
kono
parents: 67
diff changeset
182 if (fold != error_mark_node)
kono
parents: 67
diff changeset
183 fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
kono
parents: 67
diff changeset
184
kono
parents: 67
diff changeset
185 break; // roundfx
kono
parents: 67
diff changeset
186
kono
parents: 67
diff changeset
187 case AVR_BUILTIN_COUNTLSFX:
kono
parents: 67
diff changeset
188 if (args.length() != 1)
kono
parents: 67
diff changeset
189 {
kono
parents: 67
diff changeset
190 error_at (loc, "%qs expects 1 argument but %d given",
kono
parents: 67
diff changeset
191 "countlsfx", (int) args.length());
kono
parents: 67
diff changeset
192
kono
parents: 67
diff changeset
193 fold = error_mark_node;
kono
parents: 67
diff changeset
194 break;
kono
parents: 67
diff changeset
195 }
kono
parents: 67
diff changeset
196
kono
parents: 67
diff changeset
197 type0 = TREE_TYPE (args[0]);
kono
parents: 67
diff changeset
198
kono
parents: 67
diff changeset
199 if (!FIXED_POINT_TYPE_P (type0))
kono
parents: 67
diff changeset
200 {
kono
parents: 67
diff changeset
201 error_at (loc, "%qs expects a fixed-point value as first argument",
kono
parents: 67
diff changeset
202 "countlsfx");
kono
parents: 67
diff changeset
203
kono
parents: 67
diff changeset
204 fold = error_mark_node;
kono
parents: 67
diff changeset
205 }
kono
parents: 67
diff changeset
206
kono
parents: 67
diff changeset
207 switch (TYPE_MODE (type0))
kono
parents: 67
diff changeset
208 {
kono
parents: 67
diff changeset
209 case E_QQmode: id = AVR_BUILTIN_COUNTLSHR; break;
kono
parents: 67
diff changeset
210 case E_HQmode: id = AVR_BUILTIN_COUNTLSR; break;
kono
parents: 67
diff changeset
211 case E_SQmode: id = AVR_BUILTIN_COUNTLSLR; break;
kono
parents: 67
diff changeset
212 case E_DQmode: id = AVR_BUILTIN_COUNTLSLLR; break;
kono
parents: 67
diff changeset
213
kono
parents: 67
diff changeset
214 case E_UQQmode: id = AVR_BUILTIN_COUNTLSUHR; break;
kono
parents: 67
diff changeset
215 case E_UHQmode: id = AVR_BUILTIN_COUNTLSUR; break;
kono
parents: 67
diff changeset
216 case E_USQmode: id = AVR_BUILTIN_COUNTLSULR; break;
kono
parents: 67
diff changeset
217 case E_UDQmode: id = AVR_BUILTIN_COUNTLSULLR; break;
kono
parents: 67
diff changeset
218
kono
parents: 67
diff changeset
219 case E_HAmode: id = AVR_BUILTIN_COUNTLSHK; break;
kono
parents: 67
diff changeset
220 case E_SAmode: id = AVR_BUILTIN_COUNTLSK; break;
kono
parents: 67
diff changeset
221 case E_DAmode: id = AVR_BUILTIN_COUNTLSLK; break;
kono
parents: 67
diff changeset
222 case E_TAmode: id = AVR_BUILTIN_COUNTLSLLK; break;
kono
parents: 67
diff changeset
223
kono
parents: 67
diff changeset
224 case E_UHAmode: id = AVR_BUILTIN_COUNTLSUHK; break;
kono
parents: 67
diff changeset
225 case E_USAmode: id = AVR_BUILTIN_COUNTLSUK; break;
kono
parents: 67
diff changeset
226 case E_UDAmode: id = AVR_BUILTIN_COUNTLSULK; break;
kono
parents: 67
diff changeset
227 case E_UTAmode: id = AVR_BUILTIN_COUNTLSULLK; break;
kono
parents: 67
diff changeset
228
kono
parents: 67
diff changeset
229 default:
kono
parents: 67
diff changeset
230 error_at (loc, "no matching fixed-point overload found for %qs",
kono
parents: 67
diff changeset
231 "countlsfx");
kono
parents: 67
diff changeset
232
kono
parents: 67
diff changeset
233 fold = error_mark_node;
kono
parents: 67
diff changeset
234 break;
kono
parents: 67
diff changeset
235 }
kono
parents: 67
diff changeset
236
kono
parents: 67
diff changeset
237 fold = targetm.builtin_decl (id, true);
kono
parents: 67
diff changeset
238
kono
parents: 67
diff changeset
239 if (fold != error_mark_node)
kono
parents: 67
diff changeset
240 fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
kono
parents: 67
diff changeset
241
kono
parents: 67
diff changeset
242 break; // countlsfx
kono
parents: 67
diff changeset
243 }
kono
parents: 67
diff changeset
244
kono
parents: 67
diff changeset
245 return fold;
kono
parents: 67
diff changeset
246 }
kono
parents: 67
diff changeset
247
kono
parents: 67
diff changeset
248
kono
parents: 67
diff changeset
249 /* Implement `REGISTER_TARGET_PRAGMAS'. */
kono
parents: 67
diff changeset
250
kono
parents: 67
diff changeset
251 void
kono
parents: 67
diff changeset
252 avr_register_target_pragmas (void)
kono
parents: 67
diff changeset
253 {
kono
parents: 67
diff changeset
254 gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM);
kono
parents: 67
diff changeset
255
kono
parents: 67
diff changeset
256 /* Register address spaces. The order must be the same as in the respective
kono
parents: 67
diff changeset
257 enum from avr.h (or designated initializers must be used in avr.c).
kono
parents: 67
diff changeset
258 We always register all address spaces even if some of them make no
kono
parents: 67
diff changeset
259 sense for some targets. Diagnose for non-supported spaces will be
kono
parents: 67
diff changeset
260 emit by TARGET_ADDR_SPACE_DIAGNOSE_USAGE. */
kono
parents: 67
diff changeset
261
kono
parents: 67
diff changeset
262 for (int i = 0; i < ADDR_SPACE_COUNT; i++)
kono
parents: 67
diff changeset
263 {
kono
parents: 67
diff changeset
264 gcc_assert (i == avr_addrspace[i].id);
kono
parents: 67
diff changeset
265
kono
parents: 67
diff changeset
266 if (!ADDR_SPACE_GENERIC_P (i))
kono
parents: 67
diff changeset
267 c_register_addr_space (avr_addrspace[i].name, avr_addrspace[i].id);
kono
parents: 67
diff changeset
268 }
kono
parents: 67
diff changeset
269
kono
parents: 67
diff changeset
270 targetm.resolve_overloaded_builtin = avr_resolve_overloaded_builtin;
kono
parents: 67
diff changeset
271 }
kono
parents: 67
diff changeset
272
kono
parents: 67
diff changeset
273
kono
parents: 67
diff changeset
274 /* Transform LO into uppercase and write the result to UP.
kono
parents: 67
diff changeset
275 You must provide enough space for UP. Return UP. */
kono
parents: 67
diff changeset
276
kono
parents: 67
diff changeset
277 static char*
kono
parents: 67
diff changeset
278 avr_toupper (char *up, const char *lo)
kono
parents: 67
diff changeset
279 {
kono
parents: 67
diff changeset
280 char *up0 = up;
kono
parents: 67
diff changeset
281
kono
parents: 67
diff changeset
282 for (; *lo; lo++, up++)
kono
parents: 67
diff changeset
283 *up = TOUPPER (*lo);
kono
parents: 67
diff changeset
284
kono
parents: 67
diff changeset
285 *up = '\0';
kono
parents: 67
diff changeset
286
kono
parents: 67
diff changeset
287 return up0;
kono
parents: 67
diff changeset
288 }
kono
parents: 67
diff changeset
289
kono
parents: 67
diff changeset
290 /* Worker function for TARGET_CPU_CPP_BUILTINS. */
kono
parents: 67
diff changeset
291
kono
parents: 67
diff changeset
292 void
kono
parents: 67
diff changeset
293 avr_cpu_cpp_builtins (struct cpp_reader *pfile)
kono
parents: 67
diff changeset
294 {
kono
parents: 67
diff changeset
295 builtin_define_std ("AVR");
kono
parents: 67
diff changeset
296
kono
parents: 67
diff changeset
297 /* __AVR_DEVICE_NAME__ and avr_mcu_types[].macro like __AVR_ATmega8__
kono
parents: 67
diff changeset
298 are defined by -D command option, see device-specs file. */
kono
parents: 67
diff changeset
299
kono
parents: 67
diff changeset
300 if (avr_arch->macro)
kono
parents: 67
diff changeset
301 cpp_define_formatted (pfile, "__AVR_ARCH__=%s", avr_arch->macro);
kono
parents: 67
diff changeset
302 if (AVR_HAVE_RAMPD) cpp_define (pfile, "__AVR_HAVE_RAMPD__");
kono
parents: 67
diff changeset
303 if (AVR_HAVE_RAMPX) cpp_define (pfile, "__AVR_HAVE_RAMPX__");
kono
parents: 67
diff changeset
304 if (AVR_HAVE_RAMPY) cpp_define (pfile, "__AVR_HAVE_RAMPY__");
kono
parents: 67
diff changeset
305 if (AVR_HAVE_RAMPZ) cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
kono
parents: 67
diff changeset
306 if (AVR_HAVE_ELPM) cpp_define (pfile, "__AVR_HAVE_ELPM__");
kono
parents: 67
diff changeset
307 if (AVR_HAVE_ELPMX) cpp_define (pfile, "__AVR_HAVE_ELPMX__");
kono
parents: 67
diff changeset
308 if (AVR_HAVE_MOVW) cpp_define (pfile, "__AVR_HAVE_MOVW__");
kono
parents: 67
diff changeset
309 if (AVR_HAVE_LPMX) cpp_define (pfile, "__AVR_HAVE_LPMX__");
kono
parents: 67
diff changeset
310
kono
parents: 67
diff changeset
311 if (avr_arch->asm_only)
kono
parents: 67
diff changeset
312 cpp_define (pfile, "__AVR_ASM_ONLY__");
kono
parents: 67
diff changeset
313 if (AVR_HAVE_MUL)
kono
parents: 67
diff changeset
314 {
kono
parents: 67
diff changeset
315 cpp_define (pfile, "__AVR_ENHANCED__");
kono
parents: 67
diff changeset
316 cpp_define (pfile, "__AVR_HAVE_MUL__");
kono
parents: 67
diff changeset
317 }
kono
parents: 67
diff changeset
318
kono
parents: 67
diff changeset
319 if (AVR_HAVE_JMP_CALL)
kono
parents: 67
diff changeset
320 cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
kono
parents: 67
diff changeset
321
kono
parents: 67
diff changeset
322 if (avr_arch->have_jmp_call)
kono
parents: 67
diff changeset
323 cpp_define (pfile, "__AVR_MEGA__");
kono
parents: 67
diff changeset
324
kono
parents: 67
diff changeset
325 if (AVR_SHORT_CALLS)
kono
parents: 67
diff changeset
326 cpp_define (pfile, "__AVR_SHORT_CALLS__");
kono
parents: 67
diff changeset
327
kono
parents: 67
diff changeset
328 if (AVR_XMEGA)
kono
parents: 67
diff changeset
329 cpp_define (pfile, "__AVR_XMEGA__");
kono
parents: 67
diff changeset
330
kono
parents: 67
diff changeset
331 if (AVR_TINY)
kono
parents: 67
diff changeset
332 {
kono
parents: 67
diff changeset
333 cpp_define (pfile, "__AVR_TINY__");
kono
parents: 67
diff changeset
334
kono
parents: 67
diff changeset
335 /* Define macro "__AVR_TINY_PM_BASE_ADDRESS__" with mapped program memory
kono
parents: 67
diff changeset
336 start address. This macro shall be used where mapped program
kono
parents: 67
diff changeset
337 memory is accessed, eg. copying data section (__do_copy_data)
kono
parents: 67
diff changeset
338 contents to data memory region.
kono
parents: 67
diff changeset
339 NOTE:
kono
parents: 67
diff changeset
340 Program memory of AVR_TINY devices cannot be accessed directly,
kono
parents: 67
diff changeset
341 it has been mapped to the data memory. For AVR_TINY devices
kono
parents: 67
diff changeset
342 (ATtiny4/5/9/10/20 and 40) mapped program memory starts at 0x4000. */
kono
parents: 67
diff changeset
343
kono
parents: 67
diff changeset
344 cpp_define_formatted (pfile, "__AVR_TINY_PM_BASE_ADDRESS__=0x%x",
kono
parents: 67
diff changeset
345 avr_arch->flash_pm_offset);
kono
parents: 67
diff changeset
346 }
kono
parents: 67
diff changeset
347
kono
parents: 67
diff changeset
348 if (avr_arch->flash_pm_offset)
kono
parents: 67
diff changeset
349 cpp_define_formatted (pfile, "__AVR_PM_BASE_ADDRESS__=0x%x",
kono
parents: 67
diff changeset
350 avr_arch->flash_pm_offset);
kono
parents: 67
diff changeset
351
kono
parents: 67
diff changeset
352 if (AVR_HAVE_EIJMP_EICALL)
kono
parents: 67
diff changeset
353 {
kono
parents: 67
diff changeset
354 cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
kono
parents: 67
diff changeset
355 cpp_define (pfile, "__AVR_3_BYTE_PC__");
kono
parents: 67
diff changeset
356 }
kono
parents: 67
diff changeset
357 else
kono
parents: 67
diff changeset
358 {
kono
parents: 67
diff changeset
359 cpp_define (pfile, "__AVR_2_BYTE_PC__");
kono
parents: 67
diff changeset
360 }
kono
parents: 67
diff changeset
361
kono
parents: 67
diff changeset
362 if (AVR_HAVE_8BIT_SP)
kono
parents: 67
diff changeset
363 cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
kono
parents: 67
diff changeset
364 else
kono
parents: 67
diff changeset
365 cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
kono
parents: 67
diff changeset
366
kono
parents: 67
diff changeset
367 if (AVR_HAVE_SPH)
kono
parents: 67
diff changeset
368 cpp_define (pfile, "__AVR_HAVE_SPH__");
kono
parents: 67
diff changeset
369 else
kono
parents: 67
diff changeset
370 cpp_define (pfile, "__AVR_SP8__");
kono
parents: 67
diff changeset
371
kono
parents: 67
diff changeset
372 if (TARGET_NO_INTERRUPTS)
kono
parents: 67
diff changeset
373 cpp_define (pfile, "__NO_INTERRUPTS__");
kono
parents: 67
diff changeset
374
kono
parents: 67
diff changeset
375 if (TARGET_SKIP_BUG)
kono
parents: 67
diff changeset
376 {
kono
parents: 67
diff changeset
377 cpp_define (pfile, "__AVR_ERRATA_SKIP__");
kono
parents: 67
diff changeset
378
kono
parents: 67
diff changeset
379 if (AVR_HAVE_JMP_CALL)
kono
parents: 67
diff changeset
380 cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__");
kono
parents: 67
diff changeset
381 }
kono
parents: 67
diff changeset
382
kono
parents: 67
diff changeset
383 if (TARGET_RMW)
kono
parents: 67
diff changeset
384 cpp_define (pfile, "__AVR_ISA_RMW__");
kono
parents: 67
diff changeset
385
kono
parents: 67
diff changeset
386 cpp_define_formatted (pfile, "__AVR_SFR_OFFSET__=0x%x",
kono
parents: 67
diff changeset
387 avr_arch->sfr_offset);
kono
parents: 67
diff changeset
388
kono
parents: 67
diff changeset
389 #ifdef WITH_AVRLIBC
kono
parents: 67
diff changeset
390 cpp_define (pfile, "__WITH_AVRLIBC__");
kono
parents: 67
diff changeset
391 #endif /* WITH_AVRLIBC */
kono
parents: 67
diff changeset
392
kono
parents: 67
diff changeset
393 /* Define builtin macros so that the user can easily query whether
kono
parents: 67
diff changeset
394 non-generic address spaces (and which) are supported or not.
kono
parents: 67
diff changeset
395 This is only supported for C. For C++, a language extension is needed
kono
parents: 67
diff changeset
396 (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not
kono
parents: 67
diff changeset
397 implemented in GCC up to now. */
kono
parents: 67
diff changeset
398
kono
parents: 67
diff changeset
399 if (lang_GNU_C ())
kono
parents: 67
diff changeset
400 {
kono
parents: 67
diff changeset
401 for (int i = 0; i < ADDR_SPACE_COUNT; i++)
kono
parents: 67
diff changeset
402 if (!ADDR_SPACE_GENERIC_P (i)
kono
parents: 67
diff changeset
403 /* Only supply __FLASH<n> macro if the address space is reasonable
kono
parents: 67
diff changeset
404 for this target. The address space qualifier itself is still
kono
parents: 67
diff changeset
405 supported, but using it will throw an error. */
kono
parents: 67
diff changeset
406 && avr_addr_space_supported_p ((addr_space_t) i))
kono
parents: 67
diff changeset
407 {
kono
parents: 67
diff changeset
408 const char *name = avr_addrspace[i].name;
kono
parents: 67
diff changeset
409 char *Name = (char*) alloca (1 + strlen (name));
kono
parents: 67
diff changeset
410
kono
parents: 67
diff changeset
411 cpp_define (pfile, avr_toupper (Name, name));
kono
parents: 67
diff changeset
412 }
kono
parents: 67
diff changeset
413 }
kono
parents: 67
diff changeset
414
kono
parents: 67
diff changeset
415 /* Define builtin macros so that the user can easily query whether or
kono
parents: 67
diff changeset
416 not a specific builtin is available. */
kono
parents: 67
diff changeset
417
kono
parents: 67
diff changeset
418 #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME) \
kono
parents: 67
diff changeset
419 cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
kono
parents: 67
diff changeset
420 #include "builtins.def"
kono
parents: 67
diff changeset
421 #undef DEF_BUILTIN
kono
parents: 67
diff changeset
422
kono
parents: 67
diff changeset
423 /* Builtin macros for the __int24 and __uint24 type. */
kono
parents: 67
diff changeset
424
kono
parents: 67
diff changeset
425 cpp_define_formatted (pfile, "__INT24_MAX__=8388607%s",
kono
parents: 67
diff changeset
426 INT_TYPE_SIZE == 8 ? "LL" : "L");
kono
parents: 67
diff changeset
427 cpp_define (pfile, "__INT24_MIN__=(-__INT24_MAX__-1)");
kono
parents: 67
diff changeset
428 cpp_define_formatted (pfile, "__UINT24_MAX__=16777215%s",
kono
parents: 67
diff changeset
429 INT_TYPE_SIZE == 8 ? "ULL" : "UL");
kono
parents: 67
diff changeset
430 }