Commit 9f62c3e3 by Paul Brook Committed by Julian Brown

target-def.h (TARGET_CXX_USE_AEABI_ATEXIT): Define.

	* 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.

From-SVN: r98732
parent 934790cc
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> 2005-04-25 Ian Lance Taylor <ian@airs.com>
* c-common.def (EXPR_STMT): Remove, moved to C++ frontend. * c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
......
...@@ -174,6 +174,7 @@ static bool arm_cxx_cdtor_returns_this (void); ...@@ -174,6 +174,7 @@ static bool arm_cxx_cdtor_returns_this (void);
static bool arm_cxx_key_method_may_be_inline (void); static bool arm_cxx_key_method_may_be_inline (void);
static void arm_cxx_determine_class_data_visibility (tree); static void arm_cxx_determine_class_data_visibility (tree);
static bool arm_cxx_class_data_always_comdat (void); static bool arm_cxx_class_data_always_comdat (void);
static bool arm_cxx_use_aeabi_atexit (void);
static void arm_init_libfuncs (void); static void arm_init_libfuncs (void);
static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode); static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
...@@ -308,6 +309,9 @@ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode); ...@@ -308,6 +309,9 @@ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
#undef TARGET_CXX_KEY_METHOD_MAY_BE_INLINE #undef TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
#define TARGET_CXX_KEY_METHOD_MAY_BE_INLINE arm_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 #undef TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
#define TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY \ #define TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY \
arm_cxx_determine_class_data_visibility arm_cxx_determine_class_data_visibility
...@@ -14354,6 +14358,17 @@ arm_cxx_class_data_always_comdat (void) ...@@ -14354,6 +14358,17 @@ arm_cxx_class_data_always_comdat (void)
return !TARGET_AAPCS_BASED; 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 void
arm_set_return_address (rtx source, rtx scratch) arm_set_return_address (rtx source, rtx scratch)
{ {
......
...@@ -4998,6 +4998,7 @@ get_atexit_node (void) ...@@ -4998,6 +4998,7 @@ get_atexit_node (void)
tree fn_type; tree fn_type;
tree fn_ptr_type; tree fn_ptr_type;
const char *name; const char *name;
bool use_aeabi_atexit;
if (atexit_node) if (atexit_node)
return atexit_node; return atexit_node;
...@@ -5011,6 +5012,7 @@ get_atexit_node (void) ...@@ -5011,6 +5012,7 @@ get_atexit_node (void)
We build up the argument types and then then function type We build up the argument types and then then function type
itself. */ itself. */
use_aeabi_atexit = targetm.cxx.use_aeabi_atexit ();
/* First, build the pointer-to-function type for the first /* First, build the pointer-to-function type for the first
argument. */ argument. */
arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node); arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
...@@ -5018,12 +5020,23 @@ get_atexit_node (void) ...@@ -5018,12 +5020,23 @@ get_atexit_node (void)
fn_ptr_type = build_pointer_type (fn_type); fn_ptr_type = build_pointer_type (fn_type);
/* Then, build the rest of the argument types. */ /* 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, void_list_node);
arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types); if (use_aeabi_atexit)
arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types); {
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. */ /* And the final __cxa_atexit type. */
fn_type = build_function_type (integer_type_node, arg_types); fn_type = build_function_type (integer_type_node, arg_types);
fn_ptr_type = build_pointer_type (fn_type); fn_ptr_type = build_pointer_type (fn_type);
name = "__cxa_atexit"; if (use_aeabi_atexit)
name = "__aeabi_atexit";
else
name = "__cxa_atexit";
} }
else else
{ {
...@@ -5184,8 +5197,16 @@ register_dtor_fn (tree decl) ...@@ -5184,8 +5197,16 @@ register_dtor_fn (tree decl)
args = tree_cons (NULL_TREE, args = tree_cons (NULL_TREE,
build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0), build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0),
NULL_TREE); NULL_TREE);
args = tree_cons (NULL_TREE, null_pointer_node, args); if (targetm.cxx.use_aeabi_atexit ())
args = tree_cons (NULL_TREE, cleanup, args); {
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 else
args = tree_cons (NULL_TREE, cleanup, NULL_TREE); args = tree_cons (NULL_TREE, cleanup, NULL_TREE);
......
...@@ -8735,6 +8735,12 @@ classes whose virtual table will be emitted in only one translation ...@@ -8735,6 +8735,12 @@ classes whose virtual table will be emitted in only one translation
unit will not be COMDAT. unit will not be COMDAT.
@end deftypefn @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 @node Misc
@section Miscellaneous Parameters @section Miscellaneous Parameters
@cindex parameters, miscellaneous @cindex parameters, miscellaneous
......
...@@ -477,6 +477,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -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 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_true
#endif #endif
#ifndef TARGET_CXX_USE_AEABI_ATEXIT
#define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
#endif
#define TARGET_CXX \ #define TARGET_CXX \
{ \ { \
TARGET_CXX_GUARD_TYPE, \ TARGET_CXX_GUARD_TYPE, \
...@@ -488,6 +492,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -488,6 +492,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \ TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \
TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY, \ TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY, \
TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT, \ TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT, \
TARGET_CXX_USE_AEABI_ATEXIT \
} }
/* The whole shebang. */ /* The whole shebang. */
......
...@@ -603,6 +603,9 @@ struct gcc_target ...@@ -603,6 +603,9 @@ struct gcc_target
class data for classes whose virtual table will be emitted in class data for classes whose virtual table will be emitted in
only one translation unit will not be COMDAT. */ only one translation unit will not be COMDAT. */
bool (*class_data_always_comdat) (void); bool (*class_data_always_comdat) (void);
/* Returns true if __aeabi_atexit should be used to register static
destructors. */
bool (*use_aeabi_atexit) (void);
} cxx; } cxx;
/* Leave the boolean fields at the end. */ /* Leave the boolean fields at the end. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment