Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/m68k/fpe Rewrite around BFFFO inline asm.
details: https://anonhg.NetBSD.org/src/rev/3f9466c1e9cb
branches: trunk
changeset: 786223:3f9466c1e9cb
user: isaki <isaki%NetBSD.org@localhost>
date: Sat Apr 20 09:32:28 2013 +0000
description:
Rewrite around BFFFO inline asm.
o Prepare C version of BFFFO (from XM6i).
It is helpful in running FPE on other platforms (for example, for a
test). It is also helpful in porting to non-m68k 3rd party :)
o A BFFFO is supported on 68020 or later (though I'm not sure whether
sun2/68010 uses this FPE correctly or not).
diffstat:
sys/arch/m68k/fpe/fpu_subr.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diffs (62 lines):
diff -r 701adae235f3 -r 3f9466c1e9cb sys/arch/m68k/fpe/fpu_subr.c
--- a/sys/arch/m68k/fpe/fpu_subr.c Sat Apr 20 09:26:23 2013 +0000
+++ b/sys/arch/m68k/fpe/fpu_subr.c Sat Apr 20 09:32:28 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_subr.c,v 1.10 2013/03/26 11:30:21 isaki Exp $ */
+/* $NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_subr.c,v 1.10 2013/03/26 11:30:21 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $");
#include <sys/types.h>
#include <sys/systm.h>
@@ -56,6 +56,25 @@
#include "fpu_arith.h"
/*
+ * m68020 or later has a BFFFO instruction, therefore use it.
+ * Otherwise, use C version.
+ */
+static inline int
+bfffo(uint32_t src)
+{
+ int offset;
+#if defined(__m68k__) && !defined(M68010)
+ __asm volatile("bfffo %1{#0:#32},%0" : "=d"(offset) : "g"(src));
+#else
+ int width = 32;
+ for (offset = 0; width-- > 0 && (int)src >= 0; src <<= 1) {
+ offset++;
+ }
+#endif
+ return offset;
+}
+
+/*
* Shift the given number right rsh bits. Any bits that `fall off' will get
* shoved into the sticky field; we return the resulting sticky. Note that
* shifting NaNs is legal (this will never shift all bits out); a NaN's
@@ -165,7 +184,7 @@
* We have a supernormal number. We need to shift it right.
* We may assume m2==0.
*/
- __asm volatile("bfffo %1{#0:#32},%0" : "=d"(rsh) : "g"(m0));
+ rsh = bfffo(m0);
rsh = 31 - rsh - FP_LG;
exp += rsh;
lsh = 32 - rsh;
@@ -177,7 +196,7 @@
* We have a regular denorm (a subnormal number), and need
* to shift it left.
*/
- __asm volatile("bfffo %1{#0:#32},%0" : "=d"(lsh) : "g"(m0));
+ lsh = bfffo(m0);
lsh = FP_LG - 31 + lsh;
exp -= lsh;
rsh = 32 - lsh;
Home |
Main Index |
Thread Index |
Old Index