Commit f5c88dbf by Jie Zhang Committed by Jie Zhang

stor-layout.c (layout_decl): Use the field's type to determine the mode and keep…

stor-layout.c (layout_decl): Use the field's type to determine the mode and keep DECL_BIT_FIELD for a...

	* stor-layout.c (layout_decl): Use the field's type to
	determine the mode and keep DECL_BIT_FIELD for a volatile
	bit-field.
	* config/arm/arm.c (arm_override_options): Default to
	-fstrict-volatile-bitfields.

	testsuite/
	* gcc.target/arm/volatile-bitfields-1.c: New test.
	* gcc.target/arm/volatile-bitfields-2.c: New test.
	* gcc.target/arm/volatile-bitfields-3.c: New test.

From-SVN: r165934
parent 7021d5df
2010-10-26 Jie Zhang <jie@codesourcery.com>
* stor-layout.c (layout_decl): Use the field's type to
determine the mode and keep DECL_BIT_FIELD for a volatile
bit-field.
* config/arm/arm.c (arm_override_options): Default to
-fstrict-volatile-bitfields.
2010-10-25 Paul Koning <ni1d@arrl.net>
* config/pdp11/pdp11.md: Add define_constants for register
......@@ -1971,6 +1971,10 @@ arm_option_override (void)
global_options.x_param_values,
global_options_set.x_param_values);
/* ARM EABI defaults to strict volatile bitfields. */
if (TARGET_AAPCS_BASED && flag_strict_volatile_bitfields < 0)
flag_strict_volatile_bitfields = 1;
/* Register global variables with the garbage collector. */
arm_add_gc_roots ();
}
......
......@@ -661,11 +661,14 @@ layout_decl (tree decl, unsigned int known_align)
}
/* See if we can use an ordinary integer mode for a bit-field.
Conditions are: a fixed size that is correct for another mode
and occupying a complete byte or bytes on proper boundary. */
Conditions are: a fixed size that is correct for another mode,
occupying a complete byte or bytes on proper boundary,
and not volatile or not -fstrict-volatile-bitfields. */
if (TYPE_SIZE (type) != 0
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
&& GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
&& GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT
&& !(TREE_THIS_VOLATILE (decl)
&& flag_strict_volatile_bitfields > 0))
{
enum machine_mode xmode
= mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
......
2010-10-26 Jie Zhang <jie@codesourcery.com>
* gcc.target/arm/volatile-bitfields-1.c: New test.
* gcc.target/arm/volatile-bitfields-2.c: New test.
* gcc.target/arm/volatile-bitfields-3.c: New test.
2010-10-25 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/pointer_discr1.adb: New test.
......
/* { dg-require-effective-target arm_eabi } */
/* { dg-do compile } */
/* { dg-options "-O2" } */
typedef struct {
char a:1;
char b:7;
int c;
} BitStruct;
volatile BitStruct bits;
int foo ()
{
return bits.b;
}
/* { dg-final { scan-assembler "ldrb\[\\t \]+\[^\n\]*,\[\\t \]*\\\[\[^\n\]*\\\]" } } */
/* { dg-require-effective-target arm_eabi } */
/* { dg-do compile } */
/* { dg-options "-O2" } */
typedef struct {
volatile unsigned long a:8;
volatile unsigned long b:8;
volatile unsigned long c:16;
} BitStruct;
BitStruct bits;
unsigned long foo ()
{
return bits.b;
}
/* { dg-final { scan-assembler "ldr\[\\t \]+\[^\n\]*,\[\\t \]*\\\[\[^\n\]*\\\]" } } */
/* { dg-require-effective-target arm_eabi } */
/* { dg-do compile } */
/* { dg-options "-O2" } */
typedef struct {
volatile unsigned long a:8;
volatile unsigned long b:8;
volatile unsigned long c:16;
} BitStruct;
BitStruct bits;
unsigned long foo ()
{
return bits.c;
}
/* { dg-final { scan-assembler "ldr\[\\t \]+\[^\n\]*,\[\\t \]*\\\[\[^\n\]*\\\]" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment