2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-13 15:31:15 +08:00

Implement TARGET_HANDLE_GENERIC_ATTRIBUTE

gcc/ChangeLog:

2019-09-03  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* config/msp430/msp430.c (TARGET_HANDLE_GENERIC_ATTRIBUTE): Define.
	(msp430_handle_generic_attribute): New function.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in: Add TARGET_HANDLE_GENERIC_ATTRIBUTE.
	* hooks.c (hook_tree_treeptr_tree_tree_int_boolptr_null): New.
	* hooks.h (hook_tree_treeptr_tree_tree_int_boolptr_null): New.
	* target.def: Define new hook TARGET_HANDLE_GENERIC_ATTRIBUTE.

gcc/c-family/ChangeLog:

2019-09-03  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* c-attribs.c (handle_section_attribute): Call the
	handle_generic_attribute target hook after performing target
	independent processing.
	(handle_noinit_attribute): Likewise.

From-SVN: r275355
This commit is contained in:
Jozef Lawrynowicz 2019-09-03 20:36:49 +00:00 committed by Jozef Lawrynowicz
parent 52792faa0c
commit 7a4418a53e
9 changed files with 114 additions and 10 deletions

@ -1,3 +1,13 @@
2019-09-03 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* config/msp430/msp430.c (TARGET_HANDLE_GENERIC_ATTRIBUTE): Define.
(msp430_handle_generic_attribute): New function.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add TARGET_HANDLE_GENERIC_ATTRIBUTE.
* hooks.c (hook_tree_treeptr_tree_tree_int_boolptr_null): New.
* hooks.h (hook_tree_treeptr_tree_tree_int_boolptr_null): New.
* target.def: Define new hook TARGET_HANDLE_GENERIC_ATTRIBUTE.
2019-09-03 Kamlesh Kumar <kamleshbhalui@gmail.com>
PR tree-optimization/91504

@ -1,3 +1,10 @@
2019-09-03 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* c-attribs.c (handle_section_attribute): Call the
handle_generic_attribute target hook after performing target
independent processing.
(handle_noinit_attribute): Likewise.
2019-09-03 Ian Lance Taylor <iant@golang.org>
* c-cppbuiltin.c (builtin_define_with_hex_fp_value): Always expand

@ -1875,6 +1875,7 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args,
int ARG_UNUSED (flags), bool *no_add_attrs)
{
tree decl = *node;
tree res = NULL_TREE;
if (!targetm_common.have_named_sections)
{
@ -1922,12 +1923,20 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args,
goto fail;
}
set_decl_section_name (decl, TREE_STRING_POINTER (TREE_VALUE (args)));
return NULL_TREE;
res = targetm.handle_generic_attribute (node, name, args, flags,
no_add_attrs);
/* If the back end confirms the attribute can be added then continue onto
final processing. */
if (!(*no_add_attrs))
{
set_decl_section_name (decl, TREE_STRING_POINTER (TREE_VALUE (args)));
return res;
}
fail:
*no_add_attrs = true;
return NULL_TREE;
return res;
}
/* If in c++-11, check if the c++-11 alignment constraint with respect
@ -2249,6 +2258,7 @@ handle_noinit_attribute (tree * node,
bool *no_add_attrs)
{
const char *message = NULL;
tree res = NULL_TREE;
gcc_assert (DECL_P (*node));
gcc_assert (args == NULL);
@ -2271,14 +2281,23 @@ handle_noinit_attribute (tree * node,
*no_add_attrs = true;
}
else
/* If this var is thought to be common, then change this. Common
variables are assigned to sections before the backend has a
chance to process them. Do this only if the attribute is
valid. */
if (DECL_COMMON (*node))
DECL_COMMON (*node) = 0;
{
res = targetm.handle_generic_attribute (node, name, args, flags,
no_add_attrs);
/* If the back end confirms the attribute can be added then continue onto
final processing. */
if (!(*no_add_attrs))
{
/* If this var is thought to be common, then change this. Common
variables are assigned to sections before the backend has a
chance to process them. Do this only if the attribute is
valid. */
if (DECL_COMMON (*node))
DECL_COMMON (*node) = 0;
}
}
return NULL_TREE;
return res;
}

