[PowerPC] Fix i8/i16 atomics for little-Endian targets without partword atomics
authorHal Finkel <hfinkel@anl.gov>
Mon, 29 Aug 2016 22:25:36 +0000 (22:25 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 29 Aug 2016 22:25:36 +0000 (22:25 +0000)
commit3d70a9dbb7d39e0e1ebf453153135f698bd201a4
tree1573b066cccc4e1cbcf625630f74f9a9dc10b972
parent8223a1d09f6bce6a31ae88efce44a72e394018f4
[PowerPC] Fix i8/i16 atomics for little-Endian targets without partword atomics

For little-Endian PowerPC, we generally target only P8 and later by default.
However, generic (older) 64-bit configurations are still an option, and in that
case, partword atomics are not available (e.g. stbcx.). To lower i8/i16 atomics
without true i8/i16 atomic operations, we emulate using i32 atomics in
combination with a bunch of shifting and masking, etc. The amount by which to
shift in little-Endian mode is different from the amount in big-Endian mode (it
is inverted -- meaning we can leave off the xor when computing the amount).

Fixes PR22923.

llvm-svn: 280022
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/atomic-2.ll