1*8feb0f0bSmrg /* Copyright (C) 2009-2020 Free Software Foundation, Inc.
21debfc3dSmrg Contributed by Anatoly Sokolov (aesok@post.ru)
31debfc3dSmrg
41debfc3dSmrg This file is part of GCC.
51debfc3dSmrg
61debfc3dSmrg GCC is free software; you can redistribute it and/or modify
71debfc3dSmrg it under the terms of the GNU General Public License as published by
81debfc3dSmrg the Free Software Foundation; either version 3, or (at your option)
91debfc3dSmrg any later version.
101debfc3dSmrg
111debfc3dSmrg GCC is distributed in the hope that it will be useful,
121debfc3dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
131debfc3dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141debfc3dSmrg GNU General Public License for more details.
151debfc3dSmrg
161debfc3dSmrg You should have received a copy of the GNU General Public License
171debfc3dSmrg along with GCC; see the file COPYING3. If not see
181debfc3dSmrg <http://www.gnu.org/licenses/>. */
191debfc3dSmrg
201debfc3dSmrg /* Not included in avr.c since this requires C front end. */
211debfc3dSmrg
22a2dc1f3fSmrg #define IN_TARGET_CODE 1
23a2dc1f3fSmrg
241debfc3dSmrg #include "config.h"
251debfc3dSmrg #include "system.h"
261debfc3dSmrg #include "coretypes.h"
271debfc3dSmrg #include "target.h"
281debfc3dSmrg #include "c-family/c-common.h"
291debfc3dSmrg #include "stor-layout.h"
301debfc3dSmrg #include "langhooks.h"
311debfc3dSmrg #include "memmodel.h"
321debfc3dSmrg #include "tm_p.h"
331debfc3dSmrg
341debfc3dSmrg /* IDs for all the AVR builtins. */
351debfc3dSmrg
361debfc3dSmrg enum avr_builtin_id
371debfc3dSmrg {
381debfc3dSmrg #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME) \
391debfc3dSmrg AVR_BUILTIN_ ## NAME,
401debfc3dSmrg #include "builtins.def"
411debfc3dSmrg #undef DEF_BUILTIN
421debfc3dSmrg
431debfc3dSmrg AVR_BUILTIN_COUNT
441debfc3dSmrg };
451debfc3dSmrg
461debfc3dSmrg
471debfc3dSmrg /* Implement `TARGET_RESOLVE_OVERLOADED_PLUGIN'. */
481debfc3dSmrg
491debfc3dSmrg static tree
avr_resolve_overloaded_builtin(unsigned int iloc,tree fndecl,void * vargs)501debfc3dSmrg avr_resolve_overloaded_builtin (unsigned int iloc, tree fndecl, void *vargs)
511debfc3dSmrg {
521debfc3dSmrg tree type0, type1, fold = NULL_TREE;
531debfc3dSmrg enum avr_builtin_id id = AVR_BUILTIN_COUNT;
541debfc3dSmrg location_t loc = (location_t) iloc;
551debfc3dSmrg vec<tree, va_gc> &args = * (vec<tree, va_gc>*) vargs;
561debfc3dSmrg
57*8feb0f0bSmrg switch (DECL_MD_FUNCTION_CODE (fndecl))
581debfc3dSmrg {
591debfc3dSmrg default:
601debfc3dSmrg break;
611debfc3dSmrg
621debfc3dSmrg case AVR_BUILTIN_ABSFX:
631debfc3dSmrg if (args.length() != 1)
641debfc3dSmrg {
651debfc3dSmrg error_at (loc, "%qs expects 1 argument but %d given",
661debfc3dSmrg "absfx", (int) args.length());
671debfc3dSmrg
681debfc3dSmrg fold = error_mark_node;
691debfc3dSmrg break;
701debfc3dSmrg }
711debfc3dSmrg
721debfc3dSmrg type0 = TREE_TYPE (args[0]);
731debfc3dSmrg
741debfc3dSmrg if (!FIXED_POINT_TYPE_P (type0))
751debfc3dSmrg {
761debfc3dSmrg error_at (loc, "%qs expects a fixed-point value as argument",
771debfc3dSmrg "absfx");
781debfc3dSmrg
791debfc3dSmrg fold = error_mark_node;
801debfc3dSmrg }
811debfc3dSmrg
821debfc3dSmrg switch (TYPE_MODE (type0))
831debfc3dSmrg {
84a2dc1f3fSmrg case E_QQmode: id = AVR_BUILTIN_ABSHR; break;
85a2dc1f3fSmrg case E_HQmode: id = AVR_BUILTIN_ABSR; break;
86a2dc1f3fSmrg case E_SQmode: id = AVR_BUILTIN_ABSLR; break;
87a2dc1f3fSmrg case E_DQmode: id = AVR_BUILTIN_ABSLLR; break;
881debfc3dSmrg
89a2dc1f3fSmrg case E_HAmode: id = AVR_BUILTIN_ABSHK; break;
90a2dc1f3fSmrg case E_SAmode: id = AVR_BUILTIN_ABSK; break;
91a2dc1f3fSmrg case E_DAmode: id = AVR_BUILTIN_ABSLK; break;
92a2dc1f3fSmrg case E_TAmode: id = AVR_BUILTIN_ABSLLK; break;
931debfc3dSmrg
94a2dc1f3fSmrg case E_UQQmode:
95a2dc1f3fSmrg case E_UHQmode:
96a2dc1f3fSmrg case E_USQmode:
97a2dc1f3fSmrg case E_UDQmode:
98a2dc1f3fSmrg case E_UHAmode:
99a2dc1f3fSmrg case E_USAmode:
100a2dc1f3fSmrg case E_UDAmode:
101a2dc1f3fSmrg case E_UTAmode:
1021debfc3dSmrg warning_at (loc, 0, "using %qs with unsigned type has no effect",
1031debfc3dSmrg "absfx");
1041debfc3dSmrg return args[0];
1051debfc3dSmrg
1061debfc3dSmrg default:
1071debfc3dSmrg error_at (loc, "no matching fixed-point overload found for %qs",
1081debfc3dSmrg "absfx");
1091debfc3dSmrg
1101debfc3dSmrg fold = error_mark_node;
1111debfc3dSmrg break;
1121debfc3dSmrg }
1131debfc3dSmrg
1141debfc3dSmrg fold = targetm.builtin_decl (id, true);
1151debfc3dSmrg
1161debfc3dSmrg if (fold != error_mark_node)
1171debfc3dSmrg fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
1181debfc3dSmrg
1191debfc3dSmrg break; // absfx
1201debfc3dSmrg
1211debfc3dSmrg case AVR_BUILTIN_ROUNDFX:
1221debfc3dSmrg if (args.length() != 2)
1231debfc3dSmrg {
1241debfc3dSmrg error_at (loc, "%qs expects 2 arguments but %d given",
1251debfc3dSmrg "roundfx", (int) args.length());
1261debfc3dSmrg
1271debfc3dSmrg fold = error_mark_node;
1281debfc3dSmrg break;
1291debfc3dSmrg }
1301debfc3dSmrg
1311debfc3dSmrg type0 = TREE_TYPE (args[0]);
1321debfc3dSmrg type1 = TREE_TYPE (args[1]);
1331debfc3dSmrg
1341debfc3dSmrg if (!FIXED_POINT_TYPE_P (type0))
1351debfc3dSmrg {
1361debfc3dSmrg error_at (loc, "%qs expects a fixed-point value as first argument",
1371debfc3dSmrg "roundfx");
1381debfc3dSmrg
1391debfc3dSmrg fold = error_mark_node;
1401debfc3dSmrg }
1411debfc3dSmrg
1421debfc3dSmrg if (!INTEGRAL_TYPE_P (type1))
1431debfc3dSmrg {
1441debfc3dSmrg error_at (loc, "%qs expects an integer value as second argument",
1451debfc3dSmrg "roundfx");
1461debfc3dSmrg
1471debfc3dSmrg fold = error_mark_node;
1481debfc3dSmrg }
1491debfc3dSmrg
1501debfc3dSmrg switch (TYPE_MODE (type0))
1511debfc3dSmrg {
152a2dc1f3fSmrg case E_QQmode: id = AVR_BUILTIN_ROUNDHR; break;
153a2dc1f3fSmrg case E_HQmode: id = AVR_BUILTIN_ROUNDR; break;
154a2dc1f3fSmrg case E_SQmode: id = AVR_BUILTIN_ROUNDLR; break;
155a2dc1f3fSmrg case E_DQmode: id = AVR_BUILTIN_ROUNDLLR; break;
1561debfc3dSmrg
157a2dc1f3fSmrg case E_UQQmode: id = AVR_BUILTIN_ROUNDUHR; break;
158a2dc1f3fSmrg case E_UHQmode: id = AVR_BUILTIN_ROUNDUR; break;
159a2dc1f3fSmrg case E_USQmode: id = AVR_BUILTIN_ROUNDULR; break;
160a2dc1f3fSmrg case E_UDQmode: id = AVR_BUILTIN_ROUNDULLR; break;
1611debfc3dSmrg
162a2dc1f3fSmrg case E_HAmode: id = AVR_BUILTIN_ROUNDHK; break;
163a2dc1f3fSmrg case E_SAmode: id = AVR_BUILTIN_ROUNDK; break;
164a2dc1f3fSmrg case E_DAmode: id = AVR_BUILTIN_ROUNDLK; break;
165a2dc1f3fSmrg case E_TAmode: id = AVR_BUILTIN_ROUNDLLK; break;
1661debfc3dSmrg
167a2dc1f3fSmrg case E_UHAmode: id = AVR_BUILTIN_ROUNDUHK; break;
168a2dc1f3fSmrg case E_USAmode: id = AVR_BUILTIN_ROUNDUK; break;
169a2dc1f3fSmrg case E_UDAmode: id = AVR_BUILTIN_ROUNDULK; break;
170a2dc1f3fSmrg case E_UTAmode: id = AVR_BUILTIN_ROUNDULLK; break;
1711debfc3dSmrg
1721debfc3dSmrg default:
1731debfc3dSmrg error_at (loc, "no matching fixed-point overload found for %qs",
1741debfc3dSmrg "roundfx");
1751debfc3dSmrg
1761debfc3dSmrg fold = error_mark_node;
1771debfc3dSmrg break;
1781debfc3dSmrg }
1791debfc3dSmrg
1801debfc3dSmrg fold = targetm.builtin_decl (id, true);
1811debfc3dSmrg
1821debfc3dSmrg if (fold != error_mark_node)
1831debfc3dSmrg fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
1841debfc3dSmrg
1851debfc3dSmrg break; // roundfx
1861debfc3dSmrg
1871debfc3dSmrg case AVR_BUILTIN_COUNTLSFX:
1881debfc3dSmrg if (args.length() != 1)
1891debfc3dSmrg {
1901debfc3dSmrg error_at (loc, "%qs expects 1 argument but %d given",
1911debfc3dSmrg "countlsfx", (int) args.length());
1921debfc3dSmrg
1931debfc3dSmrg fold = error_mark_node;
1941debfc3dSmrg break;
1951debfc3dSmrg }
1961debfc3dSmrg
1971debfc3dSmrg type0 = TREE_TYPE (args[0]);
1981debfc3dSmrg
1991debfc3dSmrg if (!FIXED_POINT_TYPE_P (type0))
2001debfc3dSmrg {
2011debfc3dSmrg error_at (loc, "%qs expects a fixed-point value as first argument",
2021debfc3dSmrg "countlsfx");
2031debfc3dSmrg
2041debfc3dSmrg fold = error_mark_node;
2051debfc3dSmrg }
2061debfc3dSmrg
2071debfc3dSmrg switch (TYPE_MODE (type0))
2081debfc3dSmrg {
209a2dc1f3fSmrg case E_QQmode: id = AVR_BUILTIN_COUNTLSHR; break;
210a2dc1f3fSmrg case E_HQmode: id = AVR_BUILTIN_COUNTLSR; break;
211a2dc1f3fSmrg case E_SQmode: id = AVR_BUILTIN_COUNTLSLR; break;
212a2dc1f3fSmrg case E_DQmode: id = AVR_BUILTIN_COUNTLSLLR; break;
2131debfc3dSmrg
214a2dc1f3fSmrg case E_UQQmode: id = AVR_BUILTIN_COUNTLSUHR; break;
215a2dc1f3fSmrg case E_UHQmode: id = AVR_BUILTIN_COUNTLSUR; break;
216a2dc1f3fSmrg case E_USQmode: id = AVR_BUILTIN_COUNTLSULR; break;
217a2dc1f3fSmrg case E_UDQmode: id = AVR_BUILTIN_COUNTLSULLR; break;
2181debfc3dSmrg
219a2dc1f3fSmrg case E_HAmode: id = AVR_BUILTIN_COUNTLSHK; break;
220a2dc1f3fSmrg case E_SAmode: id = AVR_BUILTIN_COUNTLSK; break;
221a2dc1f3fSmrg case E_DAmode: id = AVR_BUILTIN_COUNTLSLK; break;
222a2dc1f3fSmrg case E_TAmode: id = AVR_BUILTIN_COUNTLSLLK; break;
2231debfc3dSmrg
224a2dc1f3fSmrg case E_UHAmode: id = AVR_BUILTIN_COUNTLSUHK; break;
225a2dc1f3fSmrg case E_USAmode: id = AVR_BUILTIN_COUNTLSUK; break;
226a2dc1f3fSmrg case E_UDAmode: id = AVR_BUILTIN_COUNTLSULK; break;
227a2dc1f3fSmrg case E_UTAmode: id = AVR_BUILTIN_COUNTLSULLK; break;
2281debfc3dSmrg
2291debfc3dSmrg default:
2301debfc3dSmrg error_at (loc, "no matching fixed-point overload found for %qs",
2311debfc3dSmrg "countlsfx");
2321debfc3dSmrg
2331debfc3dSmrg fold = error_mark_node;
2341debfc3dSmrg break;
2351debfc3dSmrg }
2361debfc3dSmrg
2371debfc3dSmrg fold = targetm.builtin_decl (id, true);
2381debfc3dSmrg
2391debfc3dSmrg if (fold != error_mark_node)
2401debfc3dSmrg fold = build_function_call_vec (loc, vNULL, fold, &args, NULL);
2411debfc3dSmrg
2421debfc3dSmrg break; // countlsfx
2431debfc3dSmrg }
2441debfc3dSmrg
2451debfc3dSmrg return fold;
2461debfc3dSmrg }
2471debfc3dSmrg
2481debfc3dSmrg
2491debfc3dSmrg /* Implement `REGISTER_TARGET_PRAGMAS'. */
2501debfc3dSmrg
2511debfc3dSmrg void
avr_register_target_pragmas(void)2521debfc3dSmrg avr_register_target_pragmas (void)
2531debfc3dSmrg {
2541debfc3dSmrg gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM);
2551debfc3dSmrg
2561debfc3dSmrg /* Register address spaces. The order must be the same as in the respective
2571debfc3dSmrg enum from avr.h (or designated initializers must be used in avr.c).
2581debfc3dSmrg We always register all address spaces even if some of them make no
2591debfc3dSmrg sense for some targets. Diagnose for non-supported spaces will be
2601debfc3dSmrg emit by TARGET_ADDR_SPACE_DIAGNOSE_USAGE. */
2611debfc3dSmrg
2621debfc3dSmrg for (int i = 0; i < ADDR_SPACE_COUNT; i++)
2631debfc3dSmrg {
2641debfc3dSmrg gcc_assert (i == avr_addrspace[i].id);
2651debfc3dSmrg
2661debfc3dSmrg if (!ADDR_SPACE_GENERIC_P (i))
2671debfc3dSmrg c_register_addr_space (avr_addrspace[i].name, avr_addrspace[i].id);
2681debfc3dSmrg }
2691debfc3dSmrg
2701debfc3dSmrg targetm.resolve_overloaded_builtin = avr_resolve_overloaded_builtin;
2711debfc3dSmrg }
2721debfc3dSmrg
2731debfc3dSmrg
2741debfc3dSmrg /* Transform LO into uppercase and write the result to UP.
2751debfc3dSmrg You must provide enough space for UP. Return UP. */
2761debfc3dSmrg
2771debfc3dSmrg static char*
avr_toupper(char * up,const char * lo)2781debfc3dSmrg avr_toupper (char *up, const char *lo)
2791debfc3dSmrg {
2801debfc3dSmrg char *up0 = up;
2811debfc3dSmrg
2821debfc3dSmrg for (; *lo; lo++, up++)
2831debfc3dSmrg *up = TOUPPER (*lo);
2841debfc3dSmrg
2851debfc3dSmrg *up = '\0';
2861debfc3dSmrg
2871debfc3dSmrg return up0;
2881debfc3dSmrg }
2891debfc3dSmrg
2901debfc3dSmrg /* Worker function for TARGET_CPU_CPP_BUILTINS. */
2911debfc3dSmrg
2921debfc3dSmrg void
avr_cpu_cpp_builtins(struct cpp_reader * pfile)2931debfc3dSmrg avr_cpu_cpp_builtins (struct cpp_reader *pfile)
2941debfc3dSmrg {
2951debfc3dSmrg builtin_define_std ("AVR");
2961debfc3dSmrg
2971debfc3dSmrg /* __AVR_DEVICE_NAME__ and avr_mcu_types[].macro like __AVR_ATmega8__
2981debfc3dSmrg are defined by -D command option, see device-specs file. */
2991debfc3dSmrg
3001debfc3dSmrg if (avr_arch->macro)
3011debfc3dSmrg cpp_define_formatted (pfile, "__AVR_ARCH__=%s", avr_arch->macro);
3021debfc3dSmrg if (AVR_HAVE_RAMPD) cpp_define (pfile, "__AVR_HAVE_RAMPD__");
3031debfc3dSmrg if (AVR_HAVE_RAMPX) cpp_define (pfile, "__AVR_HAVE_RAMPX__");
3041debfc3dSmrg if (AVR_HAVE_RAMPY) cpp_define (pfile, "__AVR_HAVE_RAMPY__");
3051debfc3dSmrg if (AVR_HAVE_RAMPZ) cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
3061debfc3dSmrg if (AVR_HAVE_ELPM) cpp_define (pfile, "__AVR_HAVE_ELPM__");
3071debfc3dSmrg if (AVR_HAVE_ELPMX) cpp_define (pfile, "__AVR_HAVE_ELPMX__");
3081debfc3dSmrg if (AVR_HAVE_MOVW) cpp_define (pfile, "__AVR_HAVE_MOVW__");
3091debfc3dSmrg if (AVR_HAVE_LPMX) cpp_define (pfile, "__AVR_HAVE_LPMX__");
3101debfc3dSmrg
3111debfc3dSmrg if (avr_arch->asm_only)
3121debfc3dSmrg cpp_define (pfile, "__AVR_ASM_ONLY__");
3131debfc3dSmrg if (AVR_HAVE_MUL)
3141debfc3dSmrg {
3151debfc3dSmrg cpp_define (pfile, "__AVR_ENHANCED__");
3161debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_MUL__");
3171debfc3dSmrg }
318a2dc1f3fSmrg
319a2dc1f3fSmrg if (AVR_HAVE_JMP_CALL)
3201debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
321a2dc1f3fSmrg
322a2dc1f3fSmrg if (avr_arch->have_jmp_call)
323a2dc1f3fSmrg cpp_define (pfile, "__AVR_MEGA__");
324a2dc1f3fSmrg
325a2dc1f3fSmrg if (AVR_SHORT_CALLS)
326a2dc1f3fSmrg cpp_define (pfile, "__AVR_SHORT_CALLS__");
327a2dc1f3fSmrg
3281debfc3dSmrg if (AVR_XMEGA)
3291debfc3dSmrg cpp_define (pfile, "__AVR_XMEGA__");
3301debfc3dSmrg
3311debfc3dSmrg if (AVR_TINY)
3321debfc3dSmrg {
3331debfc3dSmrg cpp_define (pfile, "__AVR_TINY__");
3341debfc3dSmrg
3351debfc3dSmrg /* Define macro "__AVR_TINY_PM_BASE_ADDRESS__" with mapped program memory
3361debfc3dSmrg start address. This macro shall be used where mapped program
3371debfc3dSmrg memory is accessed, eg. copying data section (__do_copy_data)
3381debfc3dSmrg contents to data memory region.
3391debfc3dSmrg NOTE:
3401debfc3dSmrg Program memory of AVR_TINY devices cannot be accessed directly,
3411debfc3dSmrg it has been mapped to the data memory. For AVR_TINY devices
3421debfc3dSmrg (ATtiny4/5/9/10/20 and 40) mapped program memory starts at 0x4000. */
3431debfc3dSmrg
3441debfc3dSmrg cpp_define_formatted (pfile, "__AVR_TINY_PM_BASE_ADDRESS__=0x%x",
345a2dc1f3fSmrg avr_arch->flash_pm_offset);
3461debfc3dSmrg }
3471debfc3dSmrg
348a2dc1f3fSmrg if (avr_arch->flash_pm_offset)
349a2dc1f3fSmrg cpp_define_formatted (pfile, "__AVR_PM_BASE_ADDRESS__=0x%x",
350a2dc1f3fSmrg avr_arch->flash_pm_offset);
351a2dc1f3fSmrg
3521debfc3dSmrg if (AVR_HAVE_EIJMP_EICALL)
3531debfc3dSmrg {
3541debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
3551debfc3dSmrg cpp_define (pfile, "__AVR_3_BYTE_PC__");
3561debfc3dSmrg }
3571debfc3dSmrg else
3581debfc3dSmrg {
3591debfc3dSmrg cpp_define (pfile, "__AVR_2_BYTE_PC__");
3601debfc3dSmrg }
3611debfc3dSmrg
3621debfc3dSmrg if (AVR_HAVE_8BIT_SP)
3631debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
3641debfc3dSmrg else
3651debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
3661debfc3dSmrg
3671debfc3dSmrg if (AVR_HAVE_SPH)
3681debfc3dSmrg cpp_define (pfile, "__AVR_HAVE_SPH__");
3691debfc3dSmrg else
3701debfc3dSmrg cpp_define (pfile, "__AVR_SP8__");
3711debfc3dSmrg
3721debfc3dSmrg if (TARGET_NO_INTERRUPTS)
3731debfc3dSmrg cpp_define (pfile, "__NO_INTERRUPTS__");
3741debfc3dSmrg
3751debfc3dSmrg if (TARGET_SKIP_BUG)
3761debfc3dSmrg {
3771debfc3dSmrg cpp_define (pfile, "__AVR_ERRATA_SKIP__");
3781debfc3dSmrg
3791debfc3dSmrg if (AVR_HAVE_JMP_CALL)
3801debfc3dSmrg cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__");
3811debfc3dSmrg }
3821debfc3dSmrg
3831debfc3dSmrg if (TARGET_RMW)
3841debfc3dSmrg cpp_define (pfile, "__AVR_ISA_RMW__");
3851debfc3dSmrg
3861debfc3dSmrg cpp_define_formatted (pfile, "__AVR_SFR_OFFSET__=0x%x",
3871debfc3dSmrg avr_arch->sfr_offset);
3881debfc3dSmrg
3891debfc3dSmrg #ifdef WITH_AVRLIBC
3901debfc3dSmrg cpp_define (pfile, "__WITH_AVRLIBC__");
3911debfc3dSmrg #endif /* WITH_AVRLIBC */
3921debfc3dSmrg
393*8feb0f0bSmrg // From configure --with-libf7={|libgcc|math|math-symbols|yes|no}
394*8feb0f0bSmrg
395*8feb0f0bSmrg #ifdef WITH_LIBF7_LIBGCC
396*8feb0f0bSmrg cpp_define (pfile, "__WITH_LIBF7_LIBGCC__");
397*8feb0f0bSmrg #endif /* WITH_LIBF7_LIBGCC */
398*8feb0f0bSmrg
399*8feb0f0bSmrg #ifdef WITH_LIBF7_MATH
400*8feb0f0bSmrg cpp_define (pfile, "__WITH_LIBF7_MATH__");
401*8feb0f0bSmrg #endif /* WITH_LIBF7_MATH */
402*8feb0f0bSmrg
403*8feb0f0bSmrg #ifdef WITH_LIBF7_MATH_SYMBOLS
404*8feb0f0bSmrg cpp_define (pfile, "__WITH_LIBF7_MATH_SYMBOLS__");
405*8feb0f0bSmrg #endif /* WITH_LIBF7_MATH_SYMBOLS */
406*8feb0f0bSmrg
407*8feb0f0bSmrg // From configure --with-double={|32|32,64|64,32|64}
408*8feb0f0bSmrg
409*8feb0f0bSmrg #ifdef HAVE_DOUBLE_MULTILIB
410*8feb0f0bSmrg cpp_define (pfile, "__HAVE_DOUBLE_MULTILIB__");
411*8feb0f0bSmrg #endif
412*8feb0f0bSmrg
413*8feb0f0bSmrg #ifdef HAVE_DOUBLE64
414*8feb0f0bSmrg cpp_define (pfile, "__HAVE_DOUBLE64__");
415*8feb0f0bSmrg #endif
416*8feb0f0bSmrg
417*8feb0f0bSmrg #ifdef HAVE_DOUBLE32
418*8feb0f0bSmrg cpp_define (pfile, "__HAVE_DOUBLE32__");
419*8feb0f0bSmrg #endif
420*8feb0f0bSmrg
421*8feb0f0bSmrg #if defined (WITH_DOUBLE64)
422*8feb0f0bSmrg cpp_define (pfile, "__DEFAULT_DOUBLE__=64");
423*8feb0f0bSmrg #elif defined (WITH_DOUBLE32)
424*8feb0f0bSmrg cpp_define (pfile, "__DEFAULT_DOUBLE__=32");
425*8feb0f0bSmrg #else
426*8feb0f0bSmrg #error "align this with config.gcc"
427*8feb0f0bSmrg #endif
428*8feb0f0bSmrg
429*8feb0f0bSmrg // From configure --with-long-double={|32|32,64|64,32|64|double}
430*8feb0f0bSmrg
431*8feb0f0bSmrg #ifdef HAVE_LONG_DOUBLE_MULTILIB
432*8feb0f0bSmrg cpp_define (pfile, "__HAVE_LONG_DOUBLE_MULTILIB__");
433*8feb0f0bSmrg #endif
434*8feb0f0bSmrg
435*8feb0f0bSmrg #ifdef HAVE_LONG_DOUBLE64
436*8feb0f0bSmrg cpp_define (pfile, "__HAVE_LONG_DOUBLE64__");
437*8feb0f0bSmrg #endif
438*8feb0f0bSmrg
439*8feb0f0bSmrg #ifdef HAVE_LONG_DOUBLE32
440*8feb0f0bSmrg cpp_define (pfile, "__HAVE_LONG_DOUBLE32__");
441*8feb0f0bSmrg #endif
442*8feb0f0bSmrg
443*8feb0f0bSmrg #ifdef HAVE_LONG_DOUBLE_IS_DOUBLE
444*8feb0f0bSmrg cpp_define (pfile, "__HAVE_LONG_DOUBLE_IS_DOUBLE__");
445*8feb0f0bSmrg #endif
446*8feb0f0bSmrg
447*8feb0f0bSmrg #if defined (WITH_LONG_DOUBLE64)
448*8feb0f0bSmrg cpp_define (pfile, "__DEFAULT_LONG_DOUBLE__=64");
449*8feb0f0bSmrg #elif defined (WITH_LONG_DOUBLE32)
450*8feb0f0bSmrg cpp_define (pfile, "__DEFAULT_LONG_DOUBLE__=32");
451*8feb0f0bSmrg #else
452*8feb0f0bSmrg #error "align this with config.gcc"
453*8feb0f0bSmrg #endif
454*8feb0f0bSmrg
455*8feb0f0bSmrg // From configure --with-double-comparison={2|3} --with-libf7.
456*8feb0f0bSmrg
457*8feb0f0bSmrg #if defined (WITH_DOUBLE_COMPARISON)
458*8feb0f0bSmrg #if WITH_DOUBLE_COMPARISON == 2 || WITH_DOUBLE_COMPARISON == 3
459*8feb0f0bSmrg /* The number of states a DFmode comparison libcall might take and
460*8feb0f0bSmrg reflects what avr.c:FLOAT_LIB_COMPARE_RETURNS_BOOL returns for
461*8feb0f0bSmrg DFmode. GCC's default is 3-state, but some libraries like LibF7
462*8feb0f0bSmrg implement true / false (2-state). */
463*8feb0f0bSmrg cpp_define_formatted (pfile, "__WITH_DOUBLE_COMPARISON__=%d",
464*8feb0f0bSmrg WITH_DOUBLE_COMPARISON);
465*8feb0f0bSmrg #else
466*8feb0f0bSmrg #error "align this with config.gcc"
467*8feb0f0bSmrg #endif
468*8feb0f0bSmrg #else
469*8feb0f0bSmrg #error "align this with config.gcc"
470*8feb0f0bSmrg #endif
471*8feb0f0bSmrg
4721debfc3dSmrg /* Define builtin macros so that the user can easily query whether
4731debfc3dSmrg non-generic address spaces (and which) are supported or not.
4741debfc3dSmrg This is only supported for C. For C++, a language extension is needed
4751debfc3dSmrg (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not
4761debfc3dSmrg implemented in GCC up to now. */
4771debfc3dSmrg
4781debfc3dSmrg if (lang_GNU_C ())
4791debfc3dSmrg {
4801debfc3dSmrg for (int i = 0; i < ADDR_SPACE_COUNT; i++)
4811debfc3dSmrg if (!ADDR_SPACE_GENERIC_P (i)
4821debfc3dSmrg /* Only supply __FLASH<n> macro if the address space is reasonable
4831debfc3dSmrg for this target. The address space qualifier itself is still
4841debfc3dSmrg supported, but using it will throw an error. */
4851debfc3dSmrg && avr_addr_space_supported_p ((addr_space_t) i))
4861debfc3dSmrg {
4871debfc3dSmrg const char *name = avr_addrspace[i].name;
4881debfc3dSmrg char *Name = (char*) alloca (1 + strlen (name));
4891debfc3dSmrg
4901debfc3dSmrg cpp_define (pfile, avr_toupper (Name, name));
4911debfc3dSmrg }
4921debfc3dSmrg }
4931debfc3dSmrg
4941debfc3dSmrg /* Define builtin macros so that the user can easily query whether or
4951debfc3dSmrg not a specific builtin is available. */
4961debfc3dSmrg
4971debfc3dSmrg #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME) \
4981debfc3dSmrg cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
4991debfc3dSmrg #include "builtins.def"
5001debfc3dSmrg #undef DEF_BUILTIN
5011debfc3dSmrg
5021debfc3dSmrg /* Builtin macros for the __int24 and __uint24 type. */
5031debfc3dSmrg
5041debfc3dSmrg cpp_define_formatted (pfile, "__INT24_MAX__=8388607%s",
5051debfc3dSmrg INT_TYPE_SIZE == 8 ? "LL" : "L");
5061debfc3dSmrg cpp_define (pfile, "__INT24_MIN__=(-__INT24_MAX__-1)");
5071debfc3dSmrg cpp_define_formatted (pfile, "__UINT24_MAX__=16777215%s",
5081debfc3dSmrg INT_TYPE_SIZE == 8 ? "ULL" : "UL");
5091debfc3dSmrg }
510