@ -1518,6 +1518,46 @@ const struct attribute_spec msp430_attribute_table[] =
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
};
#undef TARGET_HANDLE_GENERIC_ATTRIBUTE
#define TARGET_HANDLE_GENERIC_ATTRIBUTE msp430_handle_generic_attribute
tree
msp430_handle_generic_attribute (tree *node,
tree name,
tree args ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED,
bool *no_add_attrs)
{
const char *message = NULL;
if (!(TREE_NAME_EQ (name, ATTR_NOINIT) || TREE_NAME_EQ (name, "section")))
return NULL_TREE;
/* The front end has set up an exclusion between the "noinit" and "section"
attributes. */
if (has_attr (ATTR_LOWER, *node))
message = G_("ignoring attribute %qE because it conflicts with "
"attribute %<lower%>");
else if (has_attr (ATTR_UPPER, *node))
message = G_("ignoring attribute %qE because it conflicts with "
"attribute %<upper%>");
else if (has_attr (ATTR_EITHER, *node))
message = G_("ignoring attribute %qE because it conflicts with "
"attribute %<either%>");
else if (has_attr (ATTR_PERSIST, *node))
message = G_("ignoring attribute %qE because it conflicts with "
"attribute %<persistent%>");
if (message)
{
warning (OPT_Wattributes, message, name);
*no_add_attrs = true;
}
return NULL_TREE;
}
#undef TARGET_ASM_FUNCTION_PROLOGUE
#define TARGET_ASM_FUNCTION_PROLOGUE msp430_start_function

@ -10391,6 +10391,14 @@ attributes, or a copy of the list may be made if further changes are
needed.
@end deftypefn
@deftypefn {Target Hook} tree TARGET_HANDLE_GENERIC_ATTRIBUTE (tree *@var{node}, tree @var{name}, tree @var{args}, int @var{flags}, bool *@var{no_add_attrs})
Define this target hook if you want to be able to perform additional
target-specific processing of an attribute which is handled generically
by a front end. The arguments are the same as those which are passed to
attribute handlers. So far this only affects the @var{noinit} and
@var{section} attribute.
@end deftypefn
@deftypefn {Target Hook} bool TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P (const_tree @var{fndecl})
@cindex inlining
This target hook returns @code{true} if it is OK to inline @var{fndecl}

@ -7200,6 +7200,8 @@ on this implementation detail.
@hook TARGET_INSERT_ATTRIBUTES
@hook TARGET_HANDLE_GENERIC_ATTRIBUTE
@hook TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
@hook TARGET_OPTION_VALID_ATTRIBUTE_P

@ -442,6 +442,12 @@ hook_tree_tree_tree_tree_null (tree, tree, tree)
return NULL;
}
tree
hook_tree_treeptr_tree_tree_int_boolptr_null (tree *, tree, tree, int, bool *)
{
return NULL;
}
/* Generic hook that takes an rtx_insn *and returns a NULL string. */
const char *
hook_constcharptr_const_rtx_insn_null (const rtx_insn *)

@ -109,6 +109,7 @@ extern tree hook_tree_void_null (void);
extern tree hook_tree_tree_tree_null (tree, tree);
extern tree hook_tree_tree_tree_tree_null (tree, tree, tree);
extern tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
extern tree hook_tree_treeptr_tree_tree_int_boolptr_null (tree *, tree, tree, int, bool *);
extern unsigned hook_uint_void_0 (void);
extern unsigned int hook_uint_mode_0 (machine_mode);

@ -2208,6 +2208,17 @@ needed.",
void, (tree node, tree *attr_ptr),
hook_void_tree_treeptr)
/* Perform additional target-specific processing of generic attributes. */
DEFHOOK
(handle_generic_attribute,
"Define this target hook if you want to be able to perform additional\n\
target-specific processing of an attribute which is handled generically\n\
by a front end. The arguments are the same as those which are passed to\n\
attribute handlers. So far this only affects the @var{noinit} and\n\
@var{section} attribute.",
tree, (tree *node, tree name, tree args, int flags, bool *no_add_attrs),
hook_tree_treeptr_tree_tree_int_boolptr_null)
/* Return true if FNDECL (which has at least one machine attribute)
can be inlined despite its machine attributes, false otherwise. */
DEFHOOK