xref: /illumos-gate/usr/src/uts/sparc/fpu/utility.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1988,2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /* Utility functions for Sparc FPU simulator. */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #include <sys/fpu/fpu_simulator.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/fpu/globals.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate void
_fp_read_vfreg(FPU_REGS_TYPE * pf,uint_t n,fp_simd_type * pfpsd)35*7c478bd9Sstevel@tonic-gate _fp_read_vfreg(
36*7c478bd9Sstevel@tonic-gate 	FPU_REGS_TYPE	*pf,	/* Old freg value. */
37*7c478bd9Sstevel@tonic-gate 	uint_t		n,	/* Want to read register n. */
38*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd)
39*7c478bd9Sstevel@tonic-gate {
40*7c478bd9Sstevel@tonic-gate 	*pf = pfpsd->fp_current_pfregs->fpu_fr.fpu_regs[n];
41*7c478bd9Sstevel@tonic-gate }
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate void
_fp_write_vfreg(FPU_REGS_TYPE * pf,uint_t n,fp_simd_type * pfpsd)44*7c478bd9Sstevel@tonic-gate _fp_write_vfreg(
45*7c478bd9Sstevel@tonic-gate 	FPU_REGS_TYPE	*pf,	/* New freg value. */
46*7c478bd9Sstevel@tonic-gate 	uint_t		n,	/* Want to read register n. */
47*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd)
48*7c478bd9Sstevel@tonic-gate {
49*7c478bd9Sstevel@tonic-gate 	pfpsd->fp_current_pfregs->fpu_fr.fpu_regs[n] = *pf;
50*7c478bd9Sstevel@tonic-gate }
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate void
_fp_read_vdreg(FPU_DREGS_TYPE * pd,uint_t n,fp_simd_type * pfpsd)53*7c478bd9Sstevel@tonic-gate _fp_read_vdreg(
54*7c478bd9Sstevel@tonic-gate 	FPU_DREGS_TYPE	*pd,	/* Old dreg value. */
55*7c478bd9Sstevel@tonic-gate 	uint_t		n,	/* Want to read register n. */
56*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd)
57*7c478bd9Sstevel@tonic-gate {
58*7c478bd9Sstevel@tonic-gate 	*pd = pfpsd->fp_current_pfregs->fpu_fr.fpu_dregs[n];
59*7c478bd9Sstevel@tonic-gate }
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate void
_fp_write_vdreg(FPU_DREGS_TYPE * pd,uint_t n,fp_simd_type * pfpsd)62*7c478bd9Sstevel@tonic-gate _fp_write_vdreg(
63*7c478bd9Sstevel@tonic-gate 	FPU_DREGS_TYPE	*pd,	/* New dreg value. */
64*7c478bd9Sstevel@tonic-gate 	uint_t		n,	/* Want to read register n. */
65*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd)
66*7c478bd9Sstevel@tonic-gate {
67*7c478bd9Sstevel@tonic-gate 	pfpsd->fp_current_pfregs->fpu_fr.fpu_dregs[n] = *pd;
68*7c478bd9Sstevel@tonic-gate }
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate /*
71*7c478bd9Sstevel@tonic-gate  * Normalize a number.  Does not affect zeros, infs, or NaNs.
72*7c478bd9Sstevel@tonic-gate  * The number will be normalized to 113 bit extended:
73*7c478bd9Sstevel@tonic-gate  *		0x0001####, 0x########, 0x########, 0x########.
74*7c478bd9Sstevel@tonic-gate  */
75*7c478bd9Sstevel@tonic-gate void
fpu_normalize(unpacked * pu)76*7c478bd9Sstevel@tonic-gate fpu_normalize(unpacked *pu)
77*7c478bd9Sstevel@tonic-gate {
78*7c478bd9Sstevel@tonic-gate 	uint_t U, u0, u1, u2, u3, m, n, k;
79*7c478bd9Sstevel@tonic-gate 	u0 = pu->significand[0];
80*7c478bd9Sstevel@tonic-gate 	u1 = pu->significand[1];
81*7c478bd9Sstevel@tonic-gate 	u2 = pu->significand[2];
82*7c478bd9Sstevel@tonic-gate 	u3 = pu->significand[3];
83*7c478bd9Sstevel@tonic-gate 	if ((*pu).fpclass == fp_normal) {
84*7c478bd9Sstevel@tonic-gate 		if ((u0|u1|u2|u3) == 0) {
85*7c478bd9Sstevel@tonic-gate 			(*pu).fpclass = fp_zero;
86*7c478bd9Sstevel@tonic-gate 			return;
87*7c478bd9Sstevel@tonic-gate 		}
88*7c478bd9Sstevel@tonic-gate 		while (u0 == 0) {
89*7c478bd9Sstevel@tonic-gate 			u0 = u1; u1 = u2; u2 = u3; u3 = 0;
90*7c478bd9Sstevel@tonic-gate 			(*pu).exponent = (*pu).exponent - 32;
91*7c478bd9Sstevel@tonic-gate 		}
92*7c478bd9Sstevel@tonic-gate 		if (u0 >= 0x20000) { 	/* u3 should be zero */
93*7c478bd9Sstevel@tonic-gate 			n = 1; U = u0 >> 1;
94*7c478bd9Sstevel@tonic-gate 			while (U >= 0x20000) {
95*7c478bd9Sstevel@tonic-gate 				U >>= 1;
96*7c478bd9Sstevel@tonic-gate 				n += 1;
97*7c478bd9Sstevel@tonic-gate 			}
98*7c478bd9Sstevel@tonic-gate 			m = (1 << n)-1;
99*7c478bd9Sstevel@tonic-gate 			k = 32-n;
100*7c478bd9Sstevel@tonic-gate 			(*pu).exponent += n;
101*7c478bd9Sstevel@tonic-gate 			u3 = ((u2&m)<<k)|(u3>>n);
102*7c478bd9Sstevel@tonic-gate 			u2 = ((u1&m)<<k)|(u2>>n);
103*7c478bd9Sstevel@tonic-gate 			u1 = ((u0&m)<<k)|(u1>>n);
104*7c478bd9Sstevel@tonic-gate 			u0 = U;
105*7c478bd9Sstevel@tonic-gate 		} else if (u0 < 0x10000) {
106*7c478bd9Sstevel@tonic-gate 			n = 1; U = u0 << 1;
107*7c478bd9Sstevel@tonic-gate 			while (U < 0x10000) {
108*7c478bd9Sstevel@tonic-gate 				U <<= 1;
109*7c478bd9Sstevel@tonic-gate 				n += 1;
110*7c478bd9Sstevel@tonic-gate 			}
111*7c478bd9Sstevel@tonic-gate 			k = 32-n;
112*7c478bd9Sstevel@tonic-gate 			m = -(1 << k);
113*7c478bd9Sstevel@tonic-gate 			(*pu).exponent -= n;
114*7c478bd9Sstevel@tonic-gate 			u0 = (u0<<n)|((u1&m)>>k);
115*7c478bd9Sstevel@tonic-gate 			u1 = (u1<<n)|((u2&m)>>k);
116*7c478bd9Sstevel@tonic-gate 			u2 = (u2<<n)|((u3&m)>>k);
117*7c478bd9Sstevel@tonic-gate 			u3 = (u3<<n);
118*7c478bd9Sstevel@tonic-gate 		}
119*7c478bd9Sstevel@tonic-gate 		pu->significand[0] = u0;
120*7c478bd9Sstevel@tonic-gate 		pu->significand[1] = u1;
121*7c478bd9Sstevel@tonic-gate 		pu->significand[2] = u2;
122*7c478bd9Sstevel@tonic-gate 		pu->significand[3] = u3;
123*7c478bd9Sstevel@tonic-gate 	}
124*7c478bd9Sstevel@tonic-gate }
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate /*
127*7c478bd9Sstevel@tonic-gate  * Right shift significand sticky by n bits.
128*7c478bd9Sstevel@tonic-gate  */
129*7c478bd9Sstevel@tonic-gate void
fpu_rightshift(unpacked * pu,int n)130*7c478bd9Sstevel@tonic-gate fpu_rightshift(unpacked *pu, int n)
131*7c478bd9Sstevel@tonic-gate {
132*7c478bd9Sstevel@tonic-gate 	uint_t m, k, j, u0, u1, u2, u3;
133*7c478bd9Sstevel@tonic-gate 	if (n > 113) {		/* drastic */
134*7c478bd9Sstevel@tonic-gate 		if (((*pu).significand[0] | (*pu).significand[1]
135*7c478bd9Sstevel@tonic-gate 			| (*pu).significand[2] | (*pu).significand[3]) == 0) {
136*7c478bd9Sstevel@tonic-gate 						/* really zero */
137*7c478bd9Sstevel@tonic-gate 			pu->fpclass = fp_zero;
138*7c478bd9Sstevel@tonic-gate 			return;
139*7c478bd9Sstevel@tonic-gate 		} else {
140*7c478bd9Sstevel@tonic-gate 			pu->rounded = 0;
141*7c478bd9Sstevel@tonic-gate 			pu->sticky  = 1;
142*7c478bd9Sstevel@tonic-gate 			pu->significand[3] = 0;
143*7c478bd9Sstevel@tonic-gate 			pu->significand[2] = 0;
144*7c478bd9Sstevel@tonic-gate 			pu->significand[1] = 0;
145*7c478bd9Sstevel@tonic-gate 			pu->significand[0] = 0;
146*7c478bd9Sstevel@tonic-gate 			return;
147*7c478bd9Sstevel@tonic-gate 		}
148*7c478bd9Sstevel@tonic-gate 	}
149*7c478bd9Sstevel@tonic-gate 	while (n >= 32) {	/* big shift */
150*7c478bd9Sstevel@tonic-gate 		pu->sticky  |= pu->rounded | (pu->significand[3]&0x7fffffff);
151*7c478bd9Sstevel@tonic-gate 		pu->rounded  = (*pu).significand[3] >> 31;
152*7c478bd9Sstevel@tonic-gate 		(*pu).significand[3] = (*pu).significand[2];
153*7c478bd9Sstevel@tonic-gate 		(*pu).significand[2] = (*pu).significand[1];
154*7c478bd9Sstevel@tonic-gate 		(*pu).significand[1] = (*pu).significand[0];
155*7c478bd9Sstevel@tonic-gate 		(*pu).significand[0] = 0;
156*7c478bd9Sstevel@tonic-gate 		n -= 32;
157*7c478bd9Sstevel@tonic-gate 	}
158*7c478bd9Sstevel@tonic-gate 	if (n > 0) {		/* small shift */
159*7c478bd9Sstevel@tonic-gate 		u0 = pu->significand[0];
160*7c478bd9Sstevel@tonic-gate 		u1 = pu->significand[1];
161*7c478bd9Sstevel@tonic-gate 		u2 = pu->significand[2];
162*7c478bd9Sstevel@tonic-gate 		u3 = pu->significand[3];
163*7c478bd9Sstevel@tonic-gate 		m = (1<<n)-1;
164*7c478bd9Sstevel@tonic-gate 		k = 32 - n;
165*7c478bd9Sstevel@tonic-gate 		j = (1<<(n-1))-1;
166*7c478bd9Sstevel@tonic-gate 		pu->sticky |= pu->rounded | (u3&j);
167*7c478bd9Sstevel@tonic-gate 		pu->rounded = (u3&m)>>(n-1);
168*7c478bd9Sstevel@tonic-gate 		pu->significand[3] = ((u2&m)<<k)|(u3>>n);
169*7c478bd9Sstevel@tonic-gate 		pu->significand[2] = ((u1&m)<<k)|(u2>>n);
170*7c478bd9Sstevel@tonic-gate 		pu->significand[1] = ((u0&m)<<k)|(u1>>n);
171*7c478bd9Sstevel@tonic-gate 		pu->significand[0] = u0>>n;
172*7c478bd9Sstevel@tonic-gate 	}
173*7c478bd9Sstevel@tonic-gate }
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /*
177*7c478bd9Sstevel@tonic-gate  * Set the exception bit in the current exception register.
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate void
fpu_set_exception(pfpsd,ex)180*7c478bd9Sstevel@tonic-gate fpu_set_exception(pfpsd, ex)
181*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd;	/* Pointer to simulator data */
182*7c478bd9Sstevel@tonic-gate 	enum fp_exception_type ex;
183*7c478bd9Sstevel@tonic-gate {
184*7c478bd9Sstevel@tonic-gate 	pfpsd->fp_current_exceptions |= 1 << (int)ex;
185*7c478bd9Sstevel@tonic-gate }
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate /*
188*7c478bd9Sstevel@tonic-gate  * Set invalid exception and error nan in *pu
189*7c478bd9Sstevel@tonic-gate  */
190*7c478bd9Sstevel@tonic-gate void
fpu_error_nan(pfpsd,pu)191*7c478bd9Sstevel@tonic-gate fpu_error_nan(pfpsd, pu)
192*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd;	/* Pointer to simulator data */
193*7c478bd9Sstevel@tonic-gate 	unpacked	*pu;
194*7c478bd9Sstevel@tonic-gate {
195*7c478bd9Sstevel@tonic-gate 	fpu_set_exception(pfpsd, fp_invalid);
196*7c478bd9Sstevel@tonic-gate 	pu->sign = 0;
197*7c478bd9Sstevel@tonic-gate 	pu->significand[0] = 0x7fffffff;
198*7c478bd9Sstevel@tonic-gate 	pu->significand[1] = 0xffffffffUL;
199*7c478bd9Sstevel@tonic-gate 	pu->significand[2] = 0xffffffffUL;
200*7c478bd9Sstevel@tonic-gate 	pu->significand[3] = 0xffffffffUL;
201*7c478bd9Sstevel@tonic-gate }
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /*
204*7c478bd9Sstevel@tonic-gate  * the following fpu_add3wc should be inlined as
205*7c478bd9Sstevel@tonic-gate  *	.inline	_fpu_add3wc, 3
206*7c478bd9Sstevel@tonic-gate  *	ld	[%o1], %o4		! sum = x
207*7c478bd9Sstevel@tonic-gate  *	addcc	-1, %o3, %g0		! restore last carry in cc reg
208*7c478bd9Sstevel@tonic-gate  *	addxcc	%o4, %o2, %o4		! sum = sum + y + last carry
209*7c478bd9Sstevel@tonic-gate  *	st	%o4, [%o0]		! *z  = sum
210*7c478bd9Sstevel@tonic-gate  *	addx	%g0, %g0, %o0		! return new carry
211*7c478bd9Sstevel@tonic-gate  *	.end
212*7c478bd9Sstevel@tonic-gate  */
213*7c478bd9Sstevel@tonic-gate uint_t
fpu_add3wc(uint_t * z,uint_t x,uint_t y,uint_t carry)214*7c478bd9Sstevel@tonic-gate fpu_add3wc(uint_t *z, uint_t x, uint_t y, uint_t carry)
215*7c478bd9Sstevel@tonic-gate {				/*  *z = x + y + carry, set carry; */
216*7c478bd9Sstevel@tonic-gate 	if (carry == 0) {
217*7c478bd9Sstevel@tonic-gate 		*z = x+y;
218*7c478bd9Sstevel@tonic-gate 		return (*z < y);
219*7c478bd9Sstevel@tonic-gate 	} else {
220*7c478bd9Sstevel@tonic-gate 		*z = x+y+1;
221*7c478bd9Sstevel@tonic-gate 		return (*z <= y);
222*7c478bd9Sstevel@tonic-gate 	}
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate /*
226*7c478bd9Sstevel@tonic-gate  * The following fpu_sub3wc should be inlined as
227*7c478bd9Sstevel@tonic-gate  *	.inline	_fpu_sub3wc, 3
228*7c478bd9Sstevel@tonic-gate  *	ld	[%o1], %o4		! sum = *x
229*7c478bd9Sstevel@tonic-gate  *	addcc	-1, %o3, %g0		! restore last carry in cc reg
230*7c478bd9Sstevel@tonic-gate  *	subxcc	%o4, %o2, %o4		! sum = sum - y - last carry
231*7c478bd9Sstevel@tonic-gate  *	st	%o4, [%o0]		! *x  = sum
232*7c478bd9Sstevel@tonic-gate  *	addx	%g0, %g0, %o0		! return new carry
233*7c478bd9Sstevel@tonic-gate  *	.end
234*7c478bd9Sstevel@tonic-gate  */
235*7c478bd9Sstevel@tonic-gate uint_t
fpu_sub3wc(uint_t * z,uint_t x,uint_t y,uint_t carry)236*7c478bd9Sstevel@tonic-gate fpu_sub3wc(uint_t *z, uint_t x, uint_t y, uint_t carry)
237*7c478bd9Sstevel@tonic-gate {				/*  *z = x - y - carry, set carry; */
238*7c478bd9Sstevel@tonic-gate 	if (carry == 0) {
239*7c478bd9Sstevel@tonic-gate 		*z = x-y;
240*7c478bd9Sstevel@tonic-gate 		return (*z > x);
241*7c478bd9Sstevel@tonic-gate 	} else {
242*7c478bd9Sstevel@tonic-gate 		*z = x-y-1;
243*7c478bd9Sstevel@tonic-gate 		return (*z >= x);
244*7c478bd9Sstevel@tonic-gate 	}
245*7c478bd9Sstevel@tonic-gate }
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate /*
248*7c478bd9Sstevel@tonic-gate  * the following fpu_neg2wc should be inlined as
249*7c478bd9Sstevel@tonic-gate  *	.inline	_fpu_neg2wc, 2
250*7c478bd9Sstevel@tonic-gate  *	ld	[%o1], %o3		! tmp = *x
251*7c478bd9Sstevel@tonic-gate  *	addcc	-1, %o2, %g0		! restore last carry in cc reg
252*7c478bd9Sstevel@tonic-gate  *	subxcc	%g0, %o3, %o3		! sum = 0 - tmp - last carry
253*7c478bd9Sstevel@tonic-gate  *	st	%o3, [%o0]		! *x  = sum
254*7c478bd9Sstevel@tonic-gate  *	addx	%g0, %g0, %o0		! return new carry
255*7c478bd9Sstevel@tonic-gate  *	.end
256*7c478bd9Sstevel@tonic-gate  */
257*7c478bd9Sstevel@tonic-gate uint_t
fpu_neg2wc(uint_t * z,uint_t x,uint_t carry)258*7c478bd9Sstevel@tonic-gate fpu_neg2wc(uint_t *z, uint_t x, uint_t carry)
259*7c478bd9Sstevel@tonic-gate {				/*  *x = 0 - *x - carry, set carry; */
260*7c478bd9Sstevel@tonic-gate 	if (carry == 0) {
261*7c478bd9Sstevel@tonic-gate 		*z = -x;
262*7c478bd9Sstevel@tonic-gate 		return ((*z) != 0);
263*7c478bd9Sstevel@tonic-gate 	} else {
264*7c478bd9Sstevel@tonic-gate 		*z = -x-1;
265*7c478bd9Sstevel@tonic-gate 		return (1);
266*7c478bd9Sstevel@tonic-gate 	}
267*7c478bd9Sstevel@tonic-gate }
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate int
fpu_cmpli(uint_t * x,uint_t * y,int n)270*7c478bd9Sstevel@tonic-gate fpu_cmpli(uint_t *x, uint_t *y, int n)
271*7c478bd9Sstevel@tonic-gate {				/* compare two uint_t array */
272*7c478bd9Sstevel@tonic-gate 	int i;
273*7c478bd9Sstevel@tonic-gate 	i = 0;
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate 	while (i < n) {
276*7c478bd9Sstevel@tonic-gate 		if (x[i] > y[i])
277*7c478bd9Sstevel@tonic-gate 			return (1);
278*7c478bd9Sstevel@tonic-gate 		else if (x[i] < y[i])
279*7c478bd9Sstevel@tonic-gate 			return (-1);
280*7c478bd9Sstevel@tonic-gate 		i++;
281*7c478bd9Sstevel@tonic-gate 	}
282*7c478bd9Sstevel@tonic-gate 	return (0);
283*7c478bd9Sstevel@tonic-gate }
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate /*
290*7c478bd9Sstevel@tonic-gate  * Print out unpacked record.
291*7c478bd9Sstevel@tonic-gate  */
292*7c478bd9Sstevel@tonic-gate void
display_unpacked(pu)293*7c478bd9Sstevel@tonic-gate display_unpacked(pu)
294*7c478bd9Sstevel@tonic-gate 	unpacked	*pu;
295*7c478bd9Sstevel@tonic-gate {
296*7c478bd9Sstevel@tonic-gate 	(void) printf(" unpacked ");
297*7c478bd9Sstevel@tonic-gate 	if (pu->sign)
298*7c478bd9Sstevel@tonic-gate 		(void) printf("-");
299*7c478bd9Sstevel@tonic-gate 	else
300*7c478bd9Sstevel@tonic-gate 		(void) printf("+");
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate 	switch (pu->fpclass) {
303*7c478bd9Sstevel@tonic-gate 	case fp_zero:
304*7c478bd9Sstevel@tonic-gate 		(void) printf("0     ");
305*7c478bd9Sstevel@tonic-gate 		break;
306*7c478bd9Sstevel@tonic-gate 	case fp_normal:
307*7c478bd9Sstevel@tonic-gate 		(void) printf("normal");
308*7c478bd9Sstevel@tonic-gate 		break;
309*7c478bd9Sstevel@tonic-gate 	case fp_infinity:
310*7c478bd9Sstevel@tonic-gate 		(void) printf("Inf   ");
311*7c478bd9Sstevel@tonic-gate 		break;
312*7c478bd9Sstevel@tonic-gate 	case fp_quiet:
313*7c478bd9Sstevel@tonic-gate 	case fp_signaling:
314*7c478bd9Sstevel@tonic-gate 		(void) printf("nan   ");
315*7c478bd9Sstevel@tonic-gate 		break;
316*7c478bd9Sstevel@tonic-gate 	}
317*7c478bd9Sstevel@tonic-gate 	(void) printf(" %X %X %X %X (%X, %X) exponent %X \n",
318*7c478bd9Sstevel@tonic-gate 		pu->significand[0], pu->significand[1], pu->significand[2],
319*7c478bd9Sstevel@tonic-gate 		pu->significand[3], (pu->rounded != 0),
320*7c478bd9Sstevel@tonic-gate 		(pu->sticky != 0), pu->exponent);
321*7c478bd9Sstevel@tonic-gate }
322*7c478bd9Sstevel@tonic-gate #endif
323