Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libm Add scalbn{,f,l} for VAX.
details: https://anonhg.NetBSD.org/src/rev/a5630aa19e85
branches: trunk
changeset: 767744:a5630aa19e85
user: matt <matt%NetBSD.org@localhost>
date: Thu Jul 28 20:53:20 2011 +0000
description:
Add scalbn{,f,l} for VAX.
diffstat:
lib/libm/Makefile | 5 +-
lib/libm/arch/vax/n_scalbn.S | 77 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 2 deletions(-)
diffs (105 lines):
diff -r b0d951a0e797 -r a5630aa19e85 lib/libm/Makefile
--- a/lib/libm/Makefile Thu Jul 28 20:50:55 2011 +0000
+++ b/lib/libm/Makefile Thu Jul 28 20:53:20 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.112 2011/07/26 16:10:16 joerg Exp $
+# $NetBSD: Makefile,v 1.113 2011/07/28 20:53:20 matt Exp $
#
# @(#)Makefile 5.1beta 93/09/24
#
@@ -100,12 +100,13 @@
.endif
# end of m68k
.elif (${MACHINE_ARCH} == "vax")
-#.PATH: ${.CURDIR}/arch/vax
+.PATH: ${.CURDIR}/arch/vax
#NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S
#ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S
# XXX - ripped out due to lack of the insn polyd in the Mariah chip,
# and emulation code isn't written yet.
+ARCHS_SRCS = n_scalbn.S
WARNS?=4
.endif
diff -r b0d951a0e797 -r a5630aa19e85 lib/libm/arch/vax/n_scalbn.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/arch/vax/n_scalbn.S Thu Jul 28 20:53:20 2011 +0000
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+#include <sys/errno.h>
+
+RCSID("$NetBSD: n_scalbn.S,v 1.1 2011/07/28 20:53:20 matt Exp $")
+
+ENTRY(scalbnf, 0)
+ cvtfd 4(%ap), %r0
+ movl 8(%ap), %r2
+ jr 1f
+
+ALTENTRY(scalbnl)
+ENTRY(scalbn, 0)
+ movd 4(%ap), %r0
+ movl 12(%ap), %r2
+
+ /*
+ * First see if the result will be within bounds
+ */
+1: cmpl %r2,$(256+55)
+ jgeq overflow
+ cmpl %r2,$-(256+55)
+ jleq underflow
+
+ extzv $7, $9, %r0, %r3 /* extract exponent */
+ jneq 5f /* 0 * N is still 0 */
+ cmpw %r3, $-256 /* is this a NAN? */
+ jgtr 2f /* nope */
+ ret
+
+2: movzbl %r3, %r3 /* clear sign bit */
+ addl2 %r2, %r3 /* add to exponent */
+ jleq underflow /* <= 0? */
+
+3: jbs $8, %r3, overflow /* did exponent overflow? */
+ insv $7, $8, %r3, %r0 /* replace exponent */
+ ret
+
+underflow:
+ clrq %r0 /* return 0.0 */
+ jr copysign /* or mabye -0.0 */
+overflow:
+ pushl $ERANGE /* overflow */
+ calls $1, _C_LABEL(infnan) /* possibly signal */
+copysign:
+ jbc $15, 4(%ap), 5f /* if clear, don't set sign-bit */
+ bisw2 $0x8000, %r0 /* preserve sign-bit */
+5:
+ ret
Home |
Main Index |
Thread Index |
Old Index