This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can I force a word read-modify-write instread of a byte write?
- From: "Phil Endecott" <spam_from_gcc_help at chezphil dot org>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Mon, 02 Jul 2007 11:03:53 +0100
- Subject: Can I force a word read-modify-write instread of a byte write?
Dear Experts,
I know that in some circumstances gcc will generate read-modify-write
sequences to access memory locations, for example if I have a bitfield
struct. Is there a way in which I can tell it to only do (32-bit) word
writes to a region of memory, and to do read-modify-write sequences
instead of byte writes, even though the processor does have byte write instructions?
The situation is that I have some FPGA logic which only implements word
writes. My options are:
(a) Make the FPGA hardware support byte writes.
(b) Do explicit read/modify/write sequences in my C code.
(c) Persuade gcc to do the work for me.
Since both (a) and (b) involve quite a lot of work, I have crossed my
fingers in the hope that I can just add some magic __attribute__
somewhere and gcc will do the work for me. Am I in luck?
Many thanks for any suggestions,
Phil.