* [PATCH 0/2] arch_hweight implementation for MIPS
@ 2010-06-25 23:46 David Daney
2010-06-25 23:46 ` [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h David Daney
2010-06-25 23:46 ` [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON David Daney
0 siblings, 2 replies; 5+ messages in thread
From: David Daney @ 2010-06-25 23:46 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: David Daney
Recently the core hweight implementation was reworked to make it
easier for an architecture to implement optimized hweight()
operations.
For MIPS, I get lazy and fall back to letting GCC emit the optimized
code if it can. If ARCH_HAS_USABLE_BUILTIN_POPCOUNT is defined, we
let GCC do it, otherwise, the fallback library call is used.
The second patch turns this on for OCTEON as it has POP and DPOP
instructions that GCC knows about.
David Daney (2):
MIPS: Create and use asm/arch_hweight.h
MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON.
arch/mips/include/asm/arch_hweight.h | 38 ++++++++++++++++++++
arch/mips/include/asm/bitops.h | 5 ++-
.../asm/mach-cavium-octeon/cpu-feature-overrides.h | 8 ++++
3 files changed, 50 insertions(+), 1 deletions(-)
create mode 100644 arch/mips/include/asm/arch_hweight.h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h
2010-06-25 23:46 [PATCH 0/2] arch_hweight implementation for MIPS David Daney
@ 2010-06-25 23:46 ` David Daney
2010-07-06 13:57 ` Ralf Baechle
2010-06-25 23:46 ` [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON David Daney
1 sibling, 1 reply; 5+ messages in thread
From: David Daney @ 2010-06-25 23:46 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: David Daney
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>
---
arch/mips/include/asm/arch_hweight.h | 38 ++++++++++++++++++++++++++++++++++
arch/mips/include/asm/bitops.h | 5 +++-
2 files changed, 42 insertions(+), 1 deletions(-)
create mode 100644 arch/mips/include/asm/arch_hweight.h
diff --git a/arch/mips/include/asm/arch_hweight.h b/arch/mips/include/asm/arch_hweight.h
new file mode 100644
index 0000000..712a744
--- /dev/null
+++ b/arch/mips/include/asm/arch_hweight.h
@@ -0,0 +1,38 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+#ifndef _ASM_ARCH_HWEIGHT_H
+#define _ASM_ARCH_HWEIGHT_H
+
+#ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT
+
+#include <asm/types.h>
+
+static inline unsigned int __arch_hweight32(unsigned int w)
+{
+ return __builtin_popcount(w);
+}
+
+static inline unsigned int __arch_hweight16(unsigned int w)
+{
+ return __builtin_popcount(w & 0xffff);
+}
+
+static inline unsigned int __arch_hweight8(unsigned int w)
+{
+ return __builtin_popcount(w & 0xff);
+}
+
+static inline unsigned long __arch_hweight64(__u64 w)
+{
+ return __builtin_popcountll(w);
+}
+
+#else
+#include <asm-generic/bitops/arch_hweight.h>
+#endif
+
+#endif /* _ASM_ARCH_HWEIGHT_H */
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index 9255cfb..b0ce7ca 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)
#ifdef __KERNEL__
#include <asm-generic/bitops/sched.h>
-#include <asm-generic/bitops/hweight.h>
+
+#include <asm/arch_hweight.h>
+#include <asm-generic/bitops/const_hweight.h>
+
#include <asm-generic/bitops/ext2-non-atomic.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>
--
1.6.6.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON.
2010-06-25 23:46 [PATCH 0/2] arch_hweight implementation for MIPS David Daney
2010-06-25 23:46 ` [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h David Daney
@ 2010-06-25 23:46 ` David Daney
2010-07-06 13:57 ` Ralf Baechle
1 sibling, 1 reply; 5+ messages in thread
From: David Daney @ 2010-06-25 23:46 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: David Daney
OCTEON implements __builtin_popcount with a single instruction, so
lets use it.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
.../asm/mach-cavium-octeon/cpu-feature-overrides.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
index e412777..b952fc7 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
@@ -66,6 +66,14 @@
#define spin_lock_prefetch(x) prefetch(x)
#define PREFETCH_STRIDE 128
+#ifdef __OCTEON__
+/*
+ * All gcc versions that have OCTEON support define __OCTEON__ and have the
+ * __builtin_popcount support.
+ */
+#define ARCH_HAS_USABLE_BUILTIN_POPCOUNT 1
+#endif
+
static inline int octeon_has_saa(void)
{
int id;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h
2010-06-25 23:46 ` [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h David Daney
@ 2010-07-06 13:57 ` Ralf Baechle
0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2010-07-06 13:57 UTC (permalink / raw)
To: David Daney; +Cc: linux-mips
Thanks, queued for 2.6.36.
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON.
2010-06-25 23:46 ` [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON David Daney
@ 2010-07-06 13:57 ` Ralf Baechle
0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2010-07-06 13:57 UTC (permalink / raw)
To: David Daney; +Cc: linux-mips
Thanks, queued for 2.6.36.
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-06 13:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-25 23:46 [PATCH 0/2] arch_hweight implementation for MIPS David Daney
2010-06-25 23:46 ` [PATCH 1/2] MIPS: Create and use asm/arch_hweight.h David Daney
2010-07-06 13:57 ` Ralf Baechle
2010-06-25 23:46 ` [PATCH 2/2] MIPS: Octeon: Define ARCH_HAS_USABLE_BUILTIN_POPCOUNT for OCTEON David Daney
2010-07-06 13:57 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).