diff options
Diffstat (limited to 'gcc/config/c4x/c4x.c')
-rw-r--r-- | gcc/config/c4x/c4x.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index 872cdfd..7ed86b2 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -191,14 +191,15 @@ static int c4x_parse_pragma PARAMS ((const char *, tree *, tree *)); static int c4x_r11_set_p PARAMS ((rtx)); static int c4x_rptb_valid_p PARAMS ((rtx, rtx)); static int c4x_label_ref_used_p PARAMS ((rtx, rtx)); -static int c4x_valid_type_attribute_p PARAMS ((tree, tree, tree, tree)); +static tree c4x_handle_fntype_attribute PARAMS ((tree *, tree, tree, int, bool *)); +const struct attribute_spec c4x_attribute_table[]; static void c4x_insert_attributes PARAMS ((tree, tree *)); static void c4x_asm_named_section PARAMS ((const char *, unsigned int)); static int c4x_adjust_cost PARAMS ((rtx, rtx, rtx, int)); /* Initialize the GCC target structure. */ -#undef TARGET_VALID_TYPE_ATTRIBUTE -#define TARGET_VALID_TYPE_ATTRIBUTE c4x_valid_type_attribute_p +#undef TARGET_ATTRIBUTE_TABLE +#define TARGET_ATTRIBUTE_TABLE c4x_attribute_table #undef TARGET_INSERT_ATTRIBUTES #define TARGET_INSERT_ATTRIBUTES c4x_insert_attributes @@ -4761,31 +4762,36 @@ c4x_insert_attributes (decl, attributes) } } +/* Table of valid machine attributes. */ +const struct attribute_spec c4x_attribute_table[] = +{ + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ + { "interrupt", 0, 0, false, true, true, c4x_handle_fntype_attribute }, + /* FIXME: code elsewhere in this file treats "naked" as a synonym of + "interrupt"; should it be accepted here? */ + { "assembler", 0, 0, false, true, true, c4x_handle_fntype_attribute }, + { "leaf_pretend", 0, 0, false, true, true, c4x_handle_fntype_attribute }, + { NULL, 0, 0, false, false, false, NULL } +}; -/* Return nonzero if IDENTIFIER with arguments ARGS is a valid machine - specific attribute for TYPE. The attributes in ATTRIBUTES have - previously been assigned to TYPE. */ - -static int -c4x_valid_type_attribute_p (type, attributes, identifier, args) - tree type; - tree attributes ATTRIBUTE_UNUSED; - tree identifier; +/* Handle an attribute requiring a FUNCTION_TYPE; + arguments as in struct attribute_spec.handler. */ +static tree +c4x_handle_fntype_attribute (node, name, args, flags, no_add_attrs) + tree *node; + tree name; tree args ATTRIBUTE_UNUSED; + int flags ATTRIBUTE_UNUSED; + bool *no_add_attrs; { - if (TREE_CODE (type) != FUNCTION_TYPE) - return 0; - - if (is_attribute_p ("interrupt", identifier)) - return 1; - - if (is_attribute_p ("assembler", identifier)) - return 1; - - if (is_attribute_p ("leaf_pretend", identifier)) - return 1; - - return 0; + if (TREE_CODE (*node) != FUNCTION_TYPE) + { + warning ("`%s' attribute only applies to functions", + IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + + return NULL_TREE; } |