ip2k.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
authorDenis Chertykov <denisc@overta.ru>
Tue, 14 Jan 2003 20:25:25 +0000 (20:25 +0000)
committerDenis Chertykov <denisc@gcc.gnu.org>
Tue, 14 Jan 2003 20:25:25 +0000 (23:25 +0300)
* config/ip2k/ip2k.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
(VALID_MACHINE_TYPE_ATTRIBUTE): Remove.

* config/ip2k/ip2k.c (ip2k_attribute_table): New table of
        attributes.
(TARGET_ATTRIBUTE_TABLE): New macro.
(valid_machine_type_attribute): Remove.
(valid_machine_decl_attribute): Remove.
(ip2k_handle_progmem_attribute): New function.
(ip2k_handle_fndecl_attribute): New function.

From-SVN: r61295

gcc/ChangeLog
gcc/config/ip2k/ip2k.c
gcc/config/ip2k/ip2k.h

index 15f5ddb2b0ca1d167da57f774770339fc91e069f..e339622de9f6c7f860db68274422ece0435bbd97 100644 (file)
@@ -1,3 +1,16 @@
+2003-01-14  Denis Chertykov  <denisc@overta.ru>
+
+       * config/ip2k/ip2k.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
+       (VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
+
+       * config/ip2k/ip2k.c (ip2k_attribute_table): New table of
+        attributes.
+       (TARGET_ATTRIBUTE_TABLE): New macro.
+       (valid_machine_type_attribute): Remove.
+       (valid_machine_decl_attribute): Remove.
+       (ip2k_handle_progmem_attribute): New function.
+       (ip2k_handle_fndecl_attribute): New function.
+
 2003-01-10  Andrew Haley  <aph@redhat.com>
 
        * config/i386/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Rename
index 93d2ab27f5c05aadae11c10fc6dbacdd91d4dc47..6b2bc33729cf6d7c119c3bef55da6df7e7b72096 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used for code generation on Ubicom IP2022
    Communications Controller.
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc and Ubicom, Inc.
 
    This file is part of GNU CC.
@@ -74,6 +74,11 @@ static void mdr_try_wreg_elim PARAMS ((rtx));
 static int ip2k_check_can_adjust_stack_ref PARAMS ((rtx, int));
 static void ip2k_adjust_stack_ref PARAMS ((rtx *, int));
 static int ip2k_xexp_not_uses_reg_for_mem PARAMS ((rtx, unsigned int));
+static tree ip2k_handle_progmem_attribute PARAMS ((tree *, tree, tree, int,
+                                                  bool *));
+static tree ip2k_handle_fndecl_attribute PARAMS ((tree *, tree, tree, int,
+                                                 bool *));
+const struct attribute_spec ip2k_attribute_table[];
 
 
 /* Initialize the GCC target structure.  */
@@ -92,6 +97,9 @@ static int ip2k_xexp_not_uses_reg_for_mem PARAMS ((rtx, unsigned int));
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO encode_section_info
 
+#undef TARGET_ATTRIBUTE_TABLE
+#define TARGET_ATTRIBUTE_TABLE ip2k_attribute_table
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Commands in the functions prologues in the compiled file.  */
@@ -3145,51 +3153,82 @@ class_likely_spilled_p(c)
          || c == PTR_REGS);
 }
 
-/* Only `progmem' attribute valid for type.  */
+/* Valid attributes:
+   progmem - put data to program memory;
+   naked     - don't generate function prologue/epilogue and `ret' command.
 
-int
-valid_machine_type_attribute(type, attributes, identifier, args)
-     tree type ATTRIBUTE_UNUSED;
-     tree attributes ATTRIBUTE_UNUSED;
-     tree identifier;
-     tree args ATTRIBUTE_UNUSED;
-{
-  return is_attribute_p ("progmem", identifier);
-}
+   Only `progmem' attribute valid for type.  */
 
-/* If IDENTIFIER with arguments ARGS is a valid machine specific
-   attribute for DECL return 1.
-   Valid attributes:
-   progmem - put data to program memory;
-   naked   - don't generate function prologue/epilogue and `ret' command.  */
+const struct attribute_spec ip2k_attribute_table[] =
+{
+  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
+  { "progmem",   0, 0, false, false, false,  ip2k_handle_progmem_attribute },
+  { "naked",     0, 0, true,  false, false,  ip2k_handle_fndecl_attribute },
+  { NULL,        0, 0, false, false, false, NULL }
+};
 
-int
-valid_machine_decl_attribute (decl, attributes, attr, args)
-     tree decl;
-     tree attributes ATTRIBUTE_UNUSED;
-     tree attr;
+/* Handle a "progmem" attribute; arguments as in
+   struct attribute_spec.handler.  */
+static tree
+ip2k_handle_progmem_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 (is_attribute_p ("naked", attr))
-    return TREE_CODE (decl) == FUNCTION_DECL;
-
-  if (is_attribute_p ("progmem", attr)
-      && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
+  if (DECL_P (*node))
     {
-      /* Data stored in program RAM or FLASH must be word aligned or
-         it won't be directly addressable.  */
-      if (DECL_ALIGN (decl) < FUNCTION_BOUNDARY)
-       DECL_ALIGN (decl) = FUNCTION_BOUNDARY;
+      if (TREE_CODE (*node) == TYPE_DECL)
+       {
+         /* This is really a decl attribute, not a type attribute,
+            but try to handle it for GCC 3.0 backwards compatibility.  */
+
+         tree type = TREE_TYPE (*node);
+         tree attr = tree_cons (name, args, TYPE_ATTRIBUTES (type));
+         tree newtype = build_type_attribute_variant (type, attr);
 
-      if (DECL_INITIAL (decl) == NULL_TREE)
+         TYPE_MAIN_VARIANT (newtype) = TYPE_MAIN_VARIANT (type);
+         TREE_TYPE (*node) = newtype;
+         *no_add_attrs = true;
+       }
+      else if (TREE_STATIC (*node) || DECL_EXTERNAL (*node))
        {
-         warning ("Only initialized variables can be placed into "
-                  "program memory area.");
-         return 0;
+         if (DECL_INITIAL (*node) == NULL_TREE && !DECL_EXTERNAL (*node))
+           {
+             warning ("only initialized variables can be placed into "
+                      "program memory area");
+             *no_add_attrs = true;
+           }
+       }
+      else
+       {
+         warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
+         *no_add_attrs = true;
        }
-      return 1;
     }
-  return 0;
+
+  return NULL_TREE;
+}
+
+/* Handle an attribute requiring a FUNCTION_DECL; arguments as in
+   struct attribute_spec.handler.  */
+static tree
+ip2k_handle_fndecl_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 (*node) != FUNCTION_DECL)
+    {
+      warning ("`%s' attribute only applies to functions",
+              IDENTIFIER_POINTER (name));
+      *no_add_attrs = true;
+    }
+
+  return NULL_TREE;
 }
 
 /* Encode section information about tree DECL.  */
index 6957021ba4f67a4b9743b69fb8353423299d4638..a5b14c52025d3acbbf7ff8344fb6cdf3c04f84a7 100644 (file)
@@ -1,7 +1,7 @@
 /* Definitions of target machine for GNU compiler,
    For Ubicom IP2022 Communications Controller
 
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc and Ubicom, Inc.
 
 This file is part of GNU CC.
@@ -2327,18 +2327,6 @@ do {                                                     \
    of arguments that the function accepts.  Some people think a larger
    threshold should be used on RISC machines.  */
 
-#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
-  valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
-/* If defined, a C expression whose value is nonzero if IDENTIFIER
-   with arguments ARGS is a valid machine specific attribute for DECL.
-   The attributes in ATTRIBUTES have previously been assigned to DECL.  */
-
-#define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, IDENTIFIER, ARGS) \
-  valid_machine_type_attribute(TYPE, ATTRIBUTES, IDENTIFIER, ARGS)
-/* If defined, a C expression whose value is nonzero if IDENTIFIER
-   with arguments ARGS is a valid machine specific attribute for TYPE.
-   The attributes in ATTRIBUTES have previously been assigned to TYPE.  */
-
 #define DOLLARS_IN_IDENTIFIERS 0
 /* Define this macro to control use of the character `$' in identifier
    names.  0 means `$' is not allowed by default; 1 means it is