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?


Hi,

On Fri, 6 Nov 2009, Eric Botcazou wrote:

> 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
>     external packed bit-field BLK file p.ads line 11 col 5 size <integer_cst 
> 
> We set DECL_BIT_FIELD in the front-end because the field is misaligned.

Uahhh!  A bitfield of RECORD_TYPE!  Marvelous.

Molding this into a testcase that actually writes into some parts, like:

procedure Fields is
  type Rec1 is record
    I1 : Integer;
  end record;

  type R2 is record
    B : Boolean;
    R : Rec1;
  end record;
  pragma Pack (R2);

  r,rr : R2;
  subr,subr2 : Rec1;
  procedure useme (x:in out R2;y:in out Rec1);
  pragma Import (C, useme);
  function giveme return Integer;
  pragma Import (c,giveme);
begin
  subr2.I1 := giveme;
  subr := subr2;
  r.R := subr2;
  rr := r;
  useme(rr, subr);
end;

triggers the gcc_unreachable in get_inner_references (on sparc), okay.  
But I can't trigger the one in store_field, because the target for these 
stores will alway be a non-register due to the unaligned fields in there, 
hmm. (the above needs -O1 -fno-tree-ccp -fno-tree-copy-prop -fno-tree-sra 
ot not forward the giveme() result but retain the store into r.R).


Ciao,
Michael.


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