target-def.h (TARGET_CXX_GUARD_TYPE, [...]): Define.

gcc/
	* target-def.h (TARGET_CXX_GUARD_TYPE, TARGET_CXX_GUARD_MASK_BIT,
	TARGET_CXX): Define.
	(TARGET_INITIALIZER): Use TARGET_CXX.
	* target.h (struct gcc_target): Add struct cxx.
	* targhooks.h (default_cxx_guard_type): Add prototype.
	* targhooks.c (default_cxx_guard_type): New function.
	* config/arm/arm.c (TARGET_CXX_GUARD_TYPE, TARGET_CXX_GUARD_MASK_BIT):
	Define.
	(arm_cxx_guard_type, arm_cxx_guard_mask_bit): New functions.
	* doc/tm.texi: Document TARGET_CXX_GUARD_TYPE and
	TARGET_CXX_GUARD_MASK_BIT.
gcc/cp/
	* decl2.c (get_guard): Call targetm.cxx.guard_type.
	(get_guard_bits, get_guard_cond): Call targetm.cxx.guard_mask_bit.
libstdc++/
	* libsupc++/cxxabi.h: Define __ARM_EABI__
	(__guard): Use it.
	* libsupc++/guard.h (__cxa_guard_acquire, __cxa_guard_release): Ditto.

From-SVN: r83660
This commit is contained in:
Paul Brook 2004-06-25 17:15:46 +00:00 committed by Paul Brook
parent 0da2c8ac77
commit 4185ae5397
12 changed files with 142 additions and 10 deletions

View File

@ -1,3 +1,17 @@
2004-06-25 Paul Brook <paul@codesourcery.com>
* target-def.h (TARGET_CXX_GUARD_TYPE, TARGET_CXX_GUARD_MASK_BIT,
TARGET_CXX): Define.
(TARGET_INITIALIZER): Use TARGET_CXX.
* target.h (struct gcc_target): Add struct cxx.
* targhooks.h (default_cxx_guard_type): Add prototype.
* targhooks.c (default_cxx_guard_type): New function.
* config/arm/arm.c (TARGET_CXX_GUARD_TYPE, TARGET_CXX_GUARD_MASK_BIT):
Define.
(arm_cxx_guard_type, arm_cxx_guard_mask_bit): New functions.
* doc/tm.texi: Document TARGET_CXX_GUARD_TYPE and
TARGET_CXX_GUARD_MASK_BIT.
2004-06-25 Devang Patel <dpatel@apple.com>
* config/rs6000/darwin.h (CC1_SPEC): Handle -gused and -gfull.

View File

@ -162,6 +162,9 @@ static bool arm_promote_prototypes (tree);
static bool arm_default_short_enums (void);
static bool arm_align_anon_bitfield (void);
static tree arm_cxx_guard_type (void);
static bool arm_cxx_guard_mask_bit (void);
/* Initialize the GCC target structure. */
#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
@ -264,6 +267,12 @@ static bool arm_align_anon_bitfield (void);
#undef TARGET_ALIGN_ANON_BITFIELD
#define TARGET_ALIGN_ANON_BITFIELD arm_align_anon_bitfield
#undef TARGET_CXX_GUARD_TYPE
#define TARGET_CXX_GUARD_TYPE arm_cxx_guard_type
#undef TARGET_CXX_GUARD_MASK_BIT
#define TARGET_CXX_GUARD_MASK_BIT arm_cxx_guard_mask_bit
struct gcc_target targetm = TARGET_INITIALIZER;
/* Obstack for minipool constant handling. */
@ -14537,3 +14546,21 @@ arm_align_anon_bitfield (void)
{
return TARGET_AAPCS_BASED;
}
/* The generic C++ ABI says 64-bit (long long). The EABI says 32-bit. */
static tree
arm_cxx_guard_type (void)
{
return TARGET_AAPCS_BASED ? integer_type_node : long_long_integer_type_node;
}
/* The EABI says test the least significan bit of a guard variable. */
static bool
arm_cxx_guard_mask_bit (void)
{
return TARGET_AAPCS_BASED;
}

View File

@ -1,3 +1,8 @@
2004-06-25 Paul Brook <paul@codesourcery.com>
* decl2.c (get_guard): Call targetm.cxx.guard_type.
(get_guard_bits, get_guard_cond): Call targetm.cxx.guard_mask_bit.
2004-06-24 Mark Mitchell <mark@codesourcery.com>
* decl.c (grokdeclarator): Restore error messages about __thread.

View File

@ -1823,7 +1823,7 @@ get_guard (tree decl)
/* We use a type that is big enough to contain a mutex as well
as an integer counter. */
guard_type = long_long_integer_type_node;
guard_type = targetm.cxx.guard_type ();
guard = build_decl (VAR_DECL, sname, guard_type);
/* The guard should have the same linkage as what it guards. */
@ -1847,15 +1847,18 @@ get_guard (tree decl)
static tree
get_guard_bits (tree guard)
{
/* We only set the first byte of the guard, in order to leave room
for a mutex in the high-order bits. */
guard = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE (guard)),
guard);
guard = build1 (NOP_EXPR,
build_pointer_type (char_type_node),
guard);
guard = build1 (INDIRECT_REF, char_type_node, guard);
if (!targetm.cxx.guard_mask_bit ())
{
/* We only set the first byte of the guard, in order to leave room
for a mutex in the high-order bits. */
guard = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE (guard)),
guard);
guard = build1 (NOP_EXPR,
build_pointer_type (char_type_node),
guard);
guard = build1 (INDIRECT_REF, char_type_node, guard);
}
return guard;
}
@ -1870,6 +1873,16 @@ get_guard_cond (tree guard)
/* Check to see if the GUARD is zero. */
guard = get_guard_bits (guard);
/* Mask off all but the low bit. */
if (targetm.cxx.guard_mask_bit ())
{
guard_value = integer_one_node;
if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard)))
guard_value = convert (TREE_TYPE (guard), guard_value);
guard = cp_build_binary_op (BIT_AND_EXPR, guard, guard_value);
}
guard_value = integer_zero_node;
if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard)))
guard_value = convert (TREE_TYPE (guard), guard_value);

