OSDN Git Service

* target-def.h (TARGET_CXX_USE_AEABI_ATEXIT): Define.
authorjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Apr 2005 19:35:18 +0000 (19:35 +0000)
committerjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Apr 2005 19:35:18 +0000 (19:35 +0000)
* target.h (struct gcc_target): Add cxx.use_aeabi_atexit.
* config/arm/arm.c (arm_cxx_atexit_name): New function.
(TARGET_CXX_USE_AEABI_ATEXIT): New macro.
* cp/decl.c (get_atexit_node): Reorder arguments for __aeabi_atexit.
(register_dtor_fn): Likewise.
* doc/tm.texi: Document TARGET_CXX_USE_AEABI_ATEXIT.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98732 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/cp/decl.c
gcc/doc/tm.texi
gcc/target-def.h
gcc/target.h

index d99ba07..fea482b 100644 (file)
@@ -1,3 +1,13 @@
+2005-04-05  Paul Brook  <julian@codesourcery.com>
+
+       * target-def.h (TARGET_CXX_USE_AEABI_ATEXIT): Define.
+       * target.h (struct gcc_target): Add cxx.use_aeabi_atexit.
+       * config/arm/arm.c (arm_cxx_atexit_name): New function.
+       (TARGET_CXX_USE_AEABI_ATEXIT): New macro.
+       * cp/decl.c (get_atexit_node): Reorder arguments for __aeabi_atexit.
+       (register_dtor_fn): Likewise.
+       * doc/tm.texi: Document TARGET_CXX_USE_AEABI_ATEXIT.
+
 2005-04-25  Ian Lance Taylor  <ian@airs.com>
 
        * c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
index 7349b1e..8189909 100644 (file)
@@ -174,6 +174,7 @@ static bool arm_cxx_cdtor_returns_this (void);
 static bool arm_cxx_key_method_may_be_inline (void);
 static void arm_cxx_determine_class_data_visibility (tree);
 static bool arm_cxx_class_data_always_comdat (void);
+static bool arm_cxx_use_aeabi_atexit (void);
 static void arm_init_libfuncs (void);
 static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
 \f
@@ -308,6 +309,9 @@ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
 #undef TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
 #define TARGET_CXX_KEY_METHOD_MAY_BE_INLINE arm_cxx_key_method_may_be_inline
 
+#undef TARGET_CXX_USE_AEABI_ATEXIT
+#define TARGET_CXX_USE_AEABI_ATEXIT arm_cxx_use_aeabi_atexit
+
 #undef TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
 #define TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY \
   arm_cxx_determine_class_data_visibility
@@ -14354,6 +14358,17 @@ arm_cxx_class_data_always_comdat (void)
   return !TARGET_AAPCS_BASED;
 }
 
+
+/* The EABI says __aeabi_atexit should be used to register static
+   destructors.  */
+
+static bool
+arm_cxx_use_aeabi_atexit (void)
+{
+  return TARGET_AAPCS_BASED;
+}
+
+
 void
 arm_set_return_address (rtx source, rtx scratch)
 {
index 60b478e..91f57ef 100644 (file)
@@ -4998,6 +4998,7 @@ get_atexit_node (void)
   tree fn_type;
   tree fn_ptr_type;
   const char *name;
+  bool use_aeabi_atexit;
 
   if (atexit_node)
     return atexit_node;
@@ -5011,6 +5012,7 @@ get_atexit_node (void)
         We build up the argument types and then then function type
         itself.  */
 
+      use_aeabi_atexit = targetm.cxx.use_aeabi_atexit ();
       /* First, build the pointer-to-function type for the first
         argument.  */
       arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
@@ -5018,12 +5020,23 @@ get_atexit_node (void)
       fn_ptr_type = build_pointer_type (fn_type);
       /* Then, build the rest of the argument types.  */
       arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
-      arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
-      arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+      if (use_aeabi_atexit)
+       {
+         arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+         arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
+       }
+      else
+       {
+         arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
+         arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+       }
       /* And the final __cxa_atexit type.  */
       fn_type = build_function_type (integer_type_node, arg_types);
       fn_ptr_type = build_pointer_type (fn_type);
-      name = "__cxa_atexit";
+      if (use_aeabi_atexit)
+       name = "__aeabi_atexit";
+      else
+       name = "__cxa_atexit";
     }
   else
     {
@@ -5184,8 +5197,16 @@ register_dtor_fn (tree decl)
       args = tree_cons (NULL_TREE,
                        build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0),
                        NULL_TREE);
-      args = tree_cons (NULL_TREE, null_pointer_node, args);
-      args = tree_cons (NULL_TREE, cleanup, args);
+      if (targetm.cxx.use_aeabi_atexit ())
+       {
+         args = tree_cons (NULL_TREE, cleanup, args);
+         args = tree_cons (NULL_TREE, null_pointer_node, args);
+       }
+      else
+       {
+         args = tree_cons (NULL_TREE, null_pointer_node, args);
+         args = tree_cons (NULL_TREE, cleanup, args);
+       }
     }
   else
     args = tree_cons (NULL_TREE, cleanup, NULL_TREE);
index 42c5b0f..7714616 100644 (file)
@@ -8735,6 +8735,12 @@ classes whose virtual table will be emitted in only one translation
 unit will not be COMDAT.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_CXX_USE_AEABI_ATEXIT (void)
+This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
+should be used to register static destructors when @option{-fuse-cxa-atexit}
+is in effect.  The default is to return false to use @code{__cxa_atexit}.
+@end deftypefn
+
 @node Misc
 @section Miscellaneous Parameters
 @cindex parameters, miscellaneous
index 44e3791..6e8a578 100644 (file)
@@ -477,6 +477,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_true
 #endif
 
+#ifndef TARGET_CXX_USE_AEABI_ATEXIT
+#define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
+#endif
+
 #define TARGET_CXX                             \
   {                                            \
     TARGET_CXX_GUARD_TYPE,                     \
@@ -488,6 +492,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     TARGET_CXX_KEY_METHOD_MAY_BE_INLINE,       \
     TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY,        \
     TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT,        \
+    TARGET_CXX_USE_AEABI_ATEXIT                        \
   }
 
 /* The whole shebang.  */
index 2cb4db2..1786379 100644 (file)
@@ -603,6 +603,9 @@ struct gcc_target
        class data for classes whose virtual table will be emitted in
        only one translation unit will not be COMDAT.  */
     bool (*class_data_always_comdat) (void);
+    /* Returns true if __aeabi_atexit should be used to register static
+       destructors.  */
+    bool (*use_aeabi_atexit) (void);
   } cxx;
 
   /* Leave the boolean fields at the end.  */