s390/fpu: let fpu_vlm() and fpu_vstm() return number of registers
authorHeiko Carstens <hca@linux.ibm.com>
Sat, 3 Feb 2024 10:45:16 +0000 (11:45 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 16 Feb 2024 13:30:16 +0000 (14:30 +0100)
Let fpu_vlm() and fpu_vstm() macros return the number of registers saved /
loaded. This is helpful to read easy to read code in case there are several
subsequent fpu_vlm() or fpu_vstm() calls:

__vector128 *vxrs = ....

vxrs += fpu_vstm(0, 15, vxrs);
vxrs += fpu_vstm(16, 31, vxrs);

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/fpu-insn.h

index 538201864a47fde2b728d3683d15c0d22802c321..803ce4e2aab46a41b77a8dc725b99c5aad4d3652 100644 (file)
@@ -110,7 +110,8 @@ static __always_inline void fpu_stfpc(unsigned int *fpc)
 
 #ifdef CONFIG_CC_IS_CLANG
 
-#define fpu_vlm(_v1, _v3, _vxrs) do {                                  \
+#define fpu_vlm(_v1, _v3, _vxrs)                                       \
+({                                                                     \
        unsigned int size = ((_v3) - (_v1) + 1) * sizeof(__vector128);  \
        struct {                                                        \
                __vector128 _v[(_v3) - (_v1) + 1];                      \
@@ -124,11 +125,13 @@ static __always_inline void fpu_stfpc(unsigned int *fpc)
                : [vxrs] "R" (*_v),                                     \
                  [v1] "I" (_v1), [v3] "I" (_v3)                        \
                : "memory", "1");                                       \
-} while (0)
+       (_v3) - (_v1) + 1;                                              \
+})
 
 #else /* CONFIG_CC_IS_CLANG */
 
-#define fpu_vlm(_v1, _v3, _vxrs) do {                                  \
+#define fpu_vlm(_v1, _v3, _vxrs)                                       \
+({                                                                     \
        unsigned int size = ((_v3) - (_v1) + 1) * sizeof(__vector128);  \
        struct {                                                        \
                __vector128 _v[(_v3) - (_v1) + 1];                      \
@@ -140,13 +143,15 @@ static __always_inline void fpu_stfpc(unsigned int *fpc)
                     : [vxrs] "Q" (*_v),                                \
                       [v1] "I" (_v1), [v3] "I" (_v3)                   \
                     : "memory");                                       \
-} while (0)
+       (_v3) - (_v1) + 1;                                              \
+})
 
 #endif /* CONFIG_CC_IS_CLANG */
 
 #ifdef CONFIG_CC_IS_CLANG
 
-#define fpu_vstm(_v1, _v3, _vxrs) do {                                 \
+#define fpu_vstm(_v1, _v3, _vxrs)                                      \
+({                                                                     \
        unsigned int size = ((_v3) - (_v1) + 1) * sizeof(__vector128);  \
        struct {                                                        \
                __vector128 _v[(_v3) - (_v1) + 1];                      \
@@ -159,11 +164,13 @@ static __always_inline void fpu_stfpc(unsigned int *fpc)
                : [vxrs] "=R" (*_v)                                     \
                : [v1] "I" (_v1), [v3] "I" (_v3)                        \
                : "memory", "1");                                       \
-} while (0)
+       (_v3) - (_v1) + 1;                                              \
+})
 
 #else /* CONFIG_CC_IS_CLANG */
 
-#define fpu_vstm(_v1, _v3, _vxrs) do {                                 \
+#define fpu_vstm(_v1, _v3, _vxrs)                                      \
+({                                                                     \
        unsigned int size = ((_v3) - (_v1) + 1) * sizeof(__vector128);  \
        struct {                                                        \
                __vector128 _v[(_v3) - (_v1) + 1];                      \
@@ -174,7 +181,8 @@ static __always_inline void fpu_stfpc(unsigned int *fpc)
                     : [vxrs] "=Q" (*_v)                                \
                     : [v1] "I" (_v1), [v3] "I" (_v3)                   \
                     : "memory");                                       \
-} while (0)
+       (_v3) - (_v1) + 1;                                              \
+})
 
 #endif /* CONFIG_CC_IS_CLANG */