PR middle-end/23623
* targhooks.c (default_narrow_bitfield): New fuction.
* targhooks.h (default_narrow_bitfield): add prototype.
* target.h (gcc_target): Add narrow_volatile_bitfield.
* target-def.h (TARGET_NARROW_VOLATILE_BITFIELD): Define.
* stor-layout.c (get_best_mode): Use targetm.narrow_volatile_bitfield.
* doc/tm.texi: Document TARGET_NARROW_VOLATILE_BITFIELDS.
* config/arm/arm.c (TARGET_NARROW_VOLATILE_BITFIELD): Define.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112493
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-03-29 Paul Brook <paul@codesourcery.com>
+
+ PR middle-end/23623
+ * targhooks.c (default_narrow_bitfield): New fuction.
+ * targhooks.h (default_narrow_bitfield): add prototype.
+ * target.h (gcc_target): Add narrow_volatile_bitfield.
+ * target-def.h (TARGET_NARROW_VOLATILE_BITFIELD): Define.
+ * stor-layout.c (get_best_mode): Use targetm.narrow_volatile_bitfield.
+ * doc/tm.texi: Document TARGET_NARROW_VOLATILE_BITFIELDS.
+ * config/arm/arm.c (TARGET_NARROW_VOLATILE_BITFIELD): Define.
+
2006-03-29 Andreas Krebbel <krebbel1@de.ibm.com>
* config.gcc (s390-*-linux-*, s390x-*-linux*): Add t-dfprules to
#undef TARGET_ALIGN_ANON_BITFIELD
#define TARGET_ALIGN_ANON_BITFIELD arm_align_anon_bitfield
+#undef TARGET_NARROW_VOLATILE_BITFIELD
+#define TARGET_NARROW_VOLATILE_BITFIELD hook_bool_void_false
+
#undef TARGET_CXX_GUARD_TYPE
#define TARGET_CXX_GUARD_TYPE arm_cxx_guard_type
the alignment requirements of an unnamed bitfield's type.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_NARROW_VOLATILE_BITFIELDS (void)
+This target hook should return @code{true} if accesses to volatile bitfields
+should use the narrowest mode possible. It should return @code{false} if
+these accesses should use the bitfield container type.
+
+The default is @code{!TARGET_STRICT_ALIGN}.
+@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}.
If LARGEST_MODE is not VOIDmode, it means that we should not use a mode
larger than LARGEST_MODE (usually SImode).
- If no mode meets all these conditions, we return VOIDmode. Otherwise, if
- VOLATILEP is true or SLOW_BYTE_ACCESS is false, we return the smallest
- mode meeting these conditions.
-
- Otherwise (VOLATILEP is false and SLOW_BYTE_ACCESS is true), we return
- the largest mode (but a mode no wider than UNITS_PER_WORD) that meets
- all the conditions. */
+ If no mode meets all these conditions, we return VOIDmode.
+
+ If VOLATILEP is false and SLOW_BYTE_ACCESS is false, we return the
+ smallest mode meeting these conditions.
+
+ If VOLATILEP is false and SLOW_BYTE_ACCESS is true, we return the
+ largest mode (but a mode no wider than UNITS_PER_WORD) that meets
+ all the conditions.
+
+ If VOLATILEP is true the narrow_volatile_bitfields target hook is used to
+ decide which of the above modes should be used. */
enum machine_mode
get_best_mode (int bitsize, int bitpos, unsigned int align,
|| (largest_mode != VOIDmode && unit > GET_MODE_BITSIZE (largest_mode)))
return VOIDmode;
- if (SLOW_BYTE_ACCESS && ! volatilep)
+ if ((SLOW_BYTE_ACCESS && ! volatilep)
+ || (volatilep && !targetm.narrow_volatile_bitfield()))
{
enum machine_mode wide_mode = VOIDmode, tmode;
#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_NARROW_VOLATILE_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
#define TARGET_ALLOCATE_INITIAL_VALUE NULL
TARGET_MS_BITFIELD_LAYOUT_P, \
TARGET_DECIMAL_FLOAT_SUPPORTED_P, \
TARGET_ALIGN_ANON_BITFIELD, \
+ TARGET_NARROW_VOLATILE_BITFIELD, \
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
TARGET_EXPAND_LIBRARY_BUILTIN, \
/* Return true if anonymous bitfields affect structure alignment. */
bool (* align_anon_bitfield) (void);
+ /* Return true if volatile bitfields should use the narrowest type possible.
+ Return false if they should use the container type. */
+ bool (* narrow_volatile_bitfield) (void);
+
/* Set up target-specific built-in functions. */
void (* init_builtins) (void);
return class;
}
+
+/* If STRICT_ALIGNMENT is true we use the container type for accessing
+ volatile bitfields. This is generally the preferred behavior for memory
+ mapped peripherals on RISC architectures.
+ If STRICT_ALIGNMENT is false we use the narrowest type possible. This
+ is typically used to avoid spurious page faults and extra memory accesses
+ due to unaligned accesses on CISC architectures. */
+
+bool
+default_narrow_bitfield (void)
+{
+ return !STRICT_ALIGNMENT;
+}
+
#include "gt-targhooks.h"
extern const char * default_invalid_within_doloop (rtx);
+extern bool default_narrow_bitfield (void);
+
/* These are here, and not in hooks.[ch], because not all users of
hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */