x86/asm: simplify some inline assembly with pointers to array
PATCH 1/1 x86/asm: simplify some inline assembly with pointers to array
Use pointer to array in memory operands instead of dummy variables to save LOC.
The patterns are:
"=m" (*(T(*)[N])ptr) "+m" (*(T(*)[N])ptr) and "m" (*(const T(*)[N])ptr)
Signed-off-by Alexey Dobriyan <[email protected]>
---
arch/x86/include/asm/special_insns.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
arch/x86/include/asm/special_insns.h +7 -14
@@ -188,17 +188,15 @@ static inline void clflushopt(volatile void *__p) "+m" (*(volatile char __force *)__p)); } -static inline void clwb (volatile void *__p) +static inline void clwb (volatile void *p) { -volatile struct {char x[64 ]; } *p = __p; - asm volatile(ALTERNATIVE_2( ".byte 0x3e; clflush (%[pax])", ".byte 0x66; clflush (%[pax])", /* clflushopt (%%rax) */ X86_FEATURE_CLFLUSHOPT, ".byte 0x66, 0x0f, 0xae, 0x30", /* clwb (%%rax) */ X86_FEATURE_CLWB) - : [p] "+m" (*p) + : [p] "+m" (*(volatile char(*)[64])p) : [pax] "a" (p)); }
@@ -226,13 +224,10 @@ static inline void serialize(void)/* The dst parameter must be 64-bytes aligned */ static inline void movdir64b (void *dst,const void *src) { -const struct {char _[64 ]; } *__src = src; -struct {char _[64 ]; } *__dst = dst; -/* * MOVDIR64B %(rdx), rax. * -* Both __src and __dst must be memory constraints in order to tell the +* Both src and dst must be memory constraints in order to tell the * compiler that no other memory accesses should be reordered around * this one. *
@@ -241,8 +236,8 @@ static inline void movdir64b(void *dst, const void *src)* I.e., not the pointers but what they point to, thus the deref'ing '*'. */ asmvolatile (".byte 0x66, 0x0f, 0x38, 0xf8, 0x02" - :"+m" (*__dst) - :"m" (*__src),"a" (__dst),"d" (__src)); + :"+m" (*(char (*)[64 ])dst) + :"m" (*(const char (*)[64 ])src),"a" (dst),"d" (src)); }static inline void movdir64b_io (void __iomem *dst,const void *src)
@@ -271,8 +266,6 @@ static inline void movdir64b_io(void __iomem *dst, const void *src)*/ static inline int enqcmds (void __iomem *dst,const void *src) { -const struct {char _[64 ]; } *__src = src; -struct {char _[64 ]; }__iomem *__dst = dst;bool zf;/*
@@ -282,8 +275,8 @@ static inline int enqcmds(void __iomem *dst, const void *src)*/ asm volatile(".byte 0xf3, 0x0f, 0x38, 0xf8, 0x02, 0x66, 0x90" CC_SET(z) - : CC_OUT(z) (zf), "+m" (*__dst) - : "m" (*__src), "a" (__dst), "d" (__src)); + : CC_OUT(z) (zf), "+m" (*(char __iomem(*)[64])dst) + : "m" (*(const char(*)[64])src), "a" (dst), "d" (src));/* Submission failure is indicated via EFLAGS.ZF=1 */ if (zf)