Thu Jul 28 20:53:21 2011 UTC ()
Add scalbn{,f,l} for VAX.


(matt)
diff -r1.112 -r1.113 src/lib/libm/Makefile
diff -r0 -r1.1 src/lib/libm/arch/vax/n_scalbn.S

cvs diff -r1.112 -r1.113 src/lib/libm/Makefile (expand / switch to unified diff)

--- src/lib/libm/Makefile 2011/07/26 16:10:16 1.112
+++ src/lib/libm/Makefile 2011/07/28 20:53:20 1.113
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.112 2011/07/26 16:10:16 joerg Exp $ 1# $NetBSD: Makefile,v 1.113 2011/07/28 20:53:20 matt Exp $
2# 2#
3# @(#)Makefile 5.1beta 93/09/24 3# @(#)Makefile 5.1beta 93/09/24
4# 4#
5# ==================================================== 5# ====================================================
6# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7# 7#
8# Developed at SunPro, a Sun Microsystems, Inc. business. 8# Developed at SunPro, a Sun Microsystems, Inc. business.
9# Permission to use, copy, modify, and distribute this 9# Permission to use, copy, modify, and distribute this
10# software is freely granted, provided that this notice 10# software is freely granted, provided that this notice
11# is preserved. 11# is preserved.
12# ==================================================== 12# ====================================================
13# 13#
14# 14#
@@ -90,32 +90,33 @@ ARCH_SRCS += s_ceil.S s_copysign.S s_fin @@ -90,32 +90,33 @@ ARCH_SRCS += s_ceil.S s_copysign.S s_fin
90COPTS+=-m68040 90COPTS+=-m68040
91ARCH_SRCS = s_copysign.S s_finite.S 91ARCH_SRCS = s_copysign.S s_finite.S
92.else 92.else
93.if (${MKSOFTFLOAT} != "yes") 93.if (${MKSOFTFLOAT} != "yes")
94.PATH: ${.CURDIR}/arch/mc68881 ${.CURDIR}/arch/m68k 94.PATH: ${.CURDIR}/arch/mc68881 ${.CURDIR}/arch/m68k
95ARCH_SRCS = e_acos.S e_asin.S e_atanh.S e_cosh.S e_exp.S e_fmod.S e_log.S \ 95ARCH_SRCS = e_acos.S e_asin.S e_atanh.S e_cosh.S e_exp.S e_fmod.S e_log.S \
96 e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \ 96 e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
97 s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \ 97 s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
98 s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S 98 s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
99.endif 99.endif
100.endif 100.endif
101# end of m68k 101# end of m68k
102.elif (${MACHINE_ARCH} == "vax") 102.elif (${MACHINE_ARCH} == "vax")
103#.PATH: ${.CURDIR}/arch/vax 103.PATH: ${.CURDIR}/arch/vax
104 104
105#NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S 105#NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S
106#ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S 106#ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S
107# XXX - ripped out due to lack of the insn polyd in the Mariah chip, 107# XXX - ripped out due to lack of the insn polyd in the Mariah chip,
108# and emulation code isn't written yet. 108# and emulation code isn't written yet.
 109ARCHS_SRCS = n_scalbn.S
109WARNS?=4 110WARNS?=4
110.endif 111.endif
111 112
112WARNS?=4 113WARNS?=4
113 114
114.PATH: ${.CURDIR}/man 115.PATH: ${.CURDIR}/man
115.PATH: ${.CURDIR}/src 116.PATH: ${.CURDIR}/src
116.PATH: ${.CURDIR}/noieee_src 117.PATH: ${.CURDIR}/noieee_src
117 118
118.if (${MACHINE_ARCH} != "vax") 119.if (${MACHINE_ARCH} != "vax")
119CPPFLAGS+= -D_MULTI_LIBM -D_POSIX_MODE 120CPPFLAGS+= -D_MULTI_LIBM -D_POSIX_MODE
120# XXX noieee libm is gross 121# XXX noieee libm is gross
121COPTS+= -fno-strict-aliasing 122COPTS+= -fno-strict-aliasing

File Added: src/lib/libm/arch/vax/n_scalbn.S
/*-
 * 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