aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-07-29 12:42:07 -0400
committerDavid S. Miller <davem@davemloft.net>2011-08-03 00:28:50 -0400
commitef7c4d4675d2a9206f913f26ca1a5cd41bff9d41 (patch)
tree88839b80e603ba395882df98b8a8c8f8385337b1 /arch/sparc/include
parente95ade083939dcb4b0c51c1a2c8504ea9ef3d6ef (diff)
sparc: Use popc if possible for hweight routines.
Just like powerpc, we code patch at boot time. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/include')
-rw-r--r--arch/sparc/include/asm/bitops_64.h42
1 files changed, 4 insertions, 38 deletions
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index 325e295d60de..3588807baa6e 100644
--- a/arch/sparc/include/asm/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
@@ -42,45 +42,11 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);
42 * of bits set) of a N-bit word 42 * of bits set) of a N-bit word
43 */ 43 */
44 44
45#ifdef ULTRA_HAS_POPULATION_COUNT 45extern unsigned long __arch_hweight64(__u64 w);
46extern unsigned int __arch_hweight32(unsigned int w);
47extern unsigned int __arch_hweight16(unsigned int w);
48extern unsigned int __arch_hweight8(unsigned int w);
46 49
47static inline unsigned int __arch_hweight64(unsigned long w)
48{
49 unsigned int res;
50
51 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w));
52 return res;
53}
54
55static inline unsigned int __arch_hweight32(unsigned int w)
56{
57 unsigned int res;
58
59 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff));
60 return res;
61}
62
63static inline unsigned int __arch_hweight16(unsigned int w)
64{
65 unsigned int res;
66
67 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff));
68 return res;
69}
70
71static inline unsigned int __arch_hweight8(unsigned int w)
72{
73 unsigned int res;
74
75 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff));
76 return res;
77}
78
79#else
80
81#include <asm-generic/bitops/arch_hweight.h>
82
83#endif
84#include <asm-generic/bitops/const_hweight.h> 50#include <asm-generic/bitops/const_hweight.h>
85#include <asm-generic/bitops/lock.h> 51#include <asm-generic/bitops/lock.h>
86#endif /* __KERNEL__ */ 52#endif /* __KERNEL__ */