aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-frv
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-frv')
-rw-r--r--include/asm-frv/bitops.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
index 1f70d47148bd..f8560edf59ff 100644
--- a/include/asm-frv/bitops.h
+++ b/include/asm-frv/bitops.h
@@ -256,6 +256,50 @@ int __ffs(unsigned long x)
256 return 31 - bit; 256 return 31 - bit;
257} 257}
258 258
259/*
260 * special slimline version of fls() for calculating ilog2_u32()
261 * - note: no protection against n == 0
262 */
263#define ARCH_HAS_ILOG2_U32
264static inline __attribute__((const))
265int __ilog2_u32(u32 n)
266{
267 int bit;
268 asm("scan %1,gr0,%0" : "=r"(bit) : "r"(n));
269 return 31 - bit;
270}
271
272/*
273 * special slimline version of fls64() for calculating ilog2_u64()
274 * - note: no protection against n == 0
275 */
276#define ARCH_HAS_ILOG2_U64
277static inline __attribute__((const))
278int __ilog2_u64(u64 n)
279{
280 union {
281 u64 ll;
282 struct { u32 h, l; };
283 } _;
284 int bit, x, y;
285
286 _.ll = n;
287
288 asm(" subcc %3,gr0,gr0,icc0 \n"
289 " ckeq icc0,cc4 \n"
290 " cscan.p %3,gr0,%0 ,cc4,0 \n"
291 " setlos #63,%1 \n"
292 " cscan.p %4,gr0,%0 ,cc4,1 \n"
293 " setlos #31,%2 \n"
294 " csub.p %1,%0,%0 ,cc4,0 \n"
295 " csub %2,%0,%0 ,cc4,1 \n"
296 : "=&r"(bit), "=r"(x), "=r"(y)
297 : "0r"(_.h), "r"(_.l)
298 : "icc0", "cc4"
299 );
300 return bit;
301}
302
259#include <asm-generic/bitops/sched.h> 303#include <asm-generic/bitops/sched.h>
260#include <asm-generic/bitops/hweight.h> 304#include <asm-generic/bitops/hweight.h>
261 305