[LLVMdev] byte store requires read-modify-write sequence

Duncan Sands baldrick at free.fr
Thu Mar 19 01:39:42 PDT 2009


Hi,

> Our processor only does 32bit reads and writes to memory.  Changing a 
> byte requires a 32bit read, modify, 32bit write sequence to change the 
> 8bit value in memory.
> 
> How should this be handled?

your backend will have i32 as a legal type and i8 as an illegal type.
A store to an i8 will be automatically transformed into a "truncating"
to i8 store of i32.  Such a truncating store means: the lower 8 bits
of this i32 value needs to be stored.  When your backend sees such a
truncating store of an i32 V it will need to turn that into: read the
existing i32 value (W), replace the low 8 bits of W with the low 8
bits of V (high 8 bits on a big-endian machine), and write the new
W back.

> Do any of the other current backends do this?

I don't know.

Ciao,

Duncan.



More information about the llvm-dev mailing list