patch: honor volatile bitfield types

Mark Mitchell mark@codesourcery.com
Fri Jun 11 16:42:00 GMT 2010


DJ Delorie wrote:

>> Shouldn't the default actually be target-specific (no new hooks needed, 
>> existing hooks to set options in a target-specific way should suffice, 
>> though maybe you need to initialize the flag setting to -1 to allow 
>> OVERRIDE_OPTIONS to know whether it was explicitly set)?  For example, ARM 
>> EABI should enable this by default.
> 
> Yes, it should.  I figured, let's get the functionality working first,
> then let the target maintainers decide which targets need it on and
> which off.

Very glad to see this functionality.  However, before it goes in, I
think the change that Joseph is suggesting (which is perhaps just a
documentation change to say that the default is target-dependent) shold
occur.

Here's some proposed words for the documentation:

==
Access volatile structure fields (including bitfields) by using a single
read or write, and by loading as few bits as possible to load the field.
 For example, when loading a @type{char} bitfield on a machine with an
8-bit @type{char}, use either an 8-bit load instruction (if the entire
bitfield fits within a single byte) or a 16-bit load instruction (if the
bitfield spans two bytes).  If honoring these constraints would result
in an unaligned access on a machine where unaligned accesses are not
permitted, the compiler issues a warning and does not generate an
unaligned access.

If this option is disabled, the compiler will use the most efficient
instruction.  In the previous example, that might be a 32-bit load
instruction, even though that will access bytes that do not contain any
portion of the bitfield.

The default value of this option is determined by the application binary
interface for the target processor.
==

I think that's a more user-centric description of the option.  If I've
gotten the details wrong, please correct them.  If you need someone to
review this patch after it's been revised, please let me know.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list