mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-18 10:00:35 +08:00
re PR middle-end/23623 (volatile keyword changes bitfield access size from 32bit to 8bit)
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. From-SVN: r112493
This commit is contained in:
parent
4dc19cc052
commit
c2a644391b
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}.
|
||||
|
@ -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.
|
||||
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.
|
||||
|
||||
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 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;
|
||||
|
||||
|
@ -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, \
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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. */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user