View File

@ -51,6 +51,7 @@ through the macros defined in the @file{.h} file.
* Target Attributes:: Defining target-specific uses of @code{__attribute__}.
* MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
* PCH Target:: Validity checking for precompiled headers.
* C++ ABI:: Controlling C++ ABI changes.
* Misc:: Everything else.
@end menu
@ -8460,6 +8461,22 @@ if not. The error message will be presented to the user, so it should
be localized.
@end deftypefn
@node C++ ABI
@section C++ ABI parameters
@cindex parameters, c++ abi
@deftypefn {Target Hook} tree TARGET_CXX_GUARD_TYPE (void)
Define this hook to override the integer type used for guard variables.
These are used to implement one-time construction of static objects. The
default is long_long_integer_type_node.
@end deftypefn
@deftypefn {Target Hook} bool TARGET_CXX_GUARD_MASK_BIT (void)
This hook determines how guard variables are used. It should return
@code{false} (the default) if first byte should be used. A return value of
@code{true} indicates the least significant bit should be used.
@end deftypefn
@node Misc
@section Miscellaneous Parameters
@cindex parameters, miscellaneous

View File

@ -390,6 +390,22 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_HANDLE_PRAGMA_EXTERN_PREFIX 0
#endif
/* C++ specific. */
#ifndef TARGET_CXX_GUARD_TYPE
#define TARGET_CXX_GUARD_TYPE default_cxx_guard_type
#endif
#ifndef TARGET_CXX_GUARD_MASK_BIT
#define TARGET_CXX_GUARD_MASK_BIT hook_bool_void_false
#endif
#define TARGET_CXX \
{ \
TARGET_CXX_GUARD_TYPE, \
TARGET_CXX_GUARD_MASK_BIT \
}
/* The whole shebang. */
#define TARGET_INITIALIZER \
{ \
@ -435,6 +451,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_BUILTIN_SETJMP_FRAME_VALUE, \
TARGET_MD_ASM_CLOBBERS, \
TARGET_CALLS, \
TARGET_CXX, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_CTORS_DTORS, \
TARGET_HAVE_TLS, \

View File

@ -476,6 +476,14 @@ struct gcc_target
tree *post_p);
} calls;
/* Functions specific to the C++ frontend. */
struct cxx {
/* Return the integer type used for guard variables. */
tree (*guard_type) (void);
/* Return true if only the low bit of the guard should be tested. */
bool (*guard_mask_bit) (void);
} cxx;
/* Leave the boolean fields at the end. */
/* True if arbitrary sections are supported. */

View File

@ -135,3 +135,11 @@ hook_bool_CUMULATIVE_ARGS_true (CUMULATIVE_ARGS * a ATTRIBUTE_UNUSED)
{
return true;
}
/* The generic C++ ABI specifies this is a 64-bit value. */
tree
default_cxx_guard_type (void)
{
return long_long_integer_type_node;
}

View File

@ -32,3 +32,4 @@ extern bool hook_bool_CUMULATIVE_ARGS_false (CUMULATIVE_ARGS *);
extern bool default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *);
extern bool hook_bool_CUMULATIVE_ARGS_true (CUMULATIVE_ARGS *);
extern tree default_cxx_guard_type (void);

View File

@ -1,3 +1,9 @@
2004-06-25 Paul Brook <paul@codesourcery.com>
* libsupc++/cxxabi.h: Define __ARM_EABI__
(__guard): Use it.
* libsupc++/guard.h (__cxa_guard_acquire, __cxa_guard_release): Ditto.
2004-06-25 Paul Brook <paul@codesourcery.com>
* include/bits/concurrence.h: Still create mutex object when

View File

@ -104,8 +104,13 @@ namespace __cxxabiv1
size_t __padding_size, void (*__destructor) (void*),
void (*__dealloc) (void*, size_t));
#ifdef __ARM_EABI__
// The ARM EABI says this is a 32-bit type.
typedef int __guard;
#else
// The ABI requires a 64-bit type.
__extension__ typedef int __guard __attribute__((mode (__DI__)));
#endif
int
__cxa_guard_acquire(__guard*);

View File

@ -30,18 +30,29 @@
#include <cxxabi.h>
// The IA64/generic ABI uses the fist byte of the guard variable.
// The ARM EABI uses the least significant bit.
namespace __cxxabiv1
{
extern "C"
int __cxa_guard_acquire (__guard *g)
{
#ifdef __ARM_EABI__
return !(*g & 1);
#else
return !*(char *)(g);
#endif
}
extern "C"
void __cxa_guard_release (__guard *g)
{
#ifdef __ARM_EABI__
*g = 1;
#else
*(char *)g = 1;
#endif
}
extern "C"