+2004-05-14 Paul Brook <paul@codesourcery.com>
+
+ * stor-layout.c (update_alignment_for_field): Use
+ targetm.align_anon_bitfield.
+ * target-def.h (TARGET_ALIGN_ANON_BITFIELD): Define.
+ (TARGET_INITIALIZER): Use it.
+ * target.h (struct gcc_target): Add align_anon_bitfield.
+ * config/arm/arm.c (arm_align_anon_bitfield): New function.
+ (TARGET_ALIGN_ANON_BITFIELD): Define.
+ * doc/tm.texi: Document TARGET_ALIGN_ANON_BITFIELD.
+
2004-05-13 Zack Weinberg <zack@codesourcery.com>
* tree.def (documentation): Remove mention of class 'b'.
tree, int *, int);
static bool arm_promote_prototypes (tree);
static bool arm_default_short_enums (void);
+static bool arm_align_anon_bitfield (void);
\f
/* Initialize the GCC target structure. */
#undef TARGET_DEFAULT_SHORT_ENUMS
#define TARGET_DEFAULT_SHORT_ENUMS arm_default_short_enums
+#undef TARGET_ALIGN_ANON_BITFIELD
+#define TARGET_ALIGN_ANON_BITFIELD arm_align_anon_bitfield
+
struct gcc_target targetm = TARGET_INITIALIZER;
\f
/* Obstack for minipool constant handling. */
{
return TARGET_AAPCS_BASED;
}
+
+
+/* AAPCS requires that anonymous bitfields affect structure alignment. */
+
+static bool
+arm_align_anon_bitfield (void)
+{
+ return TARGET_AAPCS_BASED;
+}
to aligning a bit-field within the structure.
@end defmac
+@deftypefn {Target Hook} bool TARGET_ALIGN_ANON_BITFIELDS (void)
+When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
+whether unnamed bitfields affect the alignment of the containing
+structure. The hook should return true if the structure should inherit
+the alignment requirements of an unnamed bitfield's type.
+@end deftypefn
+
@defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
Return 1 if a structure or array containing @var{field} should be accessed using
@code{BLKMODE}.
else if (is_bitfield && PCC_BITFIELD_TYPE_MATTERS)
{
/* Named bit-fields cause the entire structure to have the
- alignment implied by their type. */
- if (DECL_NAME (field) != 0)
+ alignment implied by their type. Some targets also apply the same
+ rules to unnamed bitfields. */
+ if (DECL_NAME (field) != 0
+ || targetm.align_anon_bitfield ())
{
unsigned int type_align = TYPE_ALIGN (type);
#define TARGET_INSERT_ATTRIBUTES hook_void_tree_treeptr
#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P hook_bool_tree_false
#define TARGET_MS_BITFIELD_LAYOUT_P hook_bool_tree_false
+#define TARGET_ALIGN_ANON_BITFIELD hook_bool_void_false
#define TARGET_RTX_COSTS hook_bool_rtx_int_int_intp_false
#define TARGET_MANGLE_FUNDAMENTAL_TYPE hook_constcharptr_tree_null
TARGET_INSERT_ATTRIBUTES, \
TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P, \
TARGET_MS_BITFIELD_LAYOUT_P, \
+ TARGET_ALIGN_ANON_BITFIELD, \
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
TARGET_MANGLE_FUNDAMENTAL_TYPE, \
Microsoft Visual C++ bitfield layout rules. */
bool (* ms_bitfield_layout_p) (tree record_type);
+ /* Return true if anonymous bitfields affect structure alignment. */
+ bool (* align_anon_bitfield) (void);
+
/* Set up target-specific built-in functions. */
void (* init_builtins) (void);