public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* bitfields: types vs modes?
@ 2009-03-10  8:18 DJ Delorie
  2009-03-11  7:36 ` Hans-Peter Nilsson
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: DJ Delorie @ 2009-03-10  8:18 UTC (permalink / raw)
  To: gcc


One of our customers has a chip with memory-mapped peripheral
registers that need to be accessed in a specific mode.  The registers
represent bitfields within the hardware, so a volatile struct is an
obvious choice to represent them in C.

However, gcc has a very simplistic heuristic for deciding what mode to
use to access bitfields in structures - it uses either the biggest or
smallest mode practical.  This offers the programmer no way to tell
gcc what mode the accesses need to be in, aside from manually
reading/writing memory with integer types and casting.

Options?  My thought, after some internal discussion, is that (if the
target chooses) we allow gcc to honor the type of a volatile bitfield
as the mode as long as it can do so without otherwise violating the
structure's layout.  Some new hook will be needed for the backend, and
perhaps a -W option for when the type cannot be honored.

I.e. if the programmer is careful enough to properly lay out the
struct, the programmer should get what the programmer asks for.

Comments?  Alternatives?

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-07-16 23:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10  8:18 bitfields: types vs modes? DJ Delorie
2009-03-11  7:36 ` Hans-Peter Nilsson
2009-03-11  7:42   ` DJ Delorie
2009-03-11 13:24     ` Laurent GUERBY
2009-03-11 11:57 ` Paul Brook
2009-03-11 13:55   ` Hans-Peter Nilsson
2009-04-01  5:11 ` DJ Delorie
2009-04-01  5:33   ` Ian Lance Taylor
2009-04-06 17:20     ` Mark Mitchell
2009-04-06 20:11       ` DJ Delorie
2009-04-06 20:46         ` Mark Mitchell
2009-05-20 21:35           ` DJ Delorie
2009-05-20 21:48             ` Ian Lance Taylor
2009-05-20 22:10               ` Mark Mitchell
2009-05-21  1:34                 ` DJ Delorie
2009-05-21 11:51                   ` Mark Mitchell
2009-07-14 20:12                     ` DJ Delorie
2009-07-15  1:09                       ` Mark Mitchell
2009-07-15  1:15                         ` DJ Delorie
2009-07-16 23:19                         ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).