summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-12-29 17:43:15 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-12-29 17:43:15 +0000
commit47b4fc964c4486761a3c8de6302562e41e3e121a (patch)
tree584c4b22171b1ed098d94518c11a8c16ed544b0d /sys
parent5d627e49583fbe40c704231f5c838be297f04bda (diff)
Override SoftFloat's countLeadingZeros32() with a faster, ff1-based, version
on m88k.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/m88k/include/ieeefp.h11
-rw-r--r--sys/lib/libkern/softfloat-macros.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/sys/arch/m88k/include/ieeefp.h b/sys/arch/m88k/include/ieeefp.h
index 39e6b13515e..1ea4fcecfc1 100644
--- a/sys/arch/m88k/include/ieeefp.h
+++ b/sys/arch/m88k/include/ieeefp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieeefp.h,v 1.2 2007/12/29 17:41:33 miod Exp $ */
+/* $OpenBSD: ieeefp.h,v 1.3 2007/12/29 17:43:12 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -73,6 +73,15 @@ typedef enum {
#define float_get_round(fpcr) (((fpcr) >> FPCR_RD_SHIFT) & FPCR_RD_MASK)
#define fpgetround() float_get_round(curproc->p_md.md_tf->tf_fpcr)
+#define SOFTFLOAT_MD_CLZ
+static inline int
+countLeadingZeros32(u_int32_t a)
+{
+ int rc;
+ asm volatile("ff1 %0, %1" : "=r"(rc) : "r"(a));
+ return (a != 0 ? 31 - rc : rc);
+}
+
#endif
#endif /* _M88K_IEEEFP_H_ */
diff --git a/sys/lib/libkern/softfloat-macros.h b/sys/lib/libkern/softfloat-macros.h
index d7f6e55fd15..21d5603ec77 100644
--- a/sys/lib/libkern/softfloat-macros.h
+++ b/sys/lib/libkern/softfloat-macros.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softfloat-macros.h,v 1.2 2007/12/29 16:59:16 miod Exp $ */
+/* $OpenBSD: softfloat-macros.h,v 1.3 2007/12/29 17:43:14 miod Exp $ */
/* $NetBSD: softfloat-macros.h,v 1.1 2001/04/26 03:10:47 ross Exp $ */
/*
@@ -654,6 +654,7 @@ Returns the number of leading 0 bits before the most-significant 1 bit of
`a'. If `a' is zero, 32 is returned.
-------------------------------------------------------------------------------
*/
+#ifndef SOFTFLOAT_MD_CLZ
static int8 countLeadingZeros32( bits32 a )
{
static const int8 countLeadingZerosHigh[] = {
@@ -689,6 +690,7 @@ static int8 countLeadingZeros32( bits32 a )
return shiftCount;
}
+#endif
/*
-------------------------------------------------------------------------------