This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Do BLKmode bit-fields still exist?


On Fri, Nov 6, 2009 at 10:46 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> In a desparate try to get some testcases which do have BLKmode bit-fields
>> I bootstrapped and regtested the below patch (as part of a larger patch,
>> though) on seven architectures with all languages (on two without Ada).
>
> Yet it's easy in Ada on platforms with strict alignment, e.g. SPARC:
>
> package P is
>
> ?type Rec1 is record
> ? ?I1 : Integer;
> ? ?I2 : Integer;
> ? ?I3 : Integer;
> ?end record;
>
> ?type R2 is record
> ? ?B : Boolean;
> ? ?R : Rec1;
> ?end record;
> ?pragma Pack (R2);
>
> end P;
>
> (gdb) p debug_tree(0x2aaaaab2bdc0)
> ?<field_decl 0x2aaaaab2bdc0 r
> ? ?type <record_type 0x2aaaaabc64d0 p__rec1 sizes-gimplified visited BLK
> ? ? ? ?size <integer_cst 0x2aaaaab27f90 constant visited 96>
> ? ? ? ?unit size <integer_cst 0x2aaaaabd7d20 constant visited 12>
> ? ? ? ?align 32 symtab 0 alias set -1 canonical type 0x2aaaaabc64d0
> ? ? ? ?fields <field_decl 0x2aaaaab2bb40 i1 type <integer_type 0x2aaaaabc6580
> integer>
> ? ? ? ? ? ?nonaddressable SI file p.ads line 4 col 5
> ? ? ? ? ? ?size <integer_cst 0x2aaaaaaf1420 constant visited 32>
> ? ? ? ? ? ?unit size <integer_cst 0x2aaaaaaf1090 constant visited 4>
> ? ? ? ? ? ?align 32 offset_align 64
> ? ? ? ? ? ?offset <integer_cst 0x2aaaaaaf1b40 constant visited 0>
> ? ? ? ? ? ?bit offset <integer_cst 0x2aaaaaaf1b70 constant 0> context
> <record_type 0x2aaaaabc64d0 p__rec1> chain <field_decl 0x2aaaaab2bbe0 i2>>
> Ada size <integer_cst 0x2aaaaab27f90 96>
> ? ? ? ?reference_to_this <reference_type 0x2aaaaabc6630> chain <type_decl
> 0x2aaaaab34540 p__rec1>>
> ? ?external packed bit-field BLK file p.ads line 11 col 5 size <integer_cst
> 0x2aaaaab27f90 96> unit size <integer_cst 0x2aaaaabd7d20 12>
> ? ?align 8 offset_align 64 offset <integer_cst 0x2aaaaaaf1b40 0>
> ? ?bit offset <integer_cst 0x2aaaaaaf1180 type <integer_type 0x2aaaaab010b0
> bit_size_type> constant visited 8> bit_field_type <record_type 0x2aaaaabc64d0
> p__rec1> context <record_type 0x2aaaaabc6790 p__r2>>
>
> We set DECL_BIT_FIELD in the front-end because the field is misaligned.

Isn't it enough to specify DECL_PACKED here?  The tree.h docs
about DECL_BIT_FIELD are a bit unspecific compared to
DECL_PACKED.

/* Nonzero in a FIELD_DECL means it is a bit field, and must be
accessed   specially.  */

vs.

/* In a FIELD_DECL, indicates this field should be bit-packed.  */

where it seems, as your field isn't a bitfield, using DECL_PACKED
looks more appropriate?

Richard.

> --
> Eric Botcazou
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]