How to force 32bit access to bit fields ?

Robert Dewar dewar@gnat.com
Wed Feb 5 13:21:00 GMT 2003


> Hi,
> 
> I am having a problem with the code GCC generates for bit field accesses. On
> IA32 GCC 3.2.1 generates 8-bit instructions for a bit field access, but my
> device memory only supports 32-bit accesses.
> Is there any way to make GCC use 32-bit load and store instructions for a
> bit field access? 
> Can anyone point me to the corresponding subroutines in GCC that generate
> code for bit fields?
> Best Regards 
>         Ralf

It seems best to me to use ASM inserts if you really need to control the
exact instructions that are issued. It is certainly valid for gcc to use
32-bit accesses in this situation, and it is hard to see how this could
be "fixed".

There is a long discussion in the Ada context about the identical issue.
One sort of approach is the following implementation advice.

If there is an access to a volatile variable, then if this access can be
done in a single instruction which accesses the entire variable it should
be done that way. 



More information about the Gcc mailing list