[PATCH] PR50325 store_bit_field: Fix for big endian targets

Eric Botcazou ebotcazou@adacore.com
Tue Dec 6 11:52:00 GMT 2011


> Ah, so in the BLKmode case, VALUE can still be a nonzero const_int?

Yes, I'd think so.

> What are the justification rules in that case?  Naively, I'd have
> expected a store of (const_int 1) into a BLKmode field to set one
> of the bits to 1, but it sounds from the above like it depends on
> endianness: for little-endian targets it always sets a bit, but for
> big-endian targets it only sets a bit if the field width is a multiple
> of UNITS_PER_WORD.

For example, in Ada, the following program:

with Text_IO; use Text_IO;
with Unchecked_Conversion;

procedure P is

  type Arr is new String(1..3);

  function Conv is new Unchecked_Conversion (Integer, Arr);

  type R is record
    A : Arr;
  end record;

  My_R : R;

begin
  My_R.A := Conv (16#41424344#);
  Put (String(My_R.A));
end;

outputs DCB on little-endian and ABC on big-endian.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list