+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
+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
int ARG_UNUSED (flags), bool *no_add_attrs)
{
tree decl = *node;
+ tree res = NULL_TREE;
if (!targetm_common.have_named_sections)
{
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
bool *no_add_attrs)
{
const char *message = NULL;
+ tree res = NULL_TREE;
gcc_assert (DECL_P (*node));
gcc_assert (args == NULL);
*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;
}
{ 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
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}
@hook TARGET_INSERT_ATTRIBUTES
+@hook TARGET_HANDLE_GENERIC_ATTRIBUTE
+
@hook TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
@hook TARGET_OPTION_VALID_ATTRIBUTE_P
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 *)
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);
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