aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-09-26 02:32:08 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:48:54 -0400
commita8ad27d03f17e6154c61e81d4a7028c56ca6390d (patch)
tree14d0367af1fafa359733b04326a95a4fe39557c5 /include
parent92fc707208bb2e601c24b5ab65db37bcb361b658 (diff)
[PATCH] FRV: Implement fls64()
Implement fls64() for FRV without recource to conditional jumps. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-frv/bitops.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
index 97fb746f76c7..591eecc1f8cd 100644
--- a/include/asm-frv/bitops.h
+++ b/include/asm-frv/bitops.h
@@ -186,7 +186,47 @@ static inline int __test_bit(int nr, const volatile void * addr)
186 bit; \ 186 bit; \
187}) 187})
188 188
189#include <asm-generic/bitops/fls64.h> 189/**
190 * fls64 - find last bit set in a 64-bit value
191 * @n: the value to search
192 *
193 * This is defined the same way as ffs:
194 * - return 64..1 to indicate bit 63..0 most significant bit set
195 * - return 0 to indicate no bits set
196 */
197static inline __attribute__((const))
198int fls64(u64 n)
199{
200 union {
201 u64 ll;
202 struct { u32 h, l; };
203 } _;
204 int bit, x, y;
205
206 _.ll = n;
207
208 asm(" subcc.p %3,gr0,gr0,icc0 \n"
209 " subcc %4,gr0,gr0,icc1 \n"
210 " ckne icc0,cc4 \n"
211 " ckne icc1,cc5 \n"
212 " norcr cc4,cc5,cc6 \n"
213 " csub.p %0,%0,%0 ,cc6,1 \n"
214 " orcr cc5,cc4,cc4 \n"
215 " andcr cc4,cc5,cc4 \n"
216 " cscan.p %3,gr0,%0 ,cc4,0 \n"
217 " setlos #64,%1 \n"
218 " cscan.p %4,gr0,%0 ,cc4,1 \n"
219 " setlos #32,%2 \n"
220 " csub.p %1,%0,%0 ,cc4,0 \n"
221 " csub %2,%0,%0 ,cc4,1 \n"
222 : "=&r"(bit), "=r"(x), "=r"(y)
223 : "0r"(_.h), "r"(_.l)
224 : "icc0", "icc1", "cc4", "cc5", "cc6"
225 );
226 return bit;
227
228}
229
190#include <asm-generic/bitops/sched.h> 230#include <asm-generic/bitops/sched.h>
191#include <asm-generic/bitops/hweight.h> 231#include <asm-generic/bitops/hweight.h>
192 232