, - , , , .
stwbrx
= . x
.
GNU C asm, __builtin_bswap32
.
void swapstore_asm(int a, int *p) {
ASMSWAP32(p, a);
}
void swapstore_c(int a, int *p) {
*p = __builtin_bswap32(a);
}
gcc4.8.5 -O3 -mregnames
, (Godbolt compiler explorer):
swapstore:
stwbrx %r3, 0, %r4
blr
swapstore_c:
stwbrx %r3,0,%r4
blr
( p[off]
, off
arg), , , :
void swapstore_offset(int a, int *p, int off) {
= __builtin_bswap32(a);
}
swapstore_offset:
slwi %r5,%r5,2
stwbrx %r3,%r4,%r5
blr
swapstore_offset_asm:
slwi %r5,%r5,2
add %r4,%r4,%r5
stwbrx %r3, 0, %r4
blr
, asm asus GNU C, asm , . . "" GCC/clang? ASM .
, : "memory"
clobber . , asm volatile
. , *dest_addr
, , *dest_addr
insn , , , . (, , .)
"memory"
clobber ( volatile
), , =m" (*dest_addr)
, , reg+reg
. (IDK PPC , , "=m"
.)
, . .
https://gcc.gnu.org/wiki/DontUseInlineAsm
. fooobar.com/questions/tagged/....