not a specific builtin is available. */
#define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME, ATTRS) \
- cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
+ if (avr_builtin_supported_p (AVR_BUILTIN_ ## NAME)) \
+ cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
#include "builtins.def"
#undef DEF_BUILTIN
extern bool avr_function_arg_regno_p (int r);
extern void avr_cpu_cpp_builtins (cpp_reader * pfile);
+extern bool avr_builtin_supported_p (unsigned id);
extern enum reg_class avr_regno_reg_class (int r);
extern void asm_globalize_label (FILE *file, const char *name);
extern void avr_adjust_reg_alloc_order (void);
};
+/* Some of our built-in function are available for GNU-C only:
+ - Built-ins that use named address-spaces.
+ - Built-ins that use fixed-point types. */
+
+bool
+avr_builtin_supported_p (unsigned id)
+{
+ const bool uses_as = id == AVR_BUILTIN_FLASH_SEGMENT;
+
+ // We don't support address-spaces on Reduced Tiny.
+ if (AVR_TINY && uses_as)
+ return false;
+
+ return (lang_GNU_C ()
+ || id < AVR_FIRST_C_ONLY_BUILTIN_ID);
+}
+
+
/* Implement `TARGET_BUILTIN_DECL'. */
static tree
char *name = (char *) alloca (1 + strlen (Name)); \
\
gcc_assert (id < AVR_BUILTIN_COUNT); \
- avr_bdesc[id].fndecl \
- = add_builtin_function (avr_tolower (name, Name), TYPE, id, \
- BUILT_IN_MD, LIBNAME, ATTRS); \
+ avr_bdesc[id].fndecl = avr_builtin_supported_p (id) \
+ ? add_builtin_function (avr_tolower (name, Name), TYPE, id, \
+ BUILT_IN_MD, LIBNAME, ATTRS) \
+ : NULL_TREE; \
}
#include "builtins.def"
#undef DEF_BUILTIN
ATTRS: Function attributes like "attr_const" for the `const' attribute
or "NULL_TREE" for no attribute. */
+#define AVR_FIRST_C_ONLY_BUILTIN_ID AVR_BUILTIN_FLASH_SEGMENT
+
/* Mapped to respective instruction. */
DEF_BUILTIN (NOP, -1, void_ftype_void, nothing, NULL, NULL_TREE)
DEF_BUILTIN (NOPS, -1, void_ftype_uintSI, nothing, NULL, NULL_TREE)
DEF_BUILTIN (MASK1, 2, uintQI_ftype_uintQI_uintQI, gen_mask1, NULL, attr_const)
DEF_BUILTIN (INSERT_BITS, 3, uintQI_ftype_uintSI_uintQI_uintQI, insert_bits, NULL, attr_const)
+
+/* All following built-ins are C only, see avr.cc::avr_builtin_C_only_p()
+ * since they are using named address-spaces or fixed-point types, none
+ * of which are supported for C++. */
+
DEF_BUILTIN (FLASH_SEGMENT, 1, intQI_ftype_const_memx_ptr, flash_segment, NULL, attr_const)
/* ISO/IEC TR 18037 "Embedded C"
integer constant; delays with a variable number of cycles are not supported.
@enddefbuiltin
-@defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
-This built-in takes a byte address to the 24-bit
-@ref{AVR Named Address Spaces,address space} @code{__memx} and returns
-the number of the flash segment (the 64 KiB chunk) where the address
-points to. Counting starts at @code{0}.
-If the address does not point to flash memory, return @code{-1}.
-@enddefbuiltin
-
@defbuiltin{uint8_t __builtin_avr_insert_bits (uint32_t @var{map}, uint8_t @var{bits}, uint8_t @var{val})}
Insert bits from @var{bits} into @var{val} and return the resulting
value. The nibbles of @var{map} determine how the insertion is
The number of instructions must be a compile-time integer constant.
@enddefbuiltin
+@b{All of the following built-in functions are only available for GNU-C}
+
+@defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
+This built-in takes a byte address to the 24-bit
+@ref{AVR Named Address Spaces,named address space} @code{__memx} and returns
+the number of the flash segment (the 64 KiB chunk) where the address
+points to. Counting starts at @code{0}.
+If the address does not point to flash memory, return @code{-1}.
+@enddefbuiltin
+
@noindent
There are many more AVR-specific built-in functions that are used to
implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of