mirror of git://gcc.gnu.org/git/gcc.git
avr-protos.h (avr_addr_space_supported_p): New prototype.
gcc/ * config/avr/avr-protos.h (avr_addr_space_supported_p): New prototype. * config/avr/avr.c (TARGET_ADDR_SPACE_DIAGNOSE_USAGE): New hook define... (avr_addr_space_diagnose_usage): ...and implementation. (avr_addr_space_supported_p): New function. (avr_nonconst_pointer_addrspace, avr_pgm_check_var_decl): Only report bad address space usage if that space is supported. (avr_insert_attributes): Same. No more complain about unsupported address spaces. * config/avr/avr-c.c (tm_p.h): Include it. (avr_cpu_cpp_builtins): Only define addr-space related built-in macro if avr_addr_space_supported_p. From-SVN: r238519
This commit is contained in:
parent
b25ea150b6
commit
2d06ca74a2
|
|
@ -1,3 +1,18 @@
|
||||||
|
2016-07-20 Georg-Johann Lay <avr@gjlay.de>
|
||||||
|
|
||||||
|
* config/avr/avr-protos.h (avr_addr_space_supported_p): New prototype.
|
||||||
|
* config/avr/avr.c (TARGET_ADDR_SPACE_DIAGNOSE_USAGE): New hook
|
||||||
|
define...
|
||||||
|
(avr_addr_space_diagnose_usage): ...and implementation.
|
||||||
|
(avr_addr_space_supported_p): New function.
|
||||||
|
(avr_nonconst_pointer_addrspace, avr_pgm_check_var_decl): Only
|
||||||
|
report bad address space usage if that space is supported.
|
||||||
|
(avr_insert_attributes): Same. No more complain about unsupported
|
||||||
|
address spaces.
|
||||||
|
* config/avr/avr-c.c (tm_p.h): Include it.
|
||||||
|
(avr_cpu_cpp_builtins): Only define addr-space related built-in
|
||||||
|
macro if avr_addr_space_supported_p.
|
||||||
|
|
||||||
2016-07-20 Alexander Monakov <amonakov@ispras.ru>
|
2016-07-20 Alexander Monakov <amonakov@ispras.ru>
|
||||||
|
|
||||||
* config/nvptx/nvptx.c (nvptx_option_override): Do not set
|
* config/nvptx/nvptx.c (nvptx_option_override): Do not set
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#include "c-family/c-common.h"
|
#include "c-family/c-common.h"
|
||||||
#include "stor-layout.h"
|
#include "stor-layout.h"
|
||||||
#include "langhooks.h"
|
#include "langhooks.h"
|
||||||
|
#include "tm_p.h"
|
||||||
|
|
||||||
/* IDs for all the AVR builtins. */
|
/* IDs for all the AVR builtins. */
|
||||||
|
|
||||||
|
|
@ -253,7 +253,10 @@ avr_register_target_pragmas (void)
|
||||||
gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM);
|
gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM);
|
||||||
|
|
||||||
/* Register address spaces. The order must be the same as in the respective
|
/* Register address spaces. The order must be the same as in the respective
|
||||||
enum from avr.h (or designated initializers must be used in avr.c). */
|
enum from avr.h (or designated initializers must be used in avr.c).
|
||||||
|
We always register all address spaces even if some of them make no
|
||||||
|
sense for some targets. Diagnose for non-supported spaces will be
|
||||||
|
emit by TARGET_ADDR_SPACE_DIAGNOSE_USAGE. */
|
||||||
|
|
||||||
for (i = 0; i < ADDR_SPACE_COUNT; i++)
|
for (i = 0; i < ADDR_SPACE_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -391,10 +394,7 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
|
||||||
/* Only supply __FLASH<n> macro if the address space is reasonable
|
/* Only supply __FLASH<n> macro if the address space is reasonable
|
||||||
for this target. The address space qualifier itself is still
|
for this target. The address space qualifier itself is still
|
||||||
supported, but using it will throw an error. */
|
supported, but using it will throw an error. */
|
||||||
&& avr_addrspace[i].segment < avr_n_flash
|
&& avr_addr_space_supported_p ((addr_space_t) i))
|
||||||
/* Only support __MEMX macro if we have LPM. */
|
|
||||||
&& (AVR_HAVE_LPM || avr_addrspace[i].pointer_size <= 2))
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *name = avr_addrspace[i].name;
|
const char *name = avr_addrspace[i].name;
|
||||||
char *Name = (char*) alloca (1 + strlen (name));
|
char *Name = (char*) alloca (1 + strlen (name));
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ extern void avr_asm_output_aligned_decl_common (FILE*, tree, const char*, unsign
|
||||||
extern void avr_asm_asm_output_aligned_bss (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int, void (*) (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int));
|
extern void avr_asm_asm_output_aligned_bss (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int, void (*) (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int));
|
||||||
extern void asm_output_external (FILE *file, tree decl, char *name);
|
extern void asm_output_external (FILE *file, tree decl, char *name);
|
||||||
extern int avr_progmem_p (tree decl, tree attributes);
|
extern int avr_progmem_p (tree decl, tree attributes);
|
||||||
|
extern bool avr_addr_space_supported_p (addr_space_t, location_t loc = UNKNOWN_LOCATION);
|
||||||
|
|
||||||
#ifdef RTX_CODE /* inside TREE_CODE */
|
#ifdef RTX_CODE /* inside TREE_CODE */
|
||||||
extern void avr_init_cumulative_args (CUMULATIVE_ARGS*, tree, rtx, tree);
|
extern void avr_init_cumulative_args (CUMULATIVE_ARGS*, tree, rtx, tree);
|
||||||
|
|
|
||||||
|
|
@ -9148,6 +9148,42 @@ avr_attribute_table[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Return true if we support address space AS for the architecture in effect
|
||||||
|
and false, otherwise. If LOC is not UNKNOWN_LOCATION then also issue
|
||||||
|
a respective error. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
avr_addr_space_supported_p (addr_space_t as, location_t loc)
|
||||||
|
{
|
||||||
|
if (AVR_TINY)
|
||||||
|
{
|
||||||
|
if (loc != UNKNOWN_LOCATION)
|
||||||
|
error_at (loc, "address spaces are not supported for reduced "
|
||||||
|
"Tiny devices");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (avr_addrspace[as].segment >= avr_n_flash)
|
||||||
|
{
|
||||||
|
if (loc != UNKNOWN_LOCATION)
|
||||||
|
error_at (loc, "address space %qs not supported for devices with "
|
||||||
|
"flash size up to %d KiB", avr_addrspace[as].name,
|
||||||
|
64 * avr_n_flash);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Implement `TARGET_ADDR_SPACE_DIAGNOSE_USAGE'. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
avr_addr_space_diagnose_usage (addr_space_t as, location_t loc)
|
||||||
|
{
|
||||||
|
(void) avr_addr_space_supported_p (as, loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Look if DECL shall be placed in program memory space by
|
/* Look if DECL shall be placed in program memory space by
|
||||||
means of attribute `progmem' or some address-space qualifier.
|
means of attribute `progmem' or some address-space qualifier.
|
||||||
Return non-zero if DECL is data that must end up in Flash and
|
Return non-zero if DECL is data that must end up in Flash and
|
||||||
|
|
@ -9218,16 +9254,13 @@ avr_nonconst_pointer_addrspace (tree typ)
|
||||||
while (TREE_CODE (target) == ARRAY_TYPE)
|
while (TREE_CODE (target) == ARRAY_TYPE)
|
||||||
target = TREE_TYPE (target);
|
target = TREE_TYPE (target);
|
||||||
|
|
||||||
/* Pointers to non-generic address space must be const.
|
/* Pointers to non-generic address space must be const. */
|
||||||
Refuse address spaces outside the device's flash. */
|
|
||||||
|
|
||||||
as = TYPE_ADDR_SPACE (target);
|
as = TYPE_ADDR_SPACE (target);
|
||||||
|
|
||||||
if (!ADDR_SPACE_GENERIC_P (as)
|
if (!ADDR_SPACE_GENERIC_P (as)
|
||||||
&& (!TYPE_READONLY (target)
|
&& !TYPE_READONLY (target)
|
||||||
|| avr_addrspace[as].segment >= avr_n_flash
|
&& avr_addr_space_supported_p (as))
|
||||||
/* Also refuse __memx address space if we can't support it. */
|
|
||||||
|| (!AVR_HAVE_LPM && avr_addrspace[as].pointer_size > 2)))
|
|
||||||
{
|
{
|
||||||
return as;
|
return as;
|
||||||
}
|
}
|
||||||
|
|
@ -9291,25 +9324,13 @@ avr_pgm_check_var_decl (tree node)
|
||||||
|
|
||||||
if (reason)
|
if (reason)
|
||||||
{
|
{
|
||||||
if (avr_addrspace[as].segment >= avr_n_flash)
|
if (TYPE_P (node))
|
||||||
{
|
error ("pointer targeting address space %qs must be const in %qT",
|
||||||
if (TYPE_P (node))
|
avr_addrspace[as].name, node);
|
||||||
error ("%qT uses address space %qs beyond flash of %d KiB",
|
|
||||||
node, avr_addrspace[as].name, 64 * avr_n_flash);
|
|
||||||
else
|
|
||||||
error ("%s %q+D uses address space %qs beyond flash of %d KiB",
|
|
||||||
reason, node, avr_addrspace[as].name, 64 * avr_n_flash);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
error ("pointer targeting address space %qs must be const"
|
||||||
if (TYPE_P (node))
|
" in %s %q+D",
|
||||||
error ("pointer targeting address space %qs must be const in %qT",
|
avr_addrspace[as].name, reason, node);
|
||||||
avr_addrspace[as].name, node);
|
|
||||||
else
|
|
||||||
error ("pointer targeting address space %qs must be const"
|
|
||||||
" in %s %q+D",
|
|
||||||
avr_addrspace[as].name, reason, node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return reason == NULL;
|
return reason == NULL;
|
||||||
|
|
@ -9342,18 +9363,6 @@ avr_insert_attributes (tree node, tree *attributes)
|
||||||
|
|
||||||
as = TYPE_ADDR_SPACE (TREE_TYPE (node));
|
as = TYPE_ADDR_SPACE (TREE_TYPE (node));
|
||||||
|
|
||||||
if (avr_addrspace[as].segment >= avr_n_flash)
|
|
||||||
{
|
|
||||||
error ("variable %q+D located in address space %qs beyond flash "
|
|
||||||
"of %d KiB", node, avr_addrspace[as].name, 64 * avr_n_flash);
|
|
||||||
}
|
|
||||||
else if (!AVR_HAVE_LPM && avr_addrspace[as].pointer_size > 2)
|
|
||||||
{
|
|
||||||
error ("variable %q+D located in address space %qs"
|
|
||||||
" which is not supported for architecture %qs",
|
|
||||||
node, avr_addrspace[as].name, avr_arch->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TYPE_READONLY (node0)
|
if (!TYPE_READONLY (node0)
|
||||||
&& !TREE_READONLY (node))
|
&& !TREE_READONLY (node))
|
||||||
{
|
{
|
||||||
|
|
@ -13728,6 +13737,9 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg,
|
||||||
#undef TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS
|
#undef TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS
|
||||||
#define TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS avr_addr_space_legitimize_address
|
#define TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS avr_addr_space_legitimize_address
|
||||||
|
|
||||||
|
#undef TARGET_ADDR_SPACE_DIAGNOSE_USAGE
|
||||||
|
#define TARGET_ADDR_SPACE_DIAGNOSE_USAGE avr_addr_space_diagnose_usage
|
||||||
|
|
||||||
#undef TARGET_MODE_DEPENDENT_ADDRESS_P
|
#undef TARGET_MODE_DEPENDENT_ADDRESS_P
|
||||||
#define TARGET_MODE_DEPENDENT_ADDRESS_P avr_mode_dependent_address_p
|
#define TARGET_MODE_DEPENDENT_ADDRESS_P avr_mode_dependent_address_p
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue