]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/avr/avr-c.c
1 /* Copyright (C) 2009, 2010
2 Free Software Foundation, Inc.
3 Contributed by Anatoly Sokolov (aesok@post.ru)
5 This file is part of GCC.
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)
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.
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 /* Not included in avr.c since this requires C front end. */
25 #include "coretypes.h"
30 #include "c-family/c-common.h"
31 #include "langhooks.h"
34 /* Implement `REGISTER_TARGET_PRAGMAS'. */
37 avr_register_target_pragmas (void)
39 c_register_addr_space ("__pgm", ADDR_SPACE_PGM
);
43 /* Worker function for TARGET_CPU_CPP_BUILTINS. */
46 avr_cpu_cpp_builtins (struct cpp_reader
*pfile
)
48 builtin_define_std ("AVR");
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
)
62 cpp_define (pfile
, "__AVR_HAVE_MOVW__");
63 cpp_define (pfile
, "__AVR_HAVE_LPMX__");
65 if (avr_current_arch
->asm_only
)
66 cpp_define (pfile
, "__AVR_ASM_ONLY__");
67 if (avr_current_arch
->have_mul
)
69 cpp_define (pfile
, "__AVR_ENHANCED__");
70 cpp_define (pfile
, "__AVR_HAVE_MUL__");
72 if (avr_current_arch
->have_jmp_call
)
74 cpp_define (pfile
, "__AVR_MEGA__");
75 cpp_define (pfile
, "__AVR_HAVE_JMP_CALL__");
77 if (avr_current_arch
->have_eijmp_eicall
)
79 cpp_define (pfile
, "__AVR_HAVE_EIJMP_EICALL__");
80 cpp_define (pfile
, "__AVR_3_BYTE_PC__");
84 cpp_define (pfile
, "__AVR_2_BYTE_PC__");
87 if (avr_current_device
->short_sp
)
88 cpp_define (pfile
, "__AVR_HAVE_8BIT_SP__");
90 cpp_define (pfile
, "__AVR_HAVE_16BIT_SP__");
92 if (TARGET_NO_INTERRUPTS
)
93 cpp_define (pfile
, "__NO_INTERRUPTS__");
95 if (avr_current_device
->errata_skip
)
97 cpp_define (pfile
, "__AVR_ERRATA_SKIP__");
99 if (avr_current_arch
->have_jmp_call
)
100 cpp_define (pfile
, "__AVR_ERRATA_SKIP_JMP_CALL__");
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. */
109 if (!strcmp (lang_hooks
.name
, "GNU C"))
111 cpp_define (pfile
, "__PGM=__pgm");
114 /* Define builtin macros so that the user can
115 easily query if or if not a specific builtin
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");
126 cpp_define (pfile
, "__BUILTIN_AVR_FMUL");
127 cpp_define (pfile
, "__BUILTIN_AVR_FMULS");
128 cpp_define (pfile
, "__BUILTIN_AVR_FMULSU");
130 cpp_define (pfile
, "__INT24_MAX__=8388607L");
131 cpp_define (pfile
, "__INT24_MIN__=(-__INT24_MAX__-1)");
132 cpp_define (pfile
, "__UINT24_MAX__=16777215UL");