Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern/arch/arm Add ARMv5 support the clz instruction



details:   https://anonhg.NetBSD.org/src/rev/77159289f686
branches:  trunk
changeset: 781340:77159289f686
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Sep 01 11:24:36 2012 +0000

description:
Add ARMv5 support the clz instruction

diffstat:

 sys/lib/libkern/arch/arm/clzsi2.S |  25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r d61ef0d6c641 -r 77159289f686 sys/lib/libkern/arch/arm/clzsi2.S
--- a/sys/lib/libkern/arch/arm/clzsi2.S Sat Sep 01 11:21:22 2012 +0000
+++ b/sys/lib/libkern/arch/arm/clzsi2.S Sat Sep 01 11:24:36 2012 +0000
@@ -1,3 +1,4 @@
+/* $NetBSD: clzsi2.S,v 1.4 2012/09/01 11:24:36 matt Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,17 +31,36 @@
 
        .text
 ENTRY(__clzdi2)
-       movs    r3, r0
+#ifdef __ARMEB__
+#define        HI      r0
+#define        LO      r1
+#else
+#define        HI      r1
+#define        LO      r0
+#endif
+#if defined(_ARM_ARCH_5)
+       teq     HI, #0          /* high word all zero? */
+       clzne   r0, HI          /* count leading zeros in high word */
+       clzeq   r0, LO          /* yes, count in low word */
+       addeq   r0, r0, #32     /*      and add the bits in the high word */
+       RET
+#else
+       movs    r3, HI
        movne   r0, #31
        bne     .L_clz
-       movs    r3, r1
+       movs    r3, LO
        movne   r0, #63
        bne     .L_clz
        mov     r0, #64
        RET
+#endif
 END(__clzdi2)
 
 ENTRY(__clzsi2)
+#if defined(_ARM_ARCH_5)
+       clz     r0, r0
+       RET
+#else
        movs    r3, r0
        moveq   r0, #32
        RETc(eq)
@@ -85,4 +105,5 @@
 #endif
 #endif /* __OPTIMIZE_SIZE__ */
        RET
+#endif  /* _ARM_ARCH_5 */
 END(__clzsi2)



Home | Main Index | Thread Index | Old Index