aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2004-05-14 12:53:11 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2004-05-14 12:53:11 +0000
commit13c1cd82670b0be75bf99ba5bd23a7c34460fe65 (patch)
treea01af50a8b0a254e0fc7b796f434623f5557811b
parentce8fc97bdf64cb3abbe042de3d9030b0c22b74dc (diff)
downloadgcc-13c1cd82670b0be75bf99ba5bd23a7c34460fe65.zip
gcc-13c1cd82670b0be75bf99ba5bd23a7c34460fe65.tar.gz
gcc-13c1cd82670b0be75bf99ba5bd23a7c34460fe65.tar.bz2
stor-layout.c (update_alignment_for_field): Use targetm.align_anon_bitfield.
* 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. From-SVN: r81838
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/arm/arm.c13
-rw-r--r--gcc/doc/tm.texi7
-rw-r--r--gcc/stor-layout.c6
-rw-r--r--gcc/target-def.h2
-rw-r--r--gcc/target.h3
6 files changed, 40 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 66e9db2..968a23f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+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'.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 7cf835c..acbdb77 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -160,6 +160,7 @@ static void arm_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
tree, int *, int);
static bool arm_promote_prototypes (tree);
static bool arm_default_short_enums (void);
+static bool arm_align_anon_bitfield (void);
/* Initialize the GCC target structure. */
@@ -260,6 +261,9 @@ static bool arm_default_short_enums (void);
#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;
/* Obstack for minipool constant handling. */
@@ -14565,3 +14569,12 @@ arm_default_short_enums (void)
{
return TARGET_AAPCS_BASED;
}
+
+
+/* AAPCS requires that anonymous bitfields affect structure alignment. */
+
+static bool
+arm_align_anon_bitfield (void)
+{
+ return TARGET_AAPCS_BASED;
+}
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 339dc7a..a0f855d 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1301,6 +1301,13 @@ Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
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}.
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 13f95a4..5c87a63 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -771,8 +771,10 @@ update_alignment_for_field (record_layout_info rli, tree field,
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);
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 62060ab..f8c832a 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -310,6 +310,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#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
@@ -384,6 +385,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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, \
diff --git a/gcc/target.h b/gcc/target.h
index c122adb..6e28810 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -307,6 +307,9 @@ struct gcc_target
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);