diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 27 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 33 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 17 | ||||
-rw-r--r-- | gcc/target-def.h | 17 | ||||
-rw-r--r-- | gcc/target.h | 8 | ||||
-rw-r--r-- | gcc/targhooks.c | 8 | ||||
-rw-r--r-- | gcc/targhooks.h | 1 |
9 files changed, 120 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29a8805..03c589c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index e1b5be2..a7262f5 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -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; +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0063722..aca2db2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 10384b3..5b23519 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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); diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index b93941e..d01993f 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 diff --git a/gcc/target-def.h b/gcc/target-def.h index c537c9f..72fda5b 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -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, \ diff --git a/gcc/target.h b/gcc/target.h index 902db41..ad7936b 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -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. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 80ac8721..5d2a75f 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -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; +} diff --git a/gcc/targhooks.h b/gcc/targhooks.h index f90d6b3..427334f 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -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); |