Remove an unnecessary arch complication:
arch/x86/include/asm/arch_hweight.h uses __sw_hweight{32,64} as
alternatives, and they are implemented in arch/x86/lib/hweight.S
x86 does not rely on the generic C implementation lib/hweight.c
at all, so CONFIG_GENERIC_HWEIGHT should be disabled.
__HAVE_ARCH_SW_HWEIGHT is not necessary either.
No change in functionality intended.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Uros Bizjak <ubizjak@gmail.com>
Link: http://lkml.kernel.org/r/1557665521-17570-1-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
		
	
			
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0 */
 | |
| #ifndef _ASM_X86_HWEIGHT_H
 | |
| #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
 | |
| 
 | |
| 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));
 | |
| 
 | |
| 	return res;
 | |
| }
 | |
| 
 | |
| static inline unsigned int __arch_hweight16(unsigned int w)
 | |
| {
 | |
| 	return __arch_hweight32(w & 0xffff);
 | |
| }
 | |
| 
 | |
| static inline unsigned int __arch_hweight8(unsigned int w)
 | |
| {
 | |
| 	return __arch_hweight32(w & 0xff);
 | |
| }
 | |
| 
 | |
| #ifdef CONFIG_X86_32
 | |
| static inline unsigned long __arch_hweight64(__u64 w)
 | |
| {
 | |
| 	return  __arch_hweight32((u32)w) +
 | |
| 		__arch_hweight32((u32)(w >> 32));
 | |
| }
 | |
| #else
 | |
| 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));
 | |
| 
 | |
| 	return res;
 | |
| }
 | |
| #endif /* CONFIG_X86_32 */
 | |
| 
 | |
| #endif
 |