]>
Commit | Line | Data |
---|---|---|
43ea6502 AS |
1 | /* Copyright (C) 2009, 2010 |
2 | Free Software Foundation, Inc. | |
3 | Contributed by Anatoly Sokolov (aesok@post.ru) | |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public 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 | ||
7c209481 | 21 | /* Not included in avr.c since this requires C front end. */ |
43ea6502 AS |
22 | |
23 | #include "config.h" | |
24 | #include "system.h" | |
25 | #include "coretypes.h" | |
26 | #include "tm.h" | |
27 | #include "tm_p.h" | |
28 | #include "cpplib.h" | |
29 | #include "tree.h" | |
30 | #include "c-family/c-common.h" | |
7c209481 GJL |
31 | #include "langhooks.h" |
32 | ||
33 | ||
34 | /* Implement `REGISTER_TARGET_PRAGMAS'. */ | |
35 | ||
36 | void | |
37 | avr_register_target_pragmas (void) | |
38 | { | |
39 | c_register_addr_space ("__pgm", ADDR_SPACE_PGM); | |
40 | } | |
43ea6502 | 41 | |
43ea6502 AS |
42 | |
43 | /* Worker function for TARGET_CPU_CPP_BUILTINS. */ | |
44 | ||
45 | void | |
46 | avr_cpu_cpp_builtins (struct cpp_reader *pfile) | |
47 | { | |
48 | builtin_define_std ("AVR"); | |
49 | ||
50 | if (avr_current_arch->macro) | |
51 | cpp_define (pfile, avr_current_arch->macro); | |
52 | if (avr_extra_arch_macro) | |
53 | cpp_define (pfile, avr_extra_arch_macro); | |
54 | if (avr_current_arch->have_elpm) | |
55 | cpp_define (pfile, "__AVR_HAVE_RAMPZ__"); | |
56 | if (avr_current_arch->have_elpm) | |
57 | cpp_define (pfile, "__AVR_HAVE_ELPM__"); | |
58 | if (avr_current_arch->have_elpmx) | |
59 | cpp_define (pfile, "__AVR_HAVE_ELPMX__"); | |
60 | if (avr_current_arch->have_movw_lpmx) | |
61 | { | |
62 | cpp_define (pfile, "__AVR_HAVE_MOVW__"); | |
63 | cpp_define (pfile, "__AVR_HAVE_LPMX__"); | |
64 | } | |
65 | if (avr_current_arch->asm_only) | |
66 | cpp_define (pfile, "__AVR_ASM_ONLY__"); | |
67 | if (avr_current_arch->have_mul) | |
68 | { | |
69 | cpp_define (pfile, "__AVR_ENHANCED__"); | |
70 | cpp_define (pfile, "__AVR_HAVE_MUL__"); | |
71 | } | |
72 | if (avr_current_arch->have_jmp_call) | |
73 | { | |
74 | cpp_define (pfile, "__AVR_MEGA__"); | |
75 | cpp_define (pfile, "__AVR_HAVE_JMP_CALL__"); | |
76 | } | |
77 | if (avr_current_arch->have_eijmp_eicall) | |
78 | { | |
79 | cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__"); | |
80 | cpp_define (pfile, "__AVR_3_BYTE_PC__"); | |
81 | } | |
82 | else | |
83 | { | |
84 | cpp_define (pfile, "__AVR_2_BYTE_PC__"); | |
85 | } | |
86 | ||
87 | if (avr_current_device->short_sp) | |
88 | cpp_define (pfile, "__AVR_HAVE_8BIT_SP__"); | |
89 | else | |
90 | cpp_define (pfile, "__AVR_HAVE_16BIT_SP__"); | |
91 | ||
92 | if (TARGET_NO_INTERRUPTS) | |
93 | cpp_define (pfile, "__NO_INTERRUPTS__"); | |
94 | ||
f2c308fa GJL |
95 | if (avr_current_device->errata_skip) |
96 | { | |
97 | cpp_define (pfile, "__AVR_ERRATA_SKIP__"); | |
98 | ||
99 | if (avr_current_arch->have_jmp_call) | |
100 | cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__"); | |
101 | } | |
102 | ||
7c209481 GJL |
103 | /* Define builtin macros so that the user can easily query if or if not |
104 | non-generic address spaces (and which) are supported. | |
105 | This is only supported for C. For C++, a language extension is needed | |
106 | (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not | |
107 | implemented in GCC up to now. */ | |
108 | ||
109 | if (!strcmp (lang_hooks.name, "GNU C")) | |
110 | { | |
111 | cpp_define (pfile, "__PGM=__pgm"); | |
112 | } | |
113 | ||
43ea6502 AS |
114 | /* Define builtin macros so that the user can |
115 | easily query if or if not a specific builtin | |
116 | is available. */ | |
117 | ||
118 | cpp_define (pfile, "__BUILTIN_AVR_NOP"); | |
119 | cpp_define (pfile, "__BUILTIN_AVR_SEI"); | |
120 | cpp_define (pfile, "__BUILTIN_AVR_CLI"); | |
121 | cpp_define (pfile, "__BUILTIN_AVR_WDR"); | |
122 | cpp_define (pfile, "__BUILTIN_AVR_SLEEP"); | |
123 | cpp_define (pfile, "__BUILTIN_AVR_SWAP"); | |
124 | cpp_define (pfile, "__BUILTIN_AVR_DELAY_CYCLES"); | |
125 | ||
f451d14d GJL |
126 | cpp_define (pfile, "__BUILTIN_AVR_FMUL"); |
127 | cpp_define (pfile, "__BUILTIN_AVR_FMULS"); | |
128 | cpp_define (pfile, "__BUILTIN_AVR_FMULSU"); | |
e4fe948a GJL |
129 | |
130 | cpp_define (pfile, "__INT24_MAX__=8388607L"); | |
131 | cpp_define (pfile, "__INT24_MIN__=(-__INT24_MAX__-1)"); | |
132 | cpp_define (pfile, "__UINT24_MAX__=16777215UL"); | |
43ea6502 | 133 | } |