lkml.org 
[lkml]   [2019]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] x86: drop REG_OUT macro from hweight functions
On Sun, Jul 28, 2019 at 02:51:40PM +0300, Alexey Dobriyan wrote:
> Output register is always RAX/EAX.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>
> arch/x86/include/asm/arch_hweight.h | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> --- a/arch/x86/include/asm/arch_hweight.h
> +++ b/arch/x86/include/asm/arch_hweight.h
> @@ -6,10 +6,8 @@
>
> #ifdef CONFIG_64BIT
> #define REG_IN "D"
> -#define REG_OUT "a"
> #else
> #define REG_IN "a"
> -#define REG_OUT "a"
> #endif
>
> static __always_inline unsigned int __arch_hweight32(unsigned int w)
> @@ -17,7 +15,7 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
> unsigned int res;
>
> asm (ALTERNATIVE("call __sw_hweight32", "popcntl %1, %0", X86_FEATURE_POPCNT)
> - : "="REG_OUT (res)
> + : "=a" (res)
> : REG_IN (w));
>
> return res;
> @@ -45,7 +43,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
> unsigned long res;
>
> asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", X86_FEATURE_POPCNT)
> - : "="REG_OUT (res)
> + : "=a" (res)
> : REG_IN (w));
>
> return res;

I _think_ something like the below should also work:

(fwiw _ASM_ARG 5 and 6 are broken, as are all the QLWB variants)

---
diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
index ba88edd0d58b..88704612b2f7 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -3,22 +3,15 @@
#define _ASM_X86_HWEIGHT_H

#include <asm/cpufeatures.h>
-
-#ifdef CONFIG_64BIT
-#define REG_IN "D"
-#define REG_OUT "a"
-#else
-#define REG_IN "a"
-#define REG_OUT "a"
-#endif
+#include <asm/asm.h>

static __always_inline unsigned int __arch_hweight32(unsigned int w)
{
unsigned int res;

asm (ALTERNATIVE("call __sw_hweight32", "popcntl %1, %0", X86_FEATURE_POPCNT)
- : "="REG_OUT (res)
- : REG_IN (w));
+ : "=a" (res)
+ : _ASM_ARG1 (w));

return res;
}
@@ -45,8 +38,8 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
unsigned long res;

asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", X86_FEATURE_POPCNT)
- : "="REG_OUT (res)
- : REG_IN (w));
+ : "=a" (res)
+ : _ASM_ARG1 (w));

return res;
}
\
 
 \ /
  Last update: 2019-07-29 11:45    [W:0.049 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site