]> gcc.gnu.org Git - gcc.git/commitdiff
stor-layout.c (update_alignment_for_field): Use targetm.align_anon_bitfield.
authorPaul Brook <paul@codesourcery.com>
Fri, 14 May 2004 12:53:11 +0000 (12:53 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Fri, 14 May 2004 12:53:11 +0000 (12:53 +0000)
* 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

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/doc/tm.texi
gcc/stor-layout.c
gcc/target-def.h
gcc/target.h

index 66e9db272eda43395eddd9b055acfa98d8e33767..968a23f9336b021a5efd6a56f4d8236324744d5d 100644 (file)
@@ -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'.
index 7cf835ce9188be07a6e5851ad8168e9a060f14df..acbdb77f15b12e950919ac91cfe08821fe707b13 100644 (file)
@@ -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);
 
 \f
 /* 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;
 \f
 /* 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;
+}
index 339dc7ad1c4b216395fb4d4b8cc92372bd03febb..a0f855d904ee6c4fb0ce5659ec039df5e53eae26 100644 (file)
@@ -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}.
index 13f95a44ff5bf1f28ed0426a9ab175a1bf9e190c..5c87a638376e08041f2af7eba9faeefce31fbe3a 100644 (file)
@@ -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);
 
index 62060abebf204b111263e60218fe8dcf382b7e31..f8c832a251e44addea8cda6b7a8c27b485780883 100644 (file)
@@ -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,              \
index c122adbcdfaa82ac8ecb1bdff2d24ec173e97197..6e288104559a4d526d91450e3d85b3b92904a7e4 100644 (file)
@@ -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);
 
This page took 0.115879 seconds and 5 git commands to generate.