diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-06-25 19:46:07 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-08-05 08:26:02 -0400 |
commit | 1a403d1d2e549bc7d280001503867321572717f6 (patch) | |
tree | e96d31e561f13695e591cd2eadd116c4994624e6 | |
parent | d16f7093b6eb4f3859856f6ee4ab504cbeeea0b9 (diff) |
MIPS: Create and use asm/arch_hweight.h
Some MIPS ISA processor varients can do hweight operations
efficiently.
Split arch_hweight.h into a seperate file, and implement the
operations with __builtin_popcount{,ll} if supported.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/1430/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/arch_hweight.h | 38 | ||||
-rw-r--r-- | arch/mips/include/asm/bitops.h | 5 |
2 files changed, 42 insertions, 1 deletions
diff --git a/arch/mips/include/asm/arch_hweight.h b/arch/mips/include/asm/arch_hweight.h new file mode 100644 index 000000000000..712a7445ee93 --- /dev/null +++ b/arch/mips/include/asm/arch_hweight.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | */ | ||
7 | #ifndef _ASM_ARCH_HWEIGHT_H | ||
8 | #define _ASM_ARCH_HWEIGHT_H | ||
9 | |||
10 | #ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT | ||
11 | |||
12 | #include <asm/types.h> | ||
13 | |||
14 | static inline unsigned int __arch_hweight32(unsigned int w) | ||
15 | { | ||
16 | return __builtin_popcount(w); | ||
17 | } | ||
18 | |||
19 | static inline unsigned int __arch_hweight16(unsigned int w) | ||
20 | { | ||
21 | return __builtin_popcount(w & 0xffff); | ||
22 | } | ||
23 | |||
24 | static inline unsigned int __arch_hweight8(unsigned int w) | ||
25 | { | ||
26 | return __builtin_popcount(w & 0xff); | ||
27 | } | ||
28 | |||
29 | static inline unsigned long __arch_hweight64(__u64 w) | ||
30 | { | ||
31 | return __builtin_popcountll(w); | ||
32 | } | ||
33 | |||
34 | #else | ||
35 | #include <asm-generic/bitops/arch_hweight.h> | ||
36 | #endif | ||
37 | |||
38 | #endif /* _ASM_ARCH_HWEIGHT_H */ | ||
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h index 9255cfbee459..b0ce7ca2851f 100644 --- a/arch/mips/include/asm/bitops.h +++ b/arch/mips/include/asm/bitops.h | |||
@@ -700,7 +700,10 @@ static inline int ffs(int word) | |||
700 | #ifdef __KERNEL__ | 700 | #ifdef __KERNEL__ |
701 | 701 | ||
702 | #include <asm-generic/bitops/sched.h> | 702 | #include <asm-generic/bitops/sched.h> |
703 | #include <asm-generic/bitops/hweight.h> | 703 | |
704 | #include <asm/arch_hweight.h> | ||
705 | #include <asm-generic/bitops/const_hweight.h> | ||
706 | |||
704 | #include <asm-generic/bitops/ext2-non-atomic.h> | 707 | #include <asm-generic/bitops/ext2-non-atomic.h> |
705 | #include <asm-generic/bitops/ext2-atomic.h> | 708 | #include <asm-generic/bitops/ext2-atomic.h> |
706 | #include <asm-generic/bitops/minix.h> | 709 | #include <asm-generic/bitops/minix.h> |