diff options
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 3 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 8 | ||||
-rw-r--r-- | gcc/stor-layout.c | 21 | ||||
-rw-r--r-- | gcc/target-def.h | 2 | ||||
-rw-r--r-- | gcc/target.h | 4 | ||||
-rw-r--r-- | gcc/targhooks.c | 14 | ||||
-rw-r--r-- | gcc/targhooks.h | 2 |
8 files changed, 57 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1dbe439..7ab85ea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +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 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 2e5c9c4..e6b97df 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -312,6 +312,9 @@ static bool arm_tls_symbol_p (rtx x); #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 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 708a5af..b1dae11 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -1221,6 +1221,14 @@ structure. The hook should return true if the structure should inherit 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}. diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index caf176f..5617d27 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2148,13 +2148,17 @@ fixup_unsigned_type (tree type) 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, @@ -2184,7 +2188,8 @@ 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; diff --git a/gcc/target-def.h b/gcc/target-def.h index 690d0a5..7500151 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -412,6 +412,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #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 @@ -609,6 +610,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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, \ diff --git a/gcc/target.h b/gcc/target.h index 1b768e4..e9a5eca 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -418,6 +418,10 @@ struct gcc_target /* 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); diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 45942a2..f33704b 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -572,4 +572,18 @@ default_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED, 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" diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 05d1add..7c99b08 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -54,6 +54,8 @@ extern bool default_decimal_float_supported_p (void); 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. */ |