]> gcc.gnu.org Git - gcc.git/commitdiff
target-def.h (TARGET_CXX_GUARD_TYPE, [...]): Define.
authorPaul Brook <paul@codesourcery.com>
Fri, 25 Jun 2004 17:15:46 +0000 (17:15 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Fri, 25 Jun 2004 17:15:46 +0000 (17:15 +0000)
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

12 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/doc/tm.texi
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h
libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/cxxabi.h
libstdc++-v3/libsupc++/guard.cc

index 29a8805b96fafc6f6b919d3d00ecdca9df66ddd9..03c589c5df341827c0c457fa88efa142adeafc72 100644 (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.
index e1b5be2e9a295d361cd68fec7cf6922014b74f01..a7262f54dd9c9e761142ce8dae692a0ae8e3110b 100644 (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);
+
 \f
 /* 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;
 \f
 /* 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;
+}
index 0063722b879fb2db35a9c441f918eec5d52c541c..aca2db2ab9debff94e972ca768836fcf764859ae 100644 (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.
index 10384b3b9b61b574b10e619dfce12d56dc3480b5..5b2351975b999c0fcdd1898661b2a0cf5cba0f1f 100644 (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);
index b93941e8771e51247d24061b05bad41699983ad9..d01993f3a680d6153584ccf33de3116a1d0d77b6 100644 (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
index c537c9f70e0f82e052210870db1e4ef3df07f193..72fda5b2ab53724abb84fbfdac1f80a46489f8c5 100644 (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,                             \
index 902db41fd9abff1a2214bb8346449e8e5d856d8d..ad7936bbc2f94f4a97bb3b41af9fb204caef54e3 100644 (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.  */
index 80ac8721d21ed089b857848ae978171394c1dbce..5d2a75fe3154accd369891bdf5e9edf8de5048b9 100644 (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;
+}
index f90d6b3612cfceb76dbc91e77f29526ab4514d69..427334f02c15bce84514ff28d00548a19f283031 100644 (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);
index 82670b82368a9cd9e8a66f891bf0f02f7895be67..b1f5e982cbc93fdf49e16017ef22a777081016fb 100644 (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
index 35535491035b733623a370decd4b5d550f52ce7e..9e8a090b447d0da9884ac19cbc9570237753bee0 100644 (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*);
index b93cffd2e20829ffe95c3082f2682af7c9164f65..fb49f1f081aec4d5409cb74f0474d4369d910931 100644 (file)
 
 #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"
This page took 0.120346 seconds and 5 git commands to generate.