Module Name: src
Committed By: matt
Date: Sat Sep 1 11:24:37 UTC 2012
Modified Files:
src/sys/lib/libkern/arch/arm: clzsi2.S
Log Message:
Add ARMv5 support the clz instruction
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libkern/arch/arm/clzsi2.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libkern/arch/arm/clzsi2.S
diff -u src/sys/lib/libkern/arch/arm/clzsi2.S:1.3 src/sys/lib/libkern/arch/arm/clzsi2.S:1.4
--- src/sys/lib/libkern/arch/arm/clzsi2.S:1.3 Wed Oct 15 18:07:46 2008
+++ src/sys/lib/libkern/arch/arm/clzsi2.S Sat Sep 1 11:24:36 2012
@@ -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 @@ ENTRY(__clzsi2)
#endif
#endif /* __OPTIMIZE_SIZE__ */
RET
+#endif /* _ARM_ARCH_5 */
END(__clzsi2)