]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
MIPS: Use GCC __builtin_prefetch() to implement prefetch().
authorDavid Daney <ddaney@caviumnetworks.com>
Fri, 14 May 2010 19:44:18 +0000 (12:44 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 21 May 2010 20:31:23 +0000 (21:31 +0100)
GCC's __builtin_prefetch() was introduced a long time ago, all
supported GCC versions have it.  Lets do what the big boys up in
linux/prefetch.h do, except we use '1' as the third parameter to
provoke 'PREF 0,...'  and 'PREF 1,...' instead of other prefetch
hints.

This allows for better code generation.  In theory the existing
embedded asm could be optimized, but the compiler has these builtins,
so there is really no point.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/1235/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/processor.h

index ab387910009a3d1fd100f79aa94560552680750a..5d33b727acf51eeedec4b43525f2452351f66465 100644 (file)
@@ -344,16 +344,10 @@ unsigned long get_wchan(struct task_struct *p);
 #ifdef CONFIG_CPU_HAS_PREFETCH
 
 #define ARCH_HAS_PREFETCH
+#define prefetch(x) __builtin_prefetch((x), 0, 1)
 
-static inline void prefetch(const void *addr)
-{
-       __asm__ __volatile__(
-       "       .set    mips4           \n"
-       "       pref    %0, (%1)        \n"
-       "       .set    mips0           \n"
-       :
-       : "i" (Pref_Load), "r" (addr));
-}
+#define ARCH_HAS_PREFETCHW
+#define prefetchw(x) __builtin_prefetch((x), 1, 1)
 
 #endif