+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.
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
#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. */
{
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;
+}
+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.
/* 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. */
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;
}
/* 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);
* 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
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
#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 \
{ \
TARGET_BUILTIN_SETJMP_FRAME_VALUE, \
TARGET_MD_ASM_CLOBBERS, \
TARGET_CALLS, \
+ TARGET_CXX, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_CTORS_DTORS, \
TARGET_HAVE_TLS, \
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. */
{
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;
+}
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);
+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
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*);
#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"