This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH to add target hook to attribute_takes_identifier_p (testsuite/43758)


The rs6000 altivec attribute expects a plain identifier as its argument (vector__, etc), so we need a hook to express that.

Tested x86_64-pc-linux-gnu, approved by meissner, committed to trunk.
commit 47b19b941e0899b3ec4df9868184297c43ed25c2
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed May 5 19:33:11 2010 +0000

    	PR testsuite/43758
    	* target.h (struct gcc_target): Add attribute_takes_identifier_p.
    	* target_def.h (TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P): Define.
    	(TARGET_INITIALIZER): Use it.
    	* c-common.c (attribute_takes_identifier_p): Call it.
    	* c-common.h: Update prototype.
    	* config/rs6000/rs6000.c (rs6000_attribute_takes_identifier_p): New.
    	(TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P): Define.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159079 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/c-common.c b/gcc/c-common.c
index 1718344..6fa577c 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5816,11 +5816,14 @@ c_init_attributes (void)
    identifier as an argument, so the front end shouldn't look it up.  */
 
 bool
-attribute_takes_identifier_p (tree attr_id)
+attribute_takes_identifier_p (const_tree attr_id)
 {
-  return (is_attribute_p ("mode", attr_id)
-	  || is_attribute_p ("format", attr_id)
-	  || is_attribute_p ("cleanup", attr_id));
+  if (is_attribute_p ("mode", attr_id)
+      || is_attribute_p ("format", attr_id)
+      || is_attribute_p ("cleanup", attr_id))
+    return true;
+  else
+    return targetm.attribute_takes_identifier_p (attr_id);
 }
 
 /* Attribute handlers common to C front ends.  */
diff --git a/gcc/c-common.h b/gcc/c-common.h
index e79a392..7f47c2e 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -826,7 +826,7 @@ extern void check_function_format (tree, int, tree *);
 extern void set_Wformat (int);
 extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
-extern bool attribute_takes_identifier_p (tree);
+extern bool attribute_takes_identifier_p (const_tree);
 extern int c_common_handle_option (size_t code, const char *arg, int value);
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1360bf4..d1616e5 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -897,6 +897,7 @@ static bool no_global_regs_above (int, bool);
 static void rs6000_assemble_visibility (tree, int);
 #endif
 static int rs6000_ra_ever_killed (void);
+static bool rs6000_attribute_takes_identifier_p (const_tree);
 static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
 static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
 static bool rs6000_ms_bitfield_layout_p (const_tree);
@@ -1279,6 +1280,8 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table
 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes
+#undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
+#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p
 
 #undef TARGET_ASM_ALIGNED_DI_OP
 #define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP
@@ -23320,6 +23323,15 @@ rs6000_trampoline_init (rtx m_tramp, tree fndecl, rtx cxt)
 }
 
 
+/* Returns TRUE iff the target attribute indicated by ATTR_ID takes a plain
+   identifier as an argument, so the front end shouldn't look it up.  */
+
+static bool
+rs6000_attribute_takes_identifier_p (const_tree attr_id)
+{
+  return is_attribute_p ("altivec", attr_id);
+}
+
 /* Handle the "altivec" attribute.  The attribute may have
    arguments as follows:
 
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 3a36314..7eb49d6 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -9525,6 +9525,14 @@ entities to which these attributes are applied and the arguments they
 take.
 @end deftypevr
 
+@deftypefn {Target Hook} bool TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P (const_tree @var{name})
+If defined, this target hook is a function which returns true if the
+machine-specific attribute named @var{name} expects an identifier
+given as its first argument to be passed on as a plain identifier, not
+subjected to name lookup.  If this is not defined, the default is
+false for all machine-specific attributes.
+@end deftypefn
+
 @deftypefn {Target Hook} int TARGET_COMP_TYPE_ATTRIBUTES (const_tree @var{type1}, const_tree @var{type2})
 If defined, this target hook is a function which returns zero if the attributes on
 @var{type1} and @var{type2} are incompatible, one if they are compatible,
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 1c73436..1f60e52 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -561,6 +561,7 @@
 #define TARGET_MAX_ANCHOR_OFFSET 0
 #define TARGET_USE_ANCHORS_FOR_SYMBOL_P default_use_anchors_for_symbol_p
 #define TARGET_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_false
+#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P hook_bool_const_tree_false
 #define TARGET_COMP_TYPE_ATTRIBUTES hook_int_const_tree_const_tree_1
 #ifndef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES hook_void_tree
@@ -932,6 +933,7 @@
   TARGET_MERGE_DECL_ATTRIBUTES,			\
   TARGET_MERGE_TYPE_ATTRIBUTES,			\
   TARGET_ATTRIBUTE_TABLE,			\
+  TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P,		\
   TARGET_COMP_TYPE_ATTRIBUTES,			\
   TARGET_SET_DEFAULT_TYPE_ATTRIBUTES,		\
   TARGET_INSERT_ATTRIBUTES,			\
diff --git a/gcc/target.h b/gcc/target.h
index 6ff7d1d..2f99a4f 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -549,6 +549,10 @@ struct gcc_target
      Ignored if NULL.  */
   const struct attribute_spec *attribute_table;
 
+  /* Return true iff attribute NAME expects a plain identifier as its first
+     argument.  */
+  bool (*attribute_takes_identifier_p) (const_tree name);
+
   /* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
      one if they are compatible and two if they are nearly compatible
      (which causes a warning to be generated).  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]