mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
x86/hweight: Get rid of the special calling convention
People complained about ARCH_HWEIGHT_CFLAGS and how it throws a wrench
into kcov, lto, etc, experimentations.
Add asm versions for __sw_hweight{32,64}() and do explicit saving and
restoring of clobbered registers. This gets rid of the special calling
convention. We get to call those functions on !X86_FEATURE_POPCNT CPUs.
We still need to hardcode POPCNT and register operands as some old gas
versions which we support, do not know about POPCNT.
Btw, remove redundant REX prefix from 32-bit POPCNT because alternatives
can do padding now.
Suggested-by: H. Peter Anvin <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
08dd8cd06e
commit
f5967101e9
8 changed files with 97 additions and 25 deletions
|
|
@ -9,6 +9,7 @@
|
|||
* The Hamming Weight of a number is the total number of bits set in it.
|
||||
*/
|
||||
|
||||
#ifndef __HAVE_ARCH_SW_HWEIGHT
|
||||
unsigned int __sw_hweight32(unsigned int w)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
|
||||
|
|
@ -25,6 +26,7 @@ unsigned int __sw_hweight32(unsigned int w)
|
|||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__sw_hweight32);
|
||||
#endif
|
||||
|
||||
unsigned int __sw_hweight16(unsigned int w)
|
||||
{
|
||||
|
|
@ -43,6 +45,7 @@ unsigned int __sw_hweight8(unsigned int w)
|
|||
}
|
||||
EXPORT_SYMBOL(__sw_hweight8);
|
||||
|
||||
#ifndef __HAVE_ARCH_SW_HWEIGHT
|
||||
unsigned long __sw_hweight64(__u64 w)
|
||||
{
|
||||
#if BITS_PER_LONG == 32
|
||||
|
|
@ -65,3 +68,4 @@ unsigned long __sw_hweight64(__u64 w)
|
|||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__sw_hweight64);